diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp index f4ecb126c1a1d..24881926cf116 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp @@ -1964,8 +1964,9 @@ InstructionCost VPWidenSelectRecipe::computeCost(ElementCount VF, if (!ScalarCond) CondTy = VectorType::get(CondTy, VF); - llvm::CmpPredicate Pred; - match(getOperand(0), m_Cmp(Pred, m_VPValue(), m_VPValue())); + CmpInst::Predicate Pred = CmpInst::BAD_ICMP_PREDICATE; + if (auto *Cmp = dyn_cast(SI->getCondition())) + Pred = Cmp->getPredicate(); return Ctx.TTI.getCmpSelInstrCost( Instruction::Select, VectorTy, CondTy, Pred, Ctx.CostKind, {TTI::OK_AnyValue, TTI::OP_None}, {TTI::OK_AnyValue, TTI::OP_None}, SI); diff --git a/llvm/test/Transforms/LoopVectorize/AArch64/select-costs.ll b/llvm/test/Transforms/LoopVectorize/AArch64/select-costs.ll index 9460705e61c9c..7fcfcf05b89ca 100644 --- a/llvm/test/Transforms/LoopVectorize/AArch64/select-costs.ll +++ b/llvm/test/Transforms/LoopVectorize/AArch64/select-costs.ll @@ -92,10 +92,10 @@ exit: define i32 @select_xor_cond(ptr %src, i1 %c.0) { ; CHECK: LV: Checking a loop in 'select_xor_cond' -; CHECK: Cost of 1 for VF 2: WIDEN-SELECT ir<%sel> = select ir<%c>, ir, ir<%c.0> -; CHECK: Cost of 1 for VF 4: WIDEN-SELECT ir<%sel> = select ir<%c>, ir, ir<%c.0> -; CHECK: Cost of 1 for VF 8: WIDEN-SELECT ir<%sel> = select ir<%c>, ir, ir<%c.0> -; CHECK: Cost of 1 for VF 16: WIDEN-SELECT ir<%sel> = select ir<%c>, ir, ir<%c.0> +; CHECK: Cost of 6 for VF 2: WIDEN-SELECT ir<%sel> = select ir<%c>, ir, ir<%c.0> +; CHECK: Cost of 12 for VF 4: WIDEN-SELECT ir<%sel> = select ir<%c>, ir, ir<%c.0> +; CHECK: Cost of 24 for VF 8: WIDEN-SELECT ir<%sel> = select ir<%c>, ir, ir<%c.0> +; CHECK: Cost of 48 for VF 16: WIDEN-SELECT ir<%sel> = select ir<%c>, ir, ir<%c.0> ; CHECK: LV: Selecting VF: 4. entry: