Skip to content

Commit a8dda3f

Browse files
committed
!fixup address latest comments.
1 parent df295ec commit a8dda3f

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,37 +1087,37 @@ void VPlanTransforms::simplifyRecipes(VPlan &Plan, Type &CanonicalIVTy) {
10871087
}
10881088

10891089
static void convertToUniformRecipes(VPlan &Plan) {
1090-
auto TryToNarrow = [](VPBasicBlock *VPBB) {
1090+
if (Plan.hasScalarVFOnly())
1091+
return;
1092+
1093+
for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
1094+
vp_depth_first_shallow(Plan.getVectorLoopRegion()->getEntry()))) {
10911095
for (VPRecipeBase &R : make_early_inc_range(reverse(*VPBB))) {
10921096
// Try to narrow wide and replicating recipes to uniform recipes, based on
10931097
// VPlan analysis.
1094-
auto *Def = dyn_cast<VPSingleDefRecipe>(&R);
1095-
if (!Def || !isa<VPReplicateRecipe, VPWidenRecipe>(Def) ||
1096-
!Def->getUnderlyingValue())
1097-
continue;
1098-
10991098
auto *RepR = dyn_cast<VPReplicateRecipe>(&R);
1099+
if (!RepR && !isa<VPWidenRecipe>(&R))
1100+
continue;
11001101
if (RepR && RepR->isUniform())
11011102
continue;
11021103

1104+
auto *RepOrWiden = cast<VPSingleDefRecipe>(&R);
11031105
// Skip recipes that aren't uniform and don't have only their scalar
11041106
// results used. In the later case, we would introduce extra broadcasts.
1105-
if (!vputils::isUniformAfterVectorization(Def) ||
1106-
any_of(Def->users(),
1107-
[Def](VPUser *U) { return !U->usesScalars(Def); }))
1107+
if (!vputils::isUniformAfterVectorization(RepOrWiden) ||
1108+
any_of(RepOrWiden->users(), [RepOrWiden](VPUser *U) {
1109+
return !U->usesScalars(RepOrWiden);
1110+
}))
11081111
continue;
11091112

1110-
auto *Clone = new VPReplicateRecipe(Def->getUnderlyingInstr(),
1111-
Def->operands(), /*IsUniform*/ true);
1112-
Clone->insertBefore(Def);
1113-
Def->replaceAllUsesWith(Clone);
1114-
Def->eraseFromParent();
1113+
auto *Clone =
1114+
new VPReplicateRecipe(RepOrWiden->getUnderlyingInstr(),
1115+
RepOrWiden->operands(), /*IsUniform*/ true);
1116+
Clone->insertBefore(RepOrWiden);
1117+
RepOrWiden->replaceAllUsesWith(Clone);
1118+
RepOrWiden->eraseFromParent();
11151119
}
1116-
};
1117-
1118-
for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
1119-
vp_depth_first_shallow(Plan.getVectorLoopRegion()->getEntry())))
1120-
TryToNarrow(VPBB);
1120+
}
11211121
}
11221122

11231123
/// Normalize and simplify VPBlendRecipes. Should be run after simplifyRecipes

0 commit comments

Comments
 (0)