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

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 4 23:00:09 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() &&
+        ((ValTy->getScalarSizeInBits() == 16 && !ST->hasVInstructionsF16()) ||
----------------
topperc wrote:

Does this need to use hasVInstructionsF16Minimal? f16 vectors are legal when hasVInstructionsF16Minimal is true.

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


More information about the llvm-commits mailing list