[llvm] [LV] Stop using the legacy cost model for udiv + friends (PR #152707)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 20 01:13:48 PDT 2025


================
@@ -952,6 +952,19 @@ InstructionCost VPInstruction::computeCost(ElementCount VF,
   }
 
   switch (getOpcode()) {
+  case Instruction::Select: {
+    // TODO: It may be possible to improve this by analyzing where the
----------------
lukel97 wrote:

One place on RISC-V where the underlying instruction makes a difference is when we use it to create the EVL tail folding AVL in https://github.com/llvm/llvm-project/pull/152707#discussion_r2269261910

It's not costed for in the legacy cost model so that might cause a mismatch. And from what I remember looking at this yesterday, out-of-loop reductions have a VPInstruction select inserted in the latch that isn't costed in the legacy cost model:

https://github.com/llvm/llvm-project/blob/0fa6fdfbb8652c0311d27333934cc4e102df1df2/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp#L9164-L9173

I think that might now be costed with this patch? 

Partial reductions also create a select, but I think any plan with a VPPartialReduction is added to the assertion-skip-list thing.

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


More information about the llvm-commits mailing list