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

Shih-Po Hung via llvm-commits llvm-commits at lists.llvm.org
Mon May 13 00:45:08 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);
----------------
arcbbb wrote:

I think it is `LT.first * getRISCVInstructionCost(VFIRST_M)` 

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


More information about the llvm-commits mailing list