This is an archive of the discontinued LLVM Phabricator instance.

[VPlan] Check VPValue step in isCanonical (NFCI).
ClosedPublic

Authored by fhahn on Apr 9 2023, 12:48 PM.

Details

Summary

Update the isCanonical() implementations to check the VPValue step
operand instead of the step in the induction descriptor.

At the moment this is NFC, but it enables further optimizations if the
step is replaced by a constant in D147783.

Diff Detail

Event Timeline

fhahn created this revision.Apr 9 2023, 12:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 9 2023, 12:49 PM
fhahn requested review of this revision.Apr 9 2023, 12:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 9 2023, 12:49 PM
Ayal added inline comments.Apr 12 2023, 4:07 PM
llvm/lib/Transforms/Vectorize/VPlan.h
1848

Worth also passing in Start?
Documentation should be updated.

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
739

Deserves a comment? (Step of an induction should be loop invariant, but could be defined by a recipe in loop preheader, or an invariant that was not LICM'd out? In any case, this method checks only if step is 1, i.e., live-in.)

fhahn updated this revision to Diff 513909.Apr 15 2023, 8:04 AM

Address latest comments, thanks!

fhahn marked 2 inline comments as done.Apr 15 2023, 8:05 AM
fhahn added inline comments.
llvm/lib/Transforms/Vectorize/VPlan.h
1848

Updated to pass both InductionKind & Start instead of whole induction desciptor. Comment updated accordingly, thanks!

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
739

Added a comment, thanks!

fhahn updated this revision to Diff 513910.Apr 15 2023, 8:06 AM
fhahn marked 2 inline comments as done.

clang-format

Ayal accepted this revision.Apr 15 2023, 1:24 PM

Looks good to me, thanks! With some minor nits.

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
741

typo:

741
744

nit: setting StartC right after StepC here, instead of above, will (a) early-exit earlier, and (b) highlight how the two are set similarly. Except that Start must be a live-in.

May be worth having an API that gets the LiveInIRValue if one exists and returns null otherwise, which could then be used by dyn_cast_or_null.

1100

The start value is no longer "of ID". Comment worth dropping?

1102

nit: to be consistent with first check of Ty above:

1102
1110

ID is no longer present, update comment?

1112–1113

nit: check of Kind can (be the first to) early-exit.

This revision is now accepted and ready to land.Apr 15 2023, 1:24 PM
This revision was landed with ongoing or failed builds.Apr 16 2023, 6:48 AM
This revision was automatically updated to reflect the committed changes.
fhahn marked 8 inline comments as done.
fhahn added inline comments.Apr 16 2023, 6:50 AM
llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
741

Thanks, adjusted

744

May be worth having an API that gets the LiveInIRValue if one exists and returns null otherwise, which could then be used by dyn_cast_or_null.

Sounds good, I can see about adding one.

1100

Update comment, thanks!

1102

Adjusted, thanks!

1110

Updated, thanks!

1112–1113

Moved, thanks!