This is an archive of the discontinued LLVM Phabricator instance.

[DAG] Fix Memory ordering check in ReduceLoadOpStore.
ClosedPublic

Authored by niravd on Jul 16 2018, 10:32 AM.

Details

Summary

When merging through a TokenFactor we need to check that the load may
be ordered such that no other aliasing memory operations may
happen. It is not sufficient to just check that the load is a member
of the chain token factor; we must check it is not an indirect check.

This fixes PR37826.

Diff Detail

Event Timeline

niravd created this revision.Jul 16 2018, 10:32 AM

Thanks!
Adding potential reviewers (I still don't have a good understanding). Bug link:
https://bugs.llvm.org/show_bug.cgi?id=37826

It would be better to remove the main() code in the test file, auto-generate the full output showing the buggy memop sequence, and commit that against trunk. Then, when you regenerate the results after this patch, we'll see that the load and stores have changed.

efriedma added inline comments.Jul 16 2018, 2:06 PM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
13103

Instead of doing this predecessor check, could we just check that the load's chain has one use? I guess that misses some cases that could be transformed, but I'd like to avoid these expensive walks as much as possible.

niravd updated this revision to Diff 156121.Jul 18 2018, 11:44 AM

Remove the expensive check in favor of more conservative check that LD's chain has one use.

This revision is now accepted and ready to land.Jul 18 2018, 12:06 PM
This revision was automatically updated to reflect the committed changes.