[llvm] [RISCV][TTI] Scale the cost of ICmp with LMUL (PR #88235)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 10 00:45:07 PDT 2024


================
@@ -1375,14 +1375,47 @@ InstructionCost RISCVTTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
                           LT.second, CostKind);
   }
 
-  if ((Opcode == Instruction::ICmp || Opcode == Instruction::FCmp) &&
-      ValTy->isVectorTy()) {
-    std::pair<InstructionCost, MVT> LT = getTypeLegalizationCost(ValTy);
-
-    // Support natively.
-    if (CmpInst::isIntPredicate(VecPred))
-      return LT.first * 1;
+  if ((Opcode == Instruction::ICmp) && ValTy->isVectorTy()) {
+    unsigned RVVOp;
+    switch (VecPred) {
+    case CmpInst::ICMP_EQ:
+      RVVOp = RISCV::VMSEQ_VV;
+      break;
+    case CmpInst::ICMP_NE:
+      RVVOp = RISCV::VMSNE_VV;
+      break;
+    case CmpInst::ICMP_UGT:
+      RVVOp = RISCV::VMSLTU_VV;
----------------
lukel97 wrote:

We have `RISCV::VMSGTU_VX` and `RISCV::VMSGTU_VI` but I'm not sure if it's worth the effort trying to check if one of the operands is a splat or not. Since these all cost the same.

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


More information about the llvm-commits mailing list