This is an archive of the discontinued LLVM Phabricator instance.

[LV] Check if value was already not uniform for previous VF.
ClosedPublic

Authored by fhahn on May 29 2023, 12:38 PM.

Details

Summary

If the value was already known to not be uniform for the previous
(smaller VF), it cannot be uniform for the larger VF.

This slightly reduces compile-time, once uniformity checks are becoming
a bit more expensive due to using SCEV rewriting (D148841).

Diff Detail

Event Timeline

fhahn created this revision.May 29 2023, 12:38 PM
fhahn requested review of this revision.May 29 2023, 12:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 29 2023, 12:38 PM
Ayal added inline comments.May 29 2023, 2:32 PM
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
4684

This looks right.
Also holds for non-MemOpUse?
Furthermore, if value is uniform for PrevVF, suffice to only check if SCEVs of lanes 0 and VF-1 are equal.

fhahn marked an inline comment as done.May 30 2023, 3:29 AM
fhahn added inline comments.
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
4684

Also holds for non-MemOpUse?

Yes, but the loop that uses isUniformMemOpUse also collects pointers where only lane 0 is demanded (for widened memory ops), so checking in the loop directly isn't possible without first dis-entangling this logic.

Furthermore, if value is uniform for PrevVF, suffice to only check if SCEVs of lanes 0 and VF-1 are equal.

Hmm, I think we would have to check if lane 0 matches the lanes PrevVF..VF-1? Might be good as follow-up, as it will require adjusting the API a bit I think to provide the additional info.

Ayal added inline comments.May 30 2023, 4:37 AM
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
4684

Also holds for non-MemOpUse?

Yes, but the loop that uses isUniformMemOpUse also collects pointers where only lane 0 is demanded (for widened memory ops), so checking in the loop directly isn't possible without first dis-entangling this logic.

Agreed, uniformness should be disentangled from first-lane-used-ness.

Furthermore, if value is uniform for PrevVF, suffice to only check if SCEVs of lanes 0 and VF-1 are equal.

Hmm, I think we would have to check if lane 0 matches the lanes PrevVF..VF-1? Might be good as follow-up, as it will require adjusting the API a bit I think to provide the additional info.

Stitching piecewise uniformity - if a value is uniform across PrevVF then its SCEVs for lanes {0,1,..,PrevVF-1} are equal to each other, and so are those of lanes/offsets {PrevVF,PrevVF+1...,VF-1}, right? If so then suffice the select and compare one sample from each for the value to be uniform across VF.

In any case these can be dealt with in separate follow-up patches.

fhahn updated this revision to Diff 528196.Jun 4 2023, 2:51 AM
fhahn marked 2 inline comments as done.

Rebase so this can be applied on current main.

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

Sounds good, so should this initial patch go in as is for now?

Ayal accepted this revision.Jun 4 2023, 7:41 AM
Ayal added inline comments.
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
4684

Sure, just noting more room for improving how we go about analyzing uniformity/divergence.

This revision is now accepted and ready to land.Jun 4 2023, 7:41 AM