@@ -670,30 +670,6 @@ static void legalizeAndOptimizeInductions(VPlan &Plan) {
670670 if (!PhiR)
671671 continue ;
672672
673- // Try to narrow wide and replicating recipes to uniform recipes, based on
674- // VPlan analysis.
675- // TODO: Apply to all recipes in the future, to replace legacy uniformity
676- // analysis.
677- auto Users = collectUsersRecursively (PhiR);
678- for (VPUser *U : reverse (Users)) {
679- auto *Def = dyn_cast<VPSingleDefRecipe>(U);
680- auto *RepR = dyn_cast<VPReplicateRecipe>(U);
681- // Skip recipes that shouldn't be narrowed.
682- if (!Def || !isa<VPReplicateRecipe, VPWidenRecipe>(Def) ||
683- Def->getNumUsers () == 0 || !Def->getUnderlyingValue () ||
684- (RepR && (RepR->isSingleScalar () || RepR->isPredicated ())))
685- continue ;
686-
687- // Skip recipes that may have other lanes than their first used.
688- if (!vputils::isSingleScalar (Def) && !vputils::onlyFirstLaneUsed (Def))
689- continue ;
690-
691- auto *Clone = new VPReplicateRecipe (Def->getUnderlyingInstr (),
692- Def->operands (), /* IsUniform*/ true );
693- Clone->insertAfter (Def);
694- Def->replaceAllUsesWith (Clone);
695- }
696-
697673 // Replace wide pointer inductions which have only their scalars used by
698674 // PtrAdd(IndStart, ScalarIVSteps (0, Step)).
699675 if (auto *PtrIV = dyn_cast<VPWidenPointerInductionRecipe>(&Phi)) {
@@ -1419,7 +1395,9 @@ static void narrowToSingleScalarRecipes(VPlan &Plan) {
14191395 // Skip recipes that aren't single scalars or don't have only their
14201396 // scalar results used. In the latter case, we would introduce extra
14211397 // broadcasts.
1422- if (!vputils::isSingleScalar (RepOrWidenR) ||
1398+ if ((!vputils::isSingleScalar (RepOrWidenR) &&
1399+ !vputils::onlyFirstLaneUsed (RepOrWidenR)) ||
1400+ RepOrWidenR->getNumUsers () == 0 ||
14231401 !all_of (RepOrWidenR->users (), [RepOrWidenR](const VPUser *U) {
14241402 if (auto *Store = dyn_cast<VPWidenStoreRecipe>(U)) {
14251403 // VPWidenStore doesn't have users, and stores are always
0 commit comments