This is an archive of the discontinued LLVM Phabricator instance.

[NVPTX] Add a late SROA pass which allows optimizing away more allocas.
ClosedPublic

Authored by tra on Oct 8 2021, 4:26 PM.

Diff Detail

Event Timeline

tra created this revision.Oct 8 2021, 4:26 PM
tra requested review of this revision.Oct 8 2021, 4:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 8 2021, 4:26 PM
tra added a comment.Oct 8 2021, 4:27 PM

@asbirlea Is there anything else I need to do to make it work with the new PM?

While this may make sense, i would still like to see the actual reduced reproducer for the SROA failure.
Unless that new LICM run prevented inlining, i suspect it might be fixable in SROA itself.

tra added a comment.Oct 11 2021, 1:52 PM

While this may make sense, i would still like to see the actual reduced reproducer for the SROA failure.

@lebedev.ri Reproducer IR is here:
https://gist.github.com/Artem-B/c8d048ce7666f5693a8c899458829f5a

I've included the llvm-reduce test script in the comment there.

Unless that new LICM run prevented inlining, i suspect it might be fixable in SROA itself.

The problem is that one of the peeled-off parts of the loop made it impossible for SROA to figure out the fixed load offset. One of the later GVN passes simplified things enough to let the SROA pass figure out the offset of all the loads..

Specifically, here's the input to the failing SROS pass @ HEAD:
https://gist.github.com/Artem-B/a56797a9b918d4831a303ae2869dc83f

For comparison, here's what IR looked at the point where SROA was able to eliminate the alloca:
https://gist.github.com/Artem-B/0e8786afff6e6838b5cf5a9e21851b5c

tra updated this revision to Diff 379872.Oct 14 2021, 4:04 PM
tra edited the summary of this revision. (Show Details)

Added a test case.

Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2021, 4:04 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
tra updated this revision to Diff 380524.Oct 18 2021, 2:41 PM

Moved the test to LLVM.

asbirlea accepted this revision.Oct 18 2021, 2:43 PM

Thanks!

This revision is now accepted and ready to land.Oct 18 2021, 2:43 PM
tra updated this revision to Diff 380538.Oct 18 2021, 3:56 PM

The test uses llc only now. Opt is not affected by this patch.

asbirlea accepted this revision.Oct 18 2021, 4:43 PM