[llvm] [RISCV][TTI] Refine the cost of FCmp (PR #88833)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 17 16:14:20 PDT 2024


================
@@ -1383,7 +1385,13 @@ InstructionCost RISCVTTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
            getRISCVInstructionCost(RISCV::VMSLT_VV, LT.second, CostKind);
   }
 
-  if ((Opcode == Instruction::FCmp) && ValTy->isVectorTy()) {
+  if ((Opcode == Instruction::FCmp) && ValTy->isVectorTy() &&
+      CmpInst::isFPPredicate(VecPred)) {
+
+    // Use VMXOR_MM and VMXNOR_MM to generate all true/false mask
+    if ((VecPred == CmpInst::FCMP_FALSE) || (VecPred == CmpInst::FCMP_TRUE))
+      return getRISCVInstructionCost(RISCV::VMXOR_MM, LT.second, CostKind);
----------------
topperc wrote:

Hopefully VMXOR_MM doesn't use the LMUL? Since a mask always fits in VLEN or fewer bits, they shouldn't be affected by LMUL.

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


More information about the llvm-commits mailing list