[llvm] [LICM] Preserve Disjoint flag on OR when hoisting. (PR #140266)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Fri May 16 10:52:48 PDT 2025


================
@@ -2877,6 +2877,12 @@ static bool hoistBOAssociation(Instruction &I, Loop &L,
     if (auto *I = dyn_cast<Instruction>(Inv))
       I->setFastMathFlags(Intersect);
     NewBO->setFastMathFlags(Intersect);
+  } else if (Opcode == Instruction::Or) {
+    bool Disjoint = cast<PossiblyDisjointInst>(BO)->isDisjoint() &&
+                    cast<PossiblyDisjointInst>(BO0)->isDisjoint();
+    if (auto *I = dyn_cast<PossiblyDisjointInst>(Inv))
----------------
efriedma-quic wrote:

This cast is fragile; it only works under certain assumptions about what the IRBuilder will not fold.

Maybe use `IRBuilder<NoFolder>`, so you can just `cast<>`?

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


More information about the llvm-commits mailing list