[llvm] [VectorCombine] Fix invalid shuffle cost argument of foldShuffleOfSelects (PR #130281)

via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 7 06:53:34 PST 2025


================
@@ -2051,24 +2050,26 @@ bool VectorCombine::foldShuffleOfSelects(Instruction &I) {
        (SI0FOp->getFastMathFlags() != SI1FOp->getFastMathFlags())))
     return false;
 
+  auto *SrcVecTy = dyn_cast<FixedVectorType>(T1->getType());
+  auto *DstVecTy = dyn_cast<FixedVectorType>(I.getType());
   auto SK = TargetTransformInfo::SK_PermuteTwoSrc;
   auto SelOp = Instruction::Select;
   InstructionCost OldCost = TTI.getCmpSelInstrCost(
-      SelOp, T1->getType(), C1VecTy, CmpInst::BAD_ICMP_PREDICATE, CostKind);
-  OldCost += TTI.getCmpSelInstrCost(SelOp, T2->getType(), C2VecTy,
+      SelOp, DstVecTy, C1VecTy, CmpInst::BAD_ICMP_PREDICATE, CostKind);
+  OldCost += TTI.getCmpSelInstrCost(SelOp, DstVecTy, C2VecTy,
----------------
ParkHanbum wrote:

I see that SelectInst takes a DestVecTy as an argument, see VPlanRecipes.cpp:2192.
am I wrong?

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


More information about the llvm-commits mailing list