This is an archive of the discontinued LLVM Phabricator instance.

[LICM] Allow promotion with non-load/store users
ClosedPublic

Authored by nikic on Sep 8 2022, 5:31 AM.

Details

Summary

If there are non-load/store users of the promoted pointer, we currently abort promotion. However, having such users isn't really relevant to the transform. We already separately check that a) there are no instructions that modref the promoted pointer and b) that a pointer capture disables store promotion.

In the affected @test_captured_in_loop test case we have a readnone capture of the promoted pointer, which means that load promotion can be performed (while store promotion cannot).

Diff Detail

Event Timeline

nikic created this revision.Sep 8 2022, 5:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 8 2022, 5:31 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
nikic requested review of this revision.Sep 8 2022, 5:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 8 2022, 5:31 AM
stefanp accepted this revision.Sep 8 2022, 10:18 AM
stefanp added a subscriber: stefanp.

This is better than what I initially tried to do in D133426.
LGTM

This revision is now accepted and ready to land.Sep 8 2022, 10:18 AM
reames accepted this revision.Sep 8 2022, 1:31 PM

LGTM. Nice find!

llvm/lib/Transforms/Scalar/LICM.cpp
2096

If you're interested, we can be smarter here for some uses. e.g. a argument to a call marked experimental gives us deref facts. (Though that requires guaranteed to execute reasoning - which for some reason we don't use for loads?)

This revision was landed with ongoing or failed builds.Sep 9 2022, 4:10 AM
This revision was automatically updated to reflect the committed changes.