This is an archive of the discontinued LLVM Phabricator instance.

[SPARC] Fix fp128 load/stores
ClosedPublic

Authored by LemonBoy on Jan 8 2021, 3:22 PM.

Details

Summary

The generated code for the split fp128 load/stores was missing a small yet important adjustment to the pointer metadata being fed into getStore and getLoad, making it out of sync with the effective memory address.
This problem often resulted in instructions being scheduled in the wrong order.

I also took this chance to clean up some "wrong" uses of getAlignment as done in D77687.

Thanks @jrtc27 for finding the problem and providing a patch.

Diff Detail

Event Timeline

LemonBoy created this revision.Jan 8 2021, 3:22 PM
LemonBoy requested review of this revision.Jan 8 2021, 3:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 8 2021, 3:22 PM
craig.topper added inline comments.
llvm/lib/Target/Sparc/SparcISelLowering.cpp
2735–2736

This dyn_cast is only checked by the assert below. The rest of the code just blindly dereferences it.

2787–2788

Same here

The test is not so solid (is it?), ideally we should check the MI to make sure the load ops have the correct offset but I have no idea of what kind of test does that.

jrtc27 added a comment.Jan 8 2021, 3:30 PM

The test is not so solid (is it?), ideally we should check the MI to make sure the load ops have the correct offset but I have no idea of what kind of test does that.

You want a MIR test I believe (though probably still needs IR input, SelectionDAG is a bit hard to target specific parts of).

The test is not so solid (is it?), ideally we should check the MI to make sure the load ops have the correct offset but I have no idea of what kind of test does that.

You can use "-stop-after=finalize-isel" and check the MIR output which should print the memory operands. I think maybe update_mir_test_checks.py can generate the check lines for MIR output from a .ll test.

jrtc27 added inline comments.Jan 8 2021, 3:35 PM
llvm/lib/Target/Sparc/SparcISelLowering.cpp
2735–2736

If you're looking for code quality don't look at the SPARC backend... it does suffer somewhat from being the first ever backend (and not having a lot of people care about it these days to clean it up).

LemonBoy updated this revision to Diff 315599.Jan 9 2021, 6:56 AM
LemonBoy edited reviewers, added: venkatra; removed: venkataramanan.kumar.llvm.
  • Add MIR test
  • Replace dyn_cast<> with cast<>
LemonBoy marked 3 inline comments as done.Jan 9 2021, 6:58 AM

You can use "-stop-after=finalize-isel" and check the MIR output which should print the memory operands. I think maybe update_mir_test_checks.py can generate the check lines for MIR output from a .ll test.

That's perfect, the test is much better now.

llvm/lib/Target/Sparc/SparcISelLowering.cpp
2735–2736

Turned that into a asserting cast<>.

This might need to be rebased after b1c304c4946506c0d00532829fb2f91276dde0c8 where I changed the printing of the memory operands in MIR

LemonBoy updated this revision to Diff 316510.Jan 13 2021, 2:00 PM

Rebased after changes in master, feel free to land the changes right away as I have no commit access (yet?).

This revision is now accepted and ready to land.Jan 13 2021, 2:25 PM
This revision was automatically updated to reflect the committed changes.