This is an archive of the discontinued LLVM Phabricator instance.

[LV] Consider ExtractValue as uniform.
ClosedPublic

Authored by sdesmalen on Aug 2 2021, 9:22 AM.

Details

Summary

Since all operands to ExtractValue must be loop-invariant when we deem
the loop vectorizable, we can consider ExtractValue to be uniform.

Diff Detail

Event Timeline

sdesmalen created this revision.Aug 2 2021, 9:22 AM
sdesmalen requested review of this revision.Aug 2 2021, 9:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 2 2021, 9:22 AM
dmgreen added inline comments.Aug 3 2021, 1:00 AM
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
4963

This doesn't appear to be used.

david-arm added inline comments.Aug 3 2021, 1:07 AM
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
4966

I think we can probably hoist this out of the for loop and just create it once.

llvm/test/Transforms/LoopVectorize/AArch64/extractvalue-no-scalarization-required.ll
4

Could you add at least one test for an interleave > 1 either here or in the SVE test, just to prove we've got the parts right?

sdesmalen updated this revision to Diff 363691.Aug 3 2021, 4:36 AM
  • Removed unused variable.
  • Hoisted ExtractValue and Splat out of the loop.
  • Updated test.
sdesmalen marked 2 inline comments as done.Aug 3 2021, 4:37 AM
sdesmalen added inline comments.
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
4963

I somehow didn't notice that before posting the patch. Thanks for pointing out!

4966

Good point, I've made the change.

Matt added a subscriber: Matt.Aug 3 2021, 7:02 AM
fhahn added a comment.Aug 4 2021, 1:13 AM

since it's operands must always be scalar or loop-invariant.

At the moment, it must always be loop-invariant, right? Because instructions with struct-typed return values are not supported. Can't we just mark it as uniform?

sdesmalen updated this revision to Diff 364017.Aug 4 2021, 2:46 AM
sdesmalen marked 2 inline comments as done.
sdesmalen retitled this revision from [LV] Widen ExtractValue instructions instead of scalarizing. to [LV] Consider ExtractValue as uniform..
sdesmalen edited the summary of this revision. (Show Details)

Mark ExtractValue as uniform.

since it's operands must always be scalar or loop-invariant.

At the moment, it must always be loop-invariant, right? Because instructions with struct-typed return values are not supported. Can't we just mark it as uniform?

That's a good point, that works indeed.

david-arm added inline comments.Aug 4 2021, 2:52 AM
llvm/test/Transforms/LoopVectorize/AArch64/extractvalue-no-scalarization-required.ll
16

Is it worth also adding a CHECK for the debug output showing extractvalue as a uniform instruction?

sdesmalen updated this revision to Diff 364020.Aug 4 2021, 2:57 AM

Added check for debug-output showing extractvalue as uniform.

sdesmalen marked an inline comment as done.Aug 4 2021, 2:57 AM
david-arm accepted this revision.Aug 4 2021, 4:22 AM

LGTM!

This revision is now accepted and ready to land.Aug 4 2021, 4:22 AM
fhahn accepted this revision.Aug 5 2021, 7:27 AM

LGTM, thanks

Cheers for the review comments!

This revision was automatically updated to reflect the committed changes.