Skip to content

Commit ab43958

Browse files
committed
!fixup address latest comments, thanks
1 parent cbaaeb8 commit ab43958

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8289,7 +8289,6 @@ VPRecipeBase *VPRecipeBuilder::tryToCreateWidenRecipe(VPSingleDefRecipe *R,
82898289
// If the PHI is used by a partial reduction, set the scale factor.
82908290
unsigned ScaleFactor =
82918291
getScalingForReduction(RdxDesc.getLoopExitInstr()).value_or(1);
8292-
82938292
PhiRecipe = new VPReductionPHIRecipe(
82948293
Phi, RdxDesc, *StartV, CM.isInLoopReduction(Phi),
82958294
CM.useOrderedReductions(RdxDesc), ScaleFactor);
@@ -9328,11 +9327,11 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
93289327
RecipeBuilder.getScalingForReduction(RdxDesc.getLoopExitInstr())
93299328
.value_or(1);
93309329
Type *I32Ty = IntegerType::getInt32Ty(PhiTy->getContext());
9331-
auto *ScalarFactorVPV =
9330+
auto *ScaleFactorVPV =
93329331
Plan->getOrAddLiveIn(ConstantInt::get(I32Ty, ScaleFactor));
93339332
VPValue *StartV = PHBuilder.createNaryOp(
93349333
VPInstruction::ReductionStartVector,
9335-
{PhiR->getStartValue(), Iden, ScalarFactorVPV},
9334+
{PhiR->getStartValue(), Iden, ScaleFactorVPV},
93369335
PhiTy->isFloatingPointTy() ? RdxDesc.getFastMathFlags()
93379336
: FastMathFlags());
93389337
PhiR->setOperand(0, StartV);

llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,10 @@ static unsigned getVFScaleFactor(VPRecipeBase *R) {
397397
return RR->getVFScaleFactor();
398398
if (auto *RR = dyn_cast<VPPartialReductionRecipe>(R))
399399
return RR->getVFScaleFactor();
400+
if (auto *VPI = dyn_cast<VPInstruction>(R))
401+
assert(
402+
VPI->getOpcode() != VPInstruction::ReductionStartVector &&
403+
"getting scaling factor of reduction-start-vector not implemented yet");
400404
return 1;
401405
}
402406

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,9 +1157,9 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
11571157
VPValue *StartV;
11581158
if (match(Def, m_VPInstruction<VPInstruction::ReductionStartVector>(
11591159
m_VPValue(StartV), m_VPValue(), m_VPValue()))) {
1160-
Def->replaceUsesWithIf(StartV, [Def](const VPUser &U, unsigned Idx) {
1160+
Def->replaceUsesWithIf(StartV, [](const VPUser &U, unsigned Idx) {
11611161
auto *PhiR = dyn_cast<VPReductionPHIRecipe>(&U);
1162-
return PhiR && Def == PhiR->getOperand(Idx) && PhiR->isInLoop();
1162+
return PhiR && PhiR->isInLoop();
11631163
});
11641164
return;
11651165
}

llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,16 @@ void UnrollState::unrollHeaderPHIByUF(VPHeaderPHIRecipe *R,
227227
// (second operand) for unrolled parts. If the scaling factor is > 1,
228228
// create a new ReductionStartVector with the scale factor and both
229229
// operands set to the identity value.
230+
230231
if (auto *VPI = dyn_cast<VPInstruction>(RdxPhi->getStartValue())) {
231232
if (cast<ConstantInt>(VPI->getOperand(2)->getLiveInIRValue())
232-
->getZExtValue() == 1)
233+
->getZExtValue() == 1) {
233234
Copy->setOperand(0, VPI->getOperand(1));
234-
else {
235-
if (Part == 1) {
236-
auto *C = VPI->clone();
237-
C->setOperand(0, C->getOperand(1));
238-
C->insertAfter(VPI);
239-
addUniformForAllParts(C);
240-
}
235+
} else if (Part == 1) {
236+
auto *C = VPI->clone();
237+
C->setOperand(0, C->getOperand(1));
238+
C->insertAfter(VPI);
239+
addUniformForAllParts(C);
241240
}
242241
}
243242
Copy->addOperand(getConstantVPV(Part));

0 commit comments

Comments
 (0)