[llvm] [VPlan] Remove VPBlendRecipe and replace with select VPInstructions (PR #150369)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 1 05:16:37 PDT 2025
================
@@ -8944,20 +8948,20 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
// the phi until LoopExitValue. We keep track of the previous item
// (PreviousLink) to tell which of the two operands of a Link will remain
// scalar and which will be reduced. For minmax by select(cmp), Link will be
- // the select instructions. Blend recipes of in-loop reduction phi's will
+ // the select instructions. Blend selects of in-loop reduction phi's will
// get folded to their non-phi operand, as the reduction recipe handles the
// condition directly.
VPSingleDefRecipe *PreviousLink = PhiR; // Aka Worklist[0].
for (VPSingleDefRecipe *CurrentLink : drop_begin(Worklist)) {
- if (auto *Blend = dyn_cast<VPBlendRecipe>(CurrentLink)) {
- assert(Blend->getNumIncomingValues() == 2 &&
- "Blend must have 2 incoming values");
- if (Blend->getIncomingValue(0) == PhiR) {
- Blend->replaceAllUsesWith(Blend->getIncomingValue(1));
+ using namespace VPlanPatternMatch;
+ VPValue *T, *F;
+ if (match(CurrentLink, m_VPInstruction<Instruction::Select>(
+ m_VPValue(), m_VPValue(T), m_VPValue(F)))) {
+ if (T == PhiR) {
+ CurrentLink->replaceAllUsesWith(F);
} else {
- assert(Blend->getIncomingValue(1) == PhiR &&
- "PhiR must be an operand of the blend");
- Blend->replaceAllUsesWith(Blend->getIncomingValue(0));
+ assert(F == PhiR && "PhiR must be an operand of the select");
+ CurrentLink->replaceAllUsesWith(T);
}
----------------
artagnon wrote:
CurrentLink->replaceAllUsesWith(T == PhiR ? F : T);
https://github.com/llvm/llvm-project/pull/150369
More information about the llvm-commits
mailing list