[llvm] [InstSimplify] Fix Inconsistent PHI Simplification (PR #113037)
Marius Kamp via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 22 03:22:23 PDT 2024
================
@@ -5309,20 +5357,18 @@ static Value *simplifyPHINode(PHINode *PN, ArrayRef<Value *> IncomingValues,
continue;
}
if (Q.isUndefValue(Incoming)) {
- // Remember that we saw an undef value, but otherwise ignore them.
+ // Remember that we saw an undef value.
HasUndefInput = true;
- continue;
}
- if (CommonValue && Incoming != CommonValue)
+ CommonValue = getCommonPHIValue(CommonValue, Incoming, Q);
+ if (!CommonValue)
return nullptr; // Not the same, bail out.
- CommonValue = Incoming;
}
- // If CommonValue is null then all of the incoming values were either undef,
- // poison or equal to the phi node itself.
+ // If CommonValue is null then all of the incoming values were either poison
+ // or equal to the phi node itself.
if (!CommonValue)
- return HasUndefInput ? UndefValue::get(PN->getType())
- : PoisonValue::get(PN->getType());
+ return PoisonValue::get(PN->getType());
----------------
mskamp wrote:
If we encounter an `undef`, we now call `getCommonPHIValue()`. If this function returns `nullptr`, `simplifyPHINode()` also returns `nullptr`. Hence, my understanding is that we should reach this point only if all `Incoming` values equal the PHI node or are poison.
https://github.com/llvm/llvm-project/pull/113037
More information about the llvm-commits
mailing list