This is an archive of the discontinued LLVM Phabricator instance.

[MergeICmps] Allow sinking past non-load/store
ClosedPublic

Authored by nikic on Aug 22 2021, 9:21 AM.

Details

Summary

This is a followup to D106591. MergeICmps currently only allows sinking the loads past either instructions that don't write to memory at all, or simple loads/stores that don't modify the memory the loads access.

The "simple loads/stores" part of this check doesn't seem necessary to me -- AA isModRef() already accurately models any operation that may clobber the memory. For example, in the adjusted test case the transform is still fine if the call to @foo() isn't readonly, but inaccessiblememonly -- in both cases, the call cannot modify the loaded memory.

Diff Detail

Event Timeline

nikic created this revision.Aug 22 2021, 9:21 AM
nikic requested review of this revision.Aug 22 2021, 9:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2021, 9:21 AM
courbet accepted this revision.Aug 22 2021, 11:24 PM

Sounds reasonable.

I guess the only caveat that we can only reorder a load/store with non-volatile ones. Removing the check for simplicity of the sinked load/stores looks fine because we are checking that merged loads are simple (=> non-volatile) anyway, so we can indeed reorder the sinked loads with merged loads.

This revision is now accepted and ready to land.Aug 22 2021, 11:24 PM
This revision was automatically updated to reflect the committed changes.