This is an archive of the discontinued LLVM Phabricator instance.

[VPlan] Only generate single instr for loads uniform across all parts.
ClosedPublic

Authored by fhahn on Aug 31 2022, 7:08 AM.

Details

Summary

VPReplicateRecipe::isUniform actually means uniform-per-parts, hence a
scalar instruction is generated per-part.

This is a potential alternative D132892. For now the current patch only
catches cases where the address is trivially invariant (defined outside
VPlan), while D132892 catches any address that is considered invariant
by SCEV AFAICT.

It should be possible to hoist fully invariant recipes feeding loads out
of the vector loop region as well, but in practice LICM should do that
already.

This version of the patch artificially limits this to loads to make it
easier to compare, but this restriction should be easily liftable.

Diff Detail

Event Timeline

fhahn created this revision.Aug 31 2022, 7:08 AM
fhahn requested review of this revision.Aug 31 2022, 7:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2022, 7:08 AM
reames accepted this revision.Aug 31 2022, 1:10 PM

LGTM w/changes applied.

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
9612

A load can't be of void type.

9616

Please use early turn instead of else clause.

This revision is now accepted and ready to land.Aug 31 2022, 1:10 PM
reames added a comment.Sep 7 2022, 8:44 AM

@fhahn reverse ping, anything preventing this from being landed?

This revision was landed with ongoing or failed builds.Sep 8 2022, 6:28 AM
This revision was automatically updated to reflect the committed changes.
fhahn marked 2 inline comments as done.
fhahn added inline comments.Sep 8 2022, 6:28 AM
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
9612

Done in the committed version, thanks! I'll submit a follow-up to extend this to instructions other than loads.

9616

Done in the committed version, thanks!