[llvm] [RISCV][CostModel] Fix invalid cost for vector select on targets without FP vector support (PR #183158)

via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 4 22:39:28 PST 2026


================
@@ -2303,6 +2303,16 @@ InstructionCost RISCVTTIImpl::getCmpSelInstrCost(
 
   std::pair<InstructionCost, MVT> LT = getTypeLegalizationCost(ValTy);
   if (Opcode == Instruction::Select && ValTy->isVectorTy()) {
+    // If the target lacks native support for the floating-point vector type,
+    // fall back to BaseT model. This calculates a scalarized cost for fixed vectors,
+    // and correctly returns an Invalid cost for scalable vectors.
+    if (ValTy->isVectorTy() && ValTy->getScalarType()->isFloatingPointTy() &&
----------------
tudinhh wrote:

Yes, bfloat also falls into these conditions

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


More information about the llvm-commits mailing list