[llvm] [RISCV][TTI] Implement cost of intrinsic active_lane_mask (PR #87931)

Shih-Po Hung via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 7 23:59:08 PDT 2024


================
@@ -863,6 +863,25 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
     }
     break;
   }
+  case Intrinsic::get_active_lane_mask: {
+    if (ST->hasVInstructions()) {
+      Type *ExpRetTy = VectorType::get(
+          ICA.getArgTypes()[0], cast<VectorType>(RetTy)->getElementCount());
+      auto LT = getTypeLegalizationCost(ExpRetTy);
+
+      // vid.v   v8
----------------
arcbbb wrote:

I thought for that case we may need an argument to know if the user want to include `vid.v` in the cost.
However upon reviewing BasicTTIImpl.h, I notice that the cost is calculated as a sum of  `uadd_sat` and `ICmp`.
I think I can follow that approach.

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


More information about the llvm-commits mailing list