[llvm] [SLSR] Adding a cost model considering register pressure (PR #213808)

Igor Wodiany via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 13 03:13:30 PDT 2026


================
@@ -1362,11 +1376,124 @@ bool StraightLineStrengthReduceLegacyPass::runOnFunction(Function &F) {
   return StraightLineStrengthReduce(DL, DT, SE, TTI).runOnFunction(F);
 }
 
+// Go through all operands of instruction, and check if any operand is used in
+// another block different from the instruction's block and the other use is
+// not rewritable. return true if such operand is found, otherwise return false.
+bool StraightLineStrengthReduce::
+    hasOperandsUsedInNonRewritableUsersInAnotherBlock(
+        llvm::Instruction *Inst) const {
+  llvm::BasicBlock *InstBB = Inst->getParent();
+
+  for (Value *OpVal : Inst->operand_values()) {
+    auto *OpInst = dyn_cast<Instruction>(OpVal);
+    if (!OpInst)
+      continue;
+
+    for (const User *U : OpInst->users())
----------------
IgWod wrote:

nit: I'd add braces here. It's followed by a single `if` but this `if` is quite big.

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


More information about the llvm-commits mailing list