[llvm] [RISCV] Add cost for @llvm.experimental.vp.splat (PR #117313)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 25 07:21:46 PST 2024


================
@@ -1155,6 +1155,11 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
     return getCmpSelInstrCost(Instruction::Select, ICA.getReturnType(),
                               ICA.getArgTypes()[0], CmpInst::BAD_ICMP_PREDICATE,
                               CostKind);
+  case Intrinsic::experimental_vp_splat: {
+    auto LT = getTypeLegalizationCost(RetTy);
----------------
lukel97 wrote:

I took a look into this, but ended up in a bit of a rabbit hole. The default BasicTTIImpl scalarization implementation calls into the InsertElement/ExtractElement cost, but currently we return a cost of 0 for constant indices which at least isn't true for the inserts generated from a scalarized splat shuffle, for example.

However changing the InsertElement/ExtractElement cost seems somewhat sensitive, see #67334. I think we may want to make the cost "dumber", e.g. just a single scalar load/store for any insert or extract, but we would need to double check this doesn't cause excessive unrolling.

This is more complicated than what I first thought it would be, so leaving a note here to maybe return to later.

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


More information about the llvm-commits mailing list