Skip to content

Commit 2e0bea6

Browse files
Move condition that checks whether current reduction is a a partial
reduction.
1 parent b8250bd commit 2e0bea6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9728,7 +9728,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
97289728
// beginning of the dedicated latch block.
97299729
auto *OrigExitingVPV = PhiR->getBackedgeValue();
97309730
auto *NewExitingVPV = PhiR->getBackedgeValue();
9731-
if (!PhiR->isInLoop() && CM.foldTailByMasking()) {
9731+
if (!PhiR->isInLoop() && CM.foldTailByMasking() &&
9732+
!isa<VPPartialReductionRecipe>(OrigExitingVPV->getDefiningRecipe())) {
97329733
VPValue *Cond = RecipeBuilder.getBlockInMask(OrigLoop->getHeader());
97339734
assert(OrigExitingVPV->getDefiningRecipe()->getParent() != LatchVPBB &&
97349735
"reduction recipe must be defined before latch");
@@ -9737,9 +9738,8 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
97379738
PhiTy->isFloatingPointTy()
97389739
? std::make_optional(RdxDesc.getFastMathFlags())
97399740
: std::nullopt;
9740-
if (!isa<VPPartialReductionRecipe>(OrigExitingVPV->getDefiningRecipe()))
9741-
NewExitingVPV =
9742-
Builder.createSelect(Cond, OrigExitingVPV, PhiR, {}, "", FMFs);
9741+
NewExitingVPV =
9742+
Builder.createSelect(Cond, OrigExitingVPV, PhiR, {}, "", FMFs);
97439743
OrigExitingVPV->replaceUsesWithIf(NewExitingVPV, [](VPUser &U, unsigned) {
97449744
return isa<VPInstruction>(&U) &&
97459745
cast<VPInstruction>(&U)->getOpcode() ==

0 commit comments

Comments
 (0)