This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Fix codegen for VLD3/VLD4/VST3/VST4 with WB
ClosedPublic

Authored by thopre on Feb 6 2018, 8:15 AM.

Details

Summary

Code generation of VLD3, VLD4, VST3 and VST4 with register writeback is
broken due to 2 separate bugs:

  1. VLD1d64TPseudoWB_register and VLD1d64QPseudoWB_register are missing rules to expand them to non pseudo MIR. These are selected for ARMISD::VLD3_UPD/VLD4_UPD with v1i64 vectors in SelectVLD.
  1. Selection of the right VLD/VST instruction is broken for load and store of 3 and 4 v1i64 vectors. SelectVLD and SelectVST are called with MIR opcode for fixed writeback (ie increment is access size) and call getVLDSTRegisterUpdateOpcode() to select an opcode with register writeback if base register update is of a different size. Since getVLDSTRegisterUpdateOpcode() only knows about VLD1/VLD2/VST1/VST2 the call is currently conditional on the number of element in the vector.

    However, VLD1/VST1 is selected by SelectVLD/SelectVST's caller for load and stores of 3 or 4 v1i64 vectors. Therefore the opcode is not updated which later lead to a fixed writeback instruction being constructed with an extra operand for the register writeback.

This patch addresses the two issues as follows:

  • it adds the necessary mapping from VLD1d64TPseudoWB_register and VLD1d64QPseudoWB_register to VLD1d64Twb_register and VLD1d64Qwb_register respectively. Like for the existing _fixed variants, the cost of these is bumped for unaligned access.
  • it changes the logic in SelectVLD and SelectVSD to call isVLDfixed and isVSTfixed respectively to decide whether the opcode should be updated. It also reworks the logic and comments for pushing the writeback offset operand and r0 operand to clarify the logic: writeback offset needs to be pushed if it's a register writeback, r0 needs to be pushed if not and the instruction is a VLD1/VLD2/VST1/VST2.

Diff Detail

Repository
rL LLVM

Event Timeline

thopre created this revision.Feb 6 2018, 8:15 AM
srhines added a subscriber: srhines.Feb 6 2018, 5:52 PM
samparker added inline comments.
test/CodeGen/ARM/pr35157.ll
7

I can see that the bug originally caused a fault, but we should also be testing what code is generated.

thopre updated this revision to Diff 133406.Feb 8 2018, 5:45 AM

Extend existing vld3.ll/vld4.ll/vst3.ll/vst4.ll testcases instead of creating a new one, following similar patterns as those already in there incl. check directives.

thopre marked an inline comment as done.Feb 8 2018, 7:04 AM

https://reviews.llvm.org/D42967 is blocking this, but it would be great to get this into our next toolchain update.

samparker accepted this revision.Feb 23 2018, 12:26 AM

Thanks for the changes, LGTM.

This revision is now accepted and ready to land.Feb 23 2018, 12:26 AM
thopre updated this revision to Diff 135627.Feb 23 2018, 4:49 AM
thopre retitled this revision from [ARM] Fix PR35157: broken isel for VLD3/VLD4/VST3/VST4 with WB to [ARM] Fix codegen for VLD3/VLD4/VST3/VST4 with WB.
thopre edited the summary of this revision. (Show Details)
thopre set the repository for this revision to rL LLVM.

Merge patch with the one in https://reviews.llvm.org/D42967 and remove redundant mir test.

samparker accepted this revision.Feb 23 2018, 4:56 AM

LGTM, thanks.

thopre requested review of this revision.Feb 23 2018, 4:56 AM

https://reviews.llvm.org/D42967 has been merged into this patch. Can I get a review of the new diff? Thanks!

Is this waiting on anything else? It looks like the approval happened at the same time as your last message.

thopre added a comment.Mar 2 2018, 2:35 AM

Is this waiting on anything else? It looks like the approval happened at the same time as your last message.

Oh indeed, I thought the previous revision had been approved. I'll go ask for commit access and commit it asap.

This revision was not accepted when it landed; it landed in state Needs Review.Mar 2 2018, 5:05 AM
This revision was automatically updated to reflect the committed changes.

LGTM. Thanks for fixing this and thanks to samparker for reviewing and fhahn submitting it.