[llvm] [X86][CostModel] Add vXi64 divide/remainder-by-constant costs (PR #208491)

Rito Takeuchi via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 9 16:47:23 PDT 2026


Licht-T wrote:

Thanks, @Andarwinux.

I think the root cause isn't the `v4i64` entry being too high, though; it's that a scalar integer divide-by-constant is currently costed as a single instruction (`getArithmeticInstrCost` returns the generic divide cost), when it's really a ~5-instruction magic multiply.

That makes the SLP tree comparison lop-sided:
- `v8i64`: vector tree ~ `vload + vdiv(15) + vstore = 17` vs scalar tree `8 × (1+1+1) = 24`, vectorizes.
- `v4i64`: same vector tree `17` vs scalar tree `4 × (1+1+1) = 12`, stay scalar.

The only thing that changes between the two is the lane count amortizing the scalar side, and each scalar lane is priced at 1 instead of ~5.

Thinking lowering the `v4i64` cost would cover over this but cause break down elsewhere. So, I'd rather fix the scalar side in another PR. Any thoughts? 


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


More information about the llvm-commits mailing list