[llvm] [SLP]Fix graph traversal in getSpillCost (PR #124984)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 4 03:29:49 PST 2025


================
@@ -12252,25 +12254,28 @@ InstructionCost BoUpSLP::getSpillCost() const {
       };
 
       // Debug information does not impact spill cost.
-      if (isa<CallBase>(&*PrevInstIt) && !NoCallIntrinsic(&*PrevInstIt) &&
-          &*PrevInstIt != PrevInst)
+      // Vectorized calls, represented as vector intrinsics, do not impact spill
+      // cost.
+      if (const auto *CB = dyn_cast<CallBase>(&*PrevInstIt);
+          CB && !NoCallIntrinsic(CB) && !isVectorized(CB))
----------------
alexey-bataev wrote:

> It think vectorized calls might still impact spill cost. E.g. `call <2 x i64> @llvm.sin(<2 x i64> %x)` will get scalarized during codegen to:
> 
> ```assembly
> 	vs1r.v	v8, (a0)                        # Unknown-size Folded Spill
> 	vslidedown.vi	v8, v8, 1
> 	vfmv.f.s	fa0, v8
> 	call	tanh
> 	fmv.d	fs0, fa0
> 	fld	fa0, 16(sp)                     # 8-byte Folded Reload
> 	call	tanh
> ```

I have https://github.com/llvm/llvm-project/pull/125070 to fix this

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


More information about the llvm-commits mailing list