@@ -517,10 +517,7 @@ static void removeRedundantCanonicalIVs(VPlan &Plan) {
517
517
// everything WidenNewIV's users need. That is, WidenOriginalIV will
518
518
// generate a vector phi or all users of WidenNewIV demand the first lane
519
519
// only.
520
- if (any_of (WidenOriginalIV->users (),
521
- [WidenOriginalIV](VPUser *U) {
522
- return !U->usesScalars (WidenOriginalIV);
523
- }) ||
520
+ if (!vputils::onlyScalarValuesUsed (WidenOriginalIV) ||
524
521
vputils::onlyFirstLaneUsed (WidenNewIV)) {
525
522
WidenNewIV->replaceAllUsesWith (WidenOriginalIV);
526
523
WidenNewIV->eraseFromParent ();
@@ -1263,9 +1260,7 @@ static void narrowToSingleScalarRecipes(VPlan &Plan) {
1263
1260
// scalar results used. In the latter case, we would introduce extra
1264
1261
// broadcasts.
1265
1262
if (!vputils::isSingleScalar (RepOrWidenR) ||
1266
- any_of (RepOrWidenR->users (), [RepOrWidenR](VPUser *U) {
1267
- return !U->usesScalars (RepOrWidenR);
1268
- }))
1263
+ !vputils::onlyScalarValuesUsed (RepOrWidenR))
1269
1264
continue ;
1270
1265
1271
1266
auto *Clone = new VPReplicateRecipe (RepOrWidenR->getUnderlyingInstr (),
@@ -3216,8 +3211,7 @@ void VPlanTransforms::materializeBroadcasts(VPlan &Plan) {
3216
3211
3217
3212
auto *VectorPreheader = Plan.getVectorPreheader ();
3218
3213
for (VPValue *VPV : VPValues) {
3219
- if (all_of (VPV->users (),
3220
- [VPV](VPUser *U) { return U->usesScalars (VPV); }) ||
3214
+ if (vputils::onlyScalarValuesUsed (VPV) ||
3221
3215
(VPV->isLiveIn () && VPV->getLiveInIRValue () &&
3222
3216
isa<Constant>(VPV->getLiveInIRValue ())))
3223
3217
continue ;
@@ -3373,7 +3367,7 @@ void VPlanTransforms::materializeVFAndVFxUF(VPlan &Plan, VPBasicBlock *VectorPH,
3373
3367
// For users of the runtime VF, compute it as VF * vscale, and VFxUF as (VF *
3374
3368
// vscale) * UF.
3375
3369
VPValue *RuntimeVF = Builder.createElementCount (TCTy, VFEC);
3376
- if (any_of (VF. users (), [&VF](VPUser *U) { return !U-> usesScalars (&VF); } )) {
3370
+ if (! vputils::onlyScalarValuesUsed (&VF)) {
3377
3371
VPValue *BC = Builder.createNaryOp (VPInstruction::Broadcast, RuntimeVF);
3378
3372
VF.replaceUsesWithIf (
3379
3373
BC, [&VF](VPUser &U, unsigned ) { return !U.usesScalars (&VF); });
0 commit comments