[llvm] [CorrelatedValuePropagation] Drop stale debug records on context-only rewrites (PR #218498)

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 01:24:00 PDT 2026


================
@@ -4392,6 +4392,9 @@ Instruction *InstCombinerImpl::visitCondBrInst(CondBrInst &BI) {
     // Swap destinations and condition.
     auto *Cmp = cast<CmpInst>(Cond);
     Cmp->setPredicate(CmpInst::getInversePredicate(Pred));
+    // The comparison now has the inverse value. Keep attached debug records
+    // describing the original source predicate by adding a logical not.
+    freelyInvertAllUsersOf(Cmp, &BI);
----------------
jmorse wrote:

As I understand it, this change means that this patch will cause LLVM to generate different code in some circumstances, yes? If so, it should be separated out into a different patch or at least have an independent justification, as we can't base codegen decisions on what's good for debug-info.

https://github.com/llvm/llvm-project/pull/218498


More information about the llvm-commits mailing list