[llvm] f3d4166 - [InstCombine] Report change in non zero phi transform
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 31 12:52:51 PDT 2020
Author: Nikita Popov
Date: 2020-03-31T21:52:40+02:00
New Revision: f3d4166368b0449baea1e7d8e043d0fe76930179
URL: https://github.com/llvm/llvm-project/commit/f3d4166368b0449baea1e7d8e043d0fe76930179
DIFF: https://github.com/llvm/llvm-project/commit/f3d4166368b0449baea1e7d8e043d0fe76930179.diff
LOG: [InstCombine] Report change in non zero phi transform
We need to inform InstCombine (and transitively the pass manager)
that we changed an instruction.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
index 6c2aead5a754..9cdb68d07aa1 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
@@ -1194,15 +1194,22 @@ Instruction *InstCombiner::visitPHINode(PHINode &PN) {
if (CmpInst && isa<IntegerType>(PN.getType()) && CmpInst->isEquality() &&
match(CmpInst->getOperand(1), m_Zero())) {
ConstantInt *NonZeroConst = nullptr;
+ bool MadeChange = false;
for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) {
Instruction *CtxI = PN.getIncomingBlock(i)->getTerminator();
Value *VA = PN.getIncomingValue(i);
if (isKnownNonZero(VA, DL, 0, &AC, CtxI, &DT)) {
if (!NonZeroConst)
NonZeroConst = GetAnyNonZeroConstInt(PN);
- PN.setIncomingValue(i, NonZeroConst);
+
+ if (NonZeroConst != VA) {
+ PN.setIncomingValue(i, NonZeroConst);
+ MadeChange = true;
+ }
}
}
+ if (MadeChange)
+ return &PN;
}
}
More information about the llvm-commits
mailing list