Skip to content

Commit 71ac823

Browse files
committed
Improve inloop reduction detection
1 parent ce446a8 commit 71ac823

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4853,18 +4853,18 @@ calculateRegisterUsage(VPlan &Plan, ArrayRef<ElementCount> VFs,
48534853
if (isa<VPVectorPointerRecipe, VPVectorEndPointerRecipe,
48544854
VPBranchOnMaskRecipe>(R))
48554855
continue;
4856-
/// In-loop reductions don't carry their output across iterations.
4857-
if (auto *Phi = dyn_cast<VPReductionPHIRecipe>(R);
4858-
Phi && Phi->isInLoop())
4859-
continue;
48604856

48614857
if (VFs[J].isScalar() ||
48624858
isa<VPCanonicalIVPHIRecipe, VPReplicateRecipe, VPDerivedIVRecipe,
48634859
VPScalarIVStepsRecipe>(R) ||
48644860
(isa<VPInstruction>(R) &&
4865-
all_of(cast<VPSingleDefRecipe>(R)->users(), [&](VPUser *U) {
4866-
return cast<VPRecipeBase>(U)->usesScalars(R->getVPSingleValue());
4867-
}))) {
4861+
all_of(cast<VPSingleDefRecipe>(R)->users(),
4862+
[&](VPUser *U) {
4863+
return cast<VPRecipeBase>(U)->usesScalars(
4864+
R->getVPSingleValue());
4865+
})) ||
4866+
(isa<VPReductionPHIRecipe>(R) &&
4867+
(cast<VPReductionPHIRecipe>(R))->isInLoop())) {
48684868
unsigned ClassID = TTI.getRegisterClassForType(
48694869
false, TypeInfo.inferScalarType(R->getVPSingleValue()));
48704870
// FIXME: The target might use more than one register for the type

0 commit comments

Comments
 (0)