[llvm] [RISCV][TTI] Add vp.cmp intrinsic cost with functionalOPC. (PR #107504)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 6 11:01:42 PDT 2024


================
@@ -1015,6 +1015,23 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
       return getArithmeticInstrCost(*FOp, ICA.getReturnType(), CostKind);
     break;
   }
+
+  // vp compare
+  case Intrinsic::vp_icmp:
+  case Intrinsic::vp_fcmp: {
+    Intrinsic::ID IID = ICA.getID();
+    std::optional<unsigned> FOp = VPIntrinsic::getFunctionalOpcodeForVP(IID);
+    CmpInst::Predicate Pred;
+
+    if (IID == Intrinsic::vp_icmp)
+      Pred = CmpInst::ICMP_SLT;
----------------
preames wrote:

You need to get the code from the intrinsic as the cost of the comparison does depend on the predicate. 

If you have a type based query (i.e. no args), then you probably shouldn't return a cost here at all.

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


More information about the llvm-commits mailing list