From bf1d4a0710a6e1d2c99e579bcf435b92ab5d0506 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Sat, 17 May 2025 14:48:39 +0100 Subject: [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 --- llvm/lib/Transforms/Scalar/LICM.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'llvm/lib') 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(Inv)) I->setFastMathFlags(Intersect); NewBO->setFastMathFlags(Intersect); + } else if (Opcode == Instruction::Or) { + bool Disjoint = cast(BO)->isDisjoint() && + cast(BO0)->isDisjoint(); + // If `Inv` was not constant-folded, a new Instruction has been created. + if (auto *I = dyn_cast(Inv)) + I->setIsDisjoint(Disjoint); + cast(NewBO)->setIsDisjoint(Disjoint); } BO->replaceAllUsesWith(NewBO); -- cgit v1.1