This is an archive of the discontinued LLVM Phabricator instance.

GVNSink: port some tests from MergedLoadStoreMotion
AbandonedPublic

Authored by artagnon on Jul 27 2023, 9:28 AM.

Details

Summary

GVNSink has not had much work put into it, ever since it was first
introduced six years ago, and is not turned on by default. While it is
similar to MergedLoadStoreMotion, a pass which is enabled by default, it
can operate on cases where mldst-motion fails. As an example of
GVNSink's capabilities, consider:

void BeamFormWeights(int a[20000], int beam) {
  for (int i = 0; i < 10000; ++i) {
    if (i == beam)
      a[2 * i] = 0;
    else
      a[2 * i] = 1;
  }
}

mldst-motion fails to sink the store in this case, because GVN's
operation rewrote the first GEP from 2 * i to 2 * beam, and the two GEPs
in the different branches fail to match up. Indeed, the only solution to
optimizing the above example is a GVN-aware sinking-pass, and GVNSink
promises to be that pass.

Unfortunately, since GVNSink has not seen much activity, its status is
unclear: it is unclear what the outstanding bugs are, and a quick
benchmark run with GVNSink turned on shows significant regressions.

This patch is a first step to better understand the status of GVNSink:
it ports two tests from mldst-motion which pass out-of-the-box. The
other tests from mldst-motion do not pass when ported over, and
follow-ups could involve fixing legitimate problems in GVNSink, and
adding corresponding tests.

Diff Detail

Event Timeline

artagnon created this revision.Jul 27 2023, 9:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 27 2023, 9:28 AM
Herald added a subscriber: StephenFan. · View Herald Transcript
artagnon requested review of this revision.Jul 27 2023, 9:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 27 2023, 9:28 AM
nikic added a comment.Jul 27 2023, 2:06 PM

Please use update_test_checks.py.

artagnon updated this revision to Diff 545098.Jul 28 2023, 4:25 AM

Address review comment; use update_test_checks.py.

nikic added inline comments.Jul 28 2023, 5:49 AM
llvm/test/Transforms/GVNSink/no-barrier-store.ll
33 ↗(On Diff #545098)

Contrary to the intent of the test, no actual sinking occurs here. (The previous hand-written check lines were broken and accepted the result either way. Prime example of why hand-written check lines are no longer allowed.)

artagnon added inline comments.Jul 28 2023, 6:44 AM
llvm/test/Transforms/GVNSink/no-barrier-store.ll
33 ↗(On Diff #545098)

Sorry for not spotting this. I'll remove this test.

artagnon updated this revision to Diff 545148.Jul 28 2023, 7:05 AM

Remove no-barrier-store.ll.

artagnon edited the summary of this revision. (Show Details)Jul 28 2023, 7:56 AM
artagnon abandoned this revision.Sep 22 2023, 4:58 AM