[llvm] [GVNSink] Fix incorrect codegen with respect to GEPs #85333 (PR #88440)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 29 15:04:48 PDT 2024
================
@@ -719,21 +719,22 @@ GVNSink::analyzeInstructionForSinking(LockstepReverseIterator &LRI,
// try and continue making progress.
Instruction *I0 = NewInsts[0];
- // If all instructions that are going to participate don't have the same
- // number of operands, we can't do any useful PHI analysis for all operands.
- auto hasDifferentNumOperands = [&I0](Instruction *I) {
- return I->getNumOperands() != I0->getNumOperands();
+ auto hasDifferentOperands = [&I0](Instruction *I) {
+ return !I0->isSameOperationAs(I);
};
- if (any_of(NewInsts, hasDifferentNumOperands))
+
+ if (any_of(NewInsts, hasDifferentOperands))
return std::nullopt;
for (unsigned OpNum = 0, E = I0->getNumOperands(); OpNum != E; ++OpNum) {
ModelledPHI PHI(NewInsts, OpNum, ActivePreds);
if (PHI.areAllIncomingValuesSame())
continue;
- if (!canReplaceOperandWithVariable(I0, OpNum))
- // We can 't create a PHI from this instruction!
- return std::nullopt;
+ for (auto &Candidate : NewInsts) {
----------------
hiraditya wrote:
Upon further inspection, it doesn't appear to be needed. After checking all instructions represent same operation, checking w.r.t one instruction is sufficient.
https://github.com/llvm/llvm-project/pull/88440
More information about the llvm-commits
mailing list