This is an archive of the discontinued LLVM Phabricator instance.

[ARM] LSL #0 is an alias of MOV
ClosedPublic

Authored by john.brawn on Feb 23 2017, 3:56 AM.

Details

Summary

Currently we handle this correctly in arm, but in thumb we don't which leads to an unpredictable instruction being emitted for LSL #0 in an IT block and SP not being permitted in some cases when it should be.

For the thumb2 LSL we can handle this by making LSL #0 an alias of MOV in the .td file, but for thumb1 we need to handle it in checkTargetMatchPredicate to get the IT handling right. We also need to adjust the handling of MOV rd, rn, LSL #0 to avoid generating the 16-bit encoding in an IT block. We should also adjust it to allow SP in the same way that it is allowed in MOV rd, rn, but I haven't done that here because it looks like it would take quite a lot of work to get right.

Additionally correct the selection of the 16-bit shift instructions in processInstruction, where it was checking if the two registers were equal when it should have been checking if they were low. It appears that previously this code was never executed and the 16-bit encoding was selected by default, but the other changes I've done here have somehow made it start being used.

Diff Detail

Repository
rL LLVM

Event Timeline

john.brawn created this revision.Feb 23 2017, 3:56 AM
rengolin accepted this revision.Feb 27 2017, 5:48 AM

LGTM, thanks!

This revision is now accepted and ready to land.Feb 27 2017, 5:48 AM
This revision was automatically updated to reflect the committed changes.