Skip to content

Commit 78fe997

Browse files
Address comments, such as removing and renaming tests
1 parent 2e0bea6 commit 78fe997

File tree

4 files changed

+257
-663
lines changed

4 files changed

+257
-663
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9728,6 +9728,11 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
97289728
// beginning of the dedicated latch block.
97299729
auto *OrigExitingVPV = PhiR->getBackedgeValue();
97309730
auto *NewExitingVPV = PhiR->getBackedgeValue();
9731+
// Don't add selects here for partial reductions because the phi and partial
9732+
// reduction values have less vector elements than Cond. But, each operand
9733+
// in a select instruction needs to have the same number of vector elements,
9734+
// so the compiler would crash. Instead, a select, with the active lane
9735+
// mask, is applied to the inputs to the partial reduction.
97319736
if (!PhiR->isInLoop() && CM.foldTailByMasking() &&
97329737
!isa<VPPartialReductionRecipe>(OrigExitingVPV->getDefiningRecipe())) {
97339738
VPValue *Cond = RecipeBuilder.getBlockInMask(OrigLoop->getHeader());

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,13 +2131,8 @@ class VPPartialReductionRecipe : public VPSingleDefRecipe {
21312131
~VPPartialReductionRecipe() override = default;
21322132

21332133
VPPartialReductionRecipe *clone() override {
2134-
return getNumOperands() == 3
2135-
? new VPPartialReductionRecipe(Opcode, getOperand(0),
2136-
getOperand(1), getOperand(2),
2137-
getUnderlyingInstr())
2138-
: new VPPartialReductionRecipe(Opcode, getOperand(0),
2139-
getOperand(1), nullptr,
2140-
getUnderlyingInstr());
2134+
return new VPPartialReductionRecipe(Opcode, getOperand(0), getOperand(1),
2135+
getMask(), getUnderlyingInstr());
21412136
}
21422137

21432138
VPValue *getMask() const {

0 commit comments

Comments
 (0)