diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp index 79f6858463d7e..267eb319a5616 100644 --- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp +++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp @@ -1435,8 +1435,9 @@ static bool checkAndReplaceCondition( generateReproducer(Cmp, ReproducerModule, ReproducerCondStack, Info, DT); Constant *ConstantC = ConstantInt::getBool( CmpInst::makeCmpResultType(Cmp->getType()), IsTrue); - Cmp->replaceUsesWithIf(ConstantC, [&DT, NumIn, NumOut, - ContextInst](Use &U) { + bool Changed = false; + Cmp->replaceUsesWithIf(ConstantC, [&DT, NumIn, NumOut, ContextInst, + &Changed](Use &U) { auto *UserI = getContextInstForUse(U); auto *DTN = DT.getNode(UserI->getParent()); if (!DTN || DTN->getDFSNumIn() < NumIn || DTN->getDFSNumOut() > NumOut) @@ -1448,12 +1449,14 @@ static bool checkAndReplaceCondition( // Conditions in an assume trivially simplify to true. Skip uses // in assume calls to not destroy the available information. auto *II = dyn_cast(U.getUser()); - return !II || II->getIntrinsicID() != Intrinsic::assume; + bool ShouldReplace = !II || II->getIntrinsicID() != Intrinsic::assume; + Changed |= ShouldReplace; + return ShouldReplace; }); NumCondsRemoved++; if (Cmp->use_empty()) ToRemove.push_back(Cmp); - return true; + return Changed; }; if (auto ImpliedCondition = diff --git a/llvm/test/Transforms/ConstraintElimination/analysis-invalidation.ll b/llvm/test/Transforms/ConstraintElimination/analysis-invalidation.ll index e59bd13603fff..cb51f8c852503 100644 --- a/llvm/test/Transforms/ConstraintElimination/analysis-invalidation.ll +++ b/llvm/test/Transforms/ConstraintElimination/analysis-invalidation.ll @@ -43,10 +43,6 @@ ; CHECK-NEXT: Running analysis: ScalarEvolutionAnalysis on test_mul_const_nuw_unsigned_14 ; CHECK-NEXT: Running analysis: TargetLibraryAnalysis on test_mul_const_nuw_unsigned_14 ; CHECK-NEXT: Running analysis: OptimizationRemarkEmitterAnalysis on test_mul_const_nuw_unsigned_14 -; CHECK-NEXT: Invalidating analysis: DemandedBitsAnalysis on test_mul_const_nuw_unsigned_14 -; CHECK-NEXT: Running pass: RequireAnalysisPass -; CHECK-NEXT: Running analysis: DemandedBitsAnalysis on test_mul_const_nuw_unsigned_14 - declare { i8, i1 } @llvm.ssub.with.overflow.i8(i8, i8)