Skip to content

Commit f3d4166

Browse files
committed
[InstCombine] Report change in non zero phi transform
We need to inform InstCombine (and transitively the pass manager) that we changed an instruction.
1 parent 07e4625 commit f3d4166

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1194,15 +1194,22 @@ Instruction *InstCombiner::visitPHINode(PHINode &PN) {
11941194
if (CmpInst && isa<IntegerType>(PN.getType()) && CmpInst->isEquality() &&
11951195
match(CmpInst->getOperand(1), m_Zero())) {
11961196
ConstantInt *NonZeroConst = nullptr;
1197+
bool MadeChange = false;
11971198
for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) {
11981199
Instruction *CtxI = PN.getIncomingBlock(i)->getTerminator();
11991200
Value *VA = PN.getIncomingValue(i);
12001201
if (isKnownNonZero(VA, DL, 0, &AC, CtxI, &DT)) {
12011202
if (!NonZeroConst)
12021203
NonZeroConst = GetAnyNonZeroConstInt(PN);
1203-
PN.setIncomingValue(i, NonZeroConst);
1204+
1205+
if (NonZeroConst != VA) {
1206+
PN.setIncomingValue(i, NonZeroConst);
1207+
MadeChange = true;
1208+
}
12041209
}
12051210
}
1211+
if (MadeChange)
1212+
return &PN;
12061213
}
12071214
}
12081215

0 commit comments

Comments
 (0)