[llvm] [RISCV][CostModel] Remove inst cost of cmp inst in cmp-select sequence. (PR #91158)

Kito Cheng via llvm-commits llvm-commits at lists.llvm.org
Sun May 5 20:35:40 PDT 2024


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

`PseudoCCMOVGPR` is only available when `HasShortForwardBranchOpt` or `HasConditionalMoveFusion`, so it's should not free when SFB and conditional move fusion are not available? 

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


More information about the llvm-commits mailing list