[llvm] [llvm][LICM] Add flag to control re-association (PR #149829)

Theodoros Theodoridis via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 21 08:57:29 PDT 2025


================
@@ -2850,7 +2855,7 @@ static bool hoistBOAssociation(Instruction &I, Loop &L,
   bool LVInRHS = L.isLoopInvariant(BO->getOperand(0));
   auto *BO0 = dyn_cast<BinaryOperator>(BO->getOperand(LVInRHS));
   if (!BO0 || BO0->getOpcode() != Opcode || !BO0->isAssociative() ||
-      BO0->hasNUsesOrMore(3))
+      BO0->hasNUsesOrMore(BOAssociationUserLimit + 1))
----------------
thetheodor wrote:

`hasNUsesOrMore(N+1)` itself is indeed a lower bound. However, in this case, if it's true then (next line) we don't perform the re-association. We are essentially checking if the number of uses is at most `N`. 

I could rewrite this to `!BO0->getNumUses() <= BOAssociationUserLimit` to make it clearer.



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


More information about the llvm-commits mailing list