Skip to content

Commit ff432c9

Browse files
committed
Use one block for scaling factor consideration
1 parent f05ebee commit ff432c9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5030,11 +5030,15 @@ calculateRegisterUsage(VPlan &Plan, ArrayRef<ElementCount> VFs,
50305030
// The output from scaled phis and scaled reductions actually have
50315031
// fewer lanes than the VF.
50325032
ElementCount VF = VFs[J];
5033-
if (auto *ReductionR = dyn_cast<VPReductionPHIRecipe>(R))
5034-
VF = VF.divideCoefficientBy(ReductionR->getVFScaleFactor());
5035-
else if (auto *PartialReductionR =
5036-
dyn_cast<VPPartialReductionRecipe>(R))
5037-
VF = VF.divideCoefficientBy(PartialReductionR->getVFScaleFactor());
5033+
if (isa<VPPartialReductionRecipe, VPReductionPHIRecipe>(R)) {
5034+
auto *ReductionR = dyn_cast<VPReductionPHIRecipe>(R);
5035+
auto *PartialReductionR =
5036+
ReductionR ? nullptr : dyn_cast<VPPartialReductionRecipe>(R);
5037+
unsigned ScaleFactor = ReductionR
5038+
? ReductionR->getVFScaleFactor()
5039+
: PartialReductionR->getVFScaleFactor();
5040+
VF = VF.divideCoefficientBy(ScaleFactor);
5041+
}
50385042
LLVM_DEBUG(if (VF != VFs[J]) {
50395043
dbgs() << "LV(REG): Scaled down VF from " << VFs[J] << " to " << VF
50405044
<< " for ";

0 commit comments

Comments
 (0)