This is an archive of the discontinued LLVM Phabricator instance.

[NVPTX] Eliminate StoreRetval instructions with undef operand
ClosedPublic

Authored by kovdan01 on Feb 3 2022, 11:41 PM.

Details

Summary

Previously a lot of StoreRetval instructions with undef operand were generated
on NVPTX target when a big struct was returned by value. It resulted in a lot
of unneeded st.param.* instructions in final assembly. The patch solves the
issue by implementing the logic in NVPTX-specific part of DAG combiner.

Diff Detail

Event Timeline

kovdan01 created this revision.Feb 3 2022, 11:41 PM
kovdan01 requested review of this revision.Feb 3 2022, 11:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 3 2022, 11:41 PM
tra added a comment.Feb 4 2022, 10:41 AM

LGTM in principle, modulo tests as they need to actually check that we do not produce unwanted stores.

Also, the change is unlikely to affect the actual GPU code, only PTX, as ptxas is smart enough to eliminate undef stores: https://godbolt.org/z/fdb1hGdxW

llvm/test/CodeGen/NVPTX/store-retval.ll
33–38

This only verifies that the known values were stored, but the test would still pass on the current code which also stores the undef values.
You do need a handful of CHECK-NOT for st-param before/after the stores of valid values.

kovdan01 updated this revision to Diff 406912.Feb 8 2022, 11:51 AM

@tra Thanks for your review! Fixed tests.

Also, the change is unlikely to affect the actual GPU code, only PTX, as ptxas is smart enough to eliminate undef stores: https://godbolt.org/z/fdb1hGdxW

Hmm, it's an interesting notice, however, I suppose that enhancing PTX code also looks valuable.

llvm/test/CodeGen/NVPTX/store-retval.ll
33–38

Fixed, thanks!

tra accepted this revision.Feb 8 2022, 12:49 PM
This revision is now accepted and ready to land.Feb 8 2022, 12:49 PM
This revision was landed with ongoing or failed builds.Feb 10 2022, 12:40 AM
This revision was automatically updated to reflect the committed changes.