[llvm] [RISCV][CostModel] Remove cost of icmp inst in icmp+select with SFB. (PR #91158)

Kito Cheng via llvm-commits llvm-commits at lists.llvm.org
Fri May 10 01:42:33 PDT 2024


================
@@ -1443,6 +1443,17 @@ InstructionCost RISCVTTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
     }
   }
 
+  // With ShortForwardBranchOpt or ConditionalMoveFusion, scalar icmp + select
+  // instructions will lower to SELECT_CC and lower to PseudoCCMOVGPR which will
+  // generate a conditional branch + mv. The cost of scalar (icmp + select) will
+  // be (0 + select instr cost).
+  if (ST->hasConditionalMoveFusion() && I && isa<ICmpInst>(I) &&
+      !ValTy->isVectorTy() && I->hasOneUser() &&
+      isa<SelectInst>(I->user_back()) &&
+      !I->user_back()->getType()->isVectorTy() &&
----------------
kito-cheng wrote:

Should we just check `I->user_back()->getType()->isIntegerTy()` rather than `!I->user_back()->getType()->isVectorTy()`? It can also filter out something like icmp + select with fp value.

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


More information about the llvm-commits mailing list