[llvm] [InstSimplify] Fix Inconsistent PHI Simplification (PR #113037)
Marius Kamp via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 6 08:03:32 PST 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:
I've changed the code a bit to make it easier to understand.
https://github.com/llvm/llvm-project/pull/113037
More information about the llvm-commits
mailing list