[llvm] [RISCV][CostModel] Add cost model for experimental.cttz.elts (PR #91778)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon May 13 10:16:58 PDT 2024


================
@@ -901,6 +902,29 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
                  getRISCVInstructionCost(RISCV::VADD_VX, LT.second, CostKind);
     return 1 + (LT.first - 1);
   }
+  case Intrinsic::experimental_cttz_elts: {
+    Type *ArgTy = ICA.getArgTypes()[0];
+    EVT ArgType = TLI->getValueType(DL, ArgTy, true);
+    if (getTLI()->shouldExpandCttzElements(ArgType))
+      break;
+    auto LT = getTypeLegalizationCost(RetTy);
+    InstructionCost Cost =
+        getRISCVInstructionCost(
+            RISCV::VFIRST_M, getTypeLegalizationCost(ArgTy).second, CostKind) +
+        (LT.first - 1);
----------------
topperc wrote:

Is there even a cost for legalizing. If LT.first > 1 then the result type is something like i128 on RV64. The upper 64 bits will just be 0. Won't we just use X0 for all uses of that 0. Does it really have a cost at all?

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


More information about the llvm-commits mailing list