Skip to content

Commit cf3be5b

Browse files
committed
[ConstraintElim] Preserve analyses when IR is unchanged.
1 parent b248817 commit cf3be5b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

llvm/lib/Transforms/Scalar/ConstraintElimination.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,8 +1435,9 @@ static bool checkAndReplaceCondition(
14351435
generateReproducer(Cmp, ReproducerModule, ReproducerCondStack, Info, DT);
14361436
Constant *ConstantC = ConstantInt::getBool(
14371437
CmpInst::makeCmpResultType(Cmp->getType()), IsTrue);
1438-
Cmp->replaceUsesWithIf(ConstantC, [&DT, NumIn, NumOut,
1439-
ContextInst](Use &U) {
1438+
bool Changed = false;
1439+
Cmp->replaceUsesWithIf(ConstantC, [&DT, NumIn, NumOut, ContextInst,
1440+
&Changed](Use &U) {
14401441
auto *UserI = getContextInstForUse(U);
14411442
auto *DTN = DT.getNode(UserI->getParent());
14421443
if (!DTN || DTN->getDFSNumIn() < NumIn || DTN->getDFSNumOut() > NumOut)
@@ -1448,12 +1449,14 @@ static bool checkAndReplaceCondition(
14481449
// Conditions in an assume trivially simplify to true. Skip uses
14491450
// in assume calls to not destroy the available information.
14501451
auto *II = dyn_cast<IntrinsicInst>(U.getUser());
1451-
return !II || II->getIntrinsicID() != Intrinsic::assume;
1452+
bool ShouldReplace = !II || II->getIntrinsicID() != Intrinsic::assume;
1453+
Changed |= ShouldReplace;
1454+
return ShouldReplace;
14521455
});
14531456
NumCondsRemoved++;
14541457
if (Cmp->use_empty())
14551458
ToRemove.push_back(Cmp);
1456-
return true;
1459+
return Changed;
14571460
};
14581461

14591462
if (auto ImpliedCondition =

0 commit comments

Comments
 (0)