[llvm] [LICM] Preserve Disjoint flag on OR when hoisting. (PR #140266)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri May 16 12:46:28 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))
----------------
fhahn wrote:
Currently this uses the default ConstantFolder, which should be fine, as we either get a constant or the required. OR instruction. This is similar to the code for the other cases above.
Is there any particlar case you are thinking where this would be too fragile? I can imagine that we would have to be more careful if the folder could fold the op to an existing other IR value, in which case we may end up setting the disjoint flags on a different OR than we intended. But I don't think that can be the case with the ConstantFolder.
https://github.com/llvm/llvm-project/pull/140266
More information about the llvm-commits
mailing list