aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2025-05-17 14:48:39 +0100
committerGitHub <noreply@github.com>2025-05-17 14:48:39 +0100
commitbf1d4a0710a6e1d2c99e579bcf435b92ab5d0506 (patch)
treee6e1fa3b3626e03667169567780912b70479638a /llvm/lib
parent722385e87bb8e6e0fe79975d679285815629cc7f (diff)
downloadllvm-bf1d4a0710a6e1d2c99e579bcf435b92ab5d0506.zip
llvm-bf1d4a0710a6e1d2c99e579bcf435b92ab5d0506.tar.gz
llvm-bf1d4a0710a6e1d2c99e579bcf435b92ab5d0506.tar.bz2
[LICM] Preserve Disjoint flag on OR when hoisting. (#140266)
Update hoistBOAssociation to preserve Disjoint flags on the newly created instructions if both ORs are disjoint. Fixes https://github.com/llvm/llvm-project/issues/139625. PR: https://github.com/llvm/llvm-project/pull/140266
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/LICM.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index 62ef40c..7d89a13 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -2877,6 +2877,13 @@ 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 `Inv` was not constant-folded, a new Instruction has been created.
+ if (auto *I = dyn_cast<PossiblyDisjointInst>(Inv))
+ I->setIsDisjoint(Disjoint);
+ cast<PossiblyDisjointInst>(NewBO)->setIsDisjoint(Disjoint);
}
BO->replaceAllUsesWith(NewBO);