[llvm] [CGP] Drop poison-generating flags after hoisting (PR #90382)

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 06:22:46 PDT 2026


================
@@ -8268,8 +8268,10 @@ static bool optimizeBranch(BranchInst *Branch, const TargetLowering &TLI,
     if (CmpC.isPowerOf2() && Cmp->getPredicate() == ICmpInst::ICMP_ULT &&
         match(UI, m_Shr(m_Specific(X), m_SpecificInt(CmpC.logBase2())))) {
       IRBuilder<> Builder(Branch);
-      if (UI->getParent() != Branch->getParent())
+      if (UI->getParent() != Branch->getParent()) {
----------------
zmodem wrote:

Sorry to revive an old thread, but I was following the tracks back to this PR.

I understand the hoisting issue: moving an add/sub above a range check of one of its operands means nsw/nuw may no longer be true.

But if we didn't hoist (or otherwise move) the instruction, why would adding a new use affect whether nsw/nuw holds true?

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


More information about the llvm-commits mailing list