This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add InstrInfo areMemAccessesTriviallyDisjoint hook
ClosedPublic

Authored by luismarques on Aug 31 2019, 3:49 PM.

Details

Summary

Introduces the InstrInfo::areMemAccessesTriviallyDisjoint hook.
The test could check for instruction reorderings, but to avoid being brittle it just checks instruction dependencies.

Diff Detail

Event Timeline

luismarques created this revision.Aug 31 2019, 3:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2019, 3:50 PM
luismarques edited the summary of this revision. (Show Details)

Added a test. Updated summary.

lenary added inline comments.Sep 9 2019, 10:24 AM
llvm/test/CodeGen/RISCV/disjoint.ll
27

This test seems really brittle.

Now that you've implemented the hook, the compiler can see that this load and store do not interact, so can now schedule the store after the load. However, what the hook actually means for these instructions is that the load and store don't interact, and so any more-specific schedule could undo this change by implementing a schedule that thinks if you do the store first, the code is faster.

I don't know how to write a test that's less brittle to this kind of issue. I suppose a lot of asm tests could be changed by a change in the schedule, but it seems like this one has a large chance of suddenly not testing anything.

Do you have any better ideas for how to test this, or do we not have enough testcases that hit the hook and are trivially disjoint?

lenary accepted this revision.Oct 7 2019, 8:22 AM

I have decided I'm not too worried by the brittle test.

This revision is now accepted and ready to land.Oct 7 2019, 8:22 AM
luismarques edited the summary of this revision. (Show Details)

Rebased the test on master.
Changed the test to instead check the instruction dependencies directly.
Updated summary.

luismarques requested review of this revision.Oct 7 2019, 3:27 PM
luismarques marked an inline comment as done.

Changed the test. Please review again. Thank you!

NFC. Appease clang-format, even though it was a copy-pasted declaration.

Fix RUN lines and add REQUIRES: asserts.

lenary added inline comments.Oct 8 2019, 7:16 AM
llvm/test/CodeGen/RISCV/disjoint.ll
7

Please can you write a few sentences explaining how this tests that these two SW's are disjoint?

I presume it's to do with the fact that the scheduler does not deem the SW %1:gpr, %0:gpr, 8 to have to come after the first SW (it not being in the successors list).

Knowing how this tests the disjoint hook will help us understand how to update the test if the exact output ever changes.

lenary accepted this revision.Oct 28 2019, 7:08 AM

LGTM. When you land it, do add a comment about how the disjoint.ll test works.

This revision is now accepted and ready to land.Oct 28 2019, 7:08 AM

Rebased on master. Add test comments.

luismarques marked 2 inline comments as done.Nov 4 2019, 12:25 PM
luismarques added inline comments.
llvm/test/CodeGen/RISCV/disjoint.ll
27

You're right, this merited some context and explanation. Thanks!

This revision was automatically updated to reflect the committed changes.