[PATCH][arm] PR target/85026: Fix ldrsh length estimate in Thumb state

Kyrill Tkachov kyrylo.tkachov@foss.arm.com
Fri Mar 23 16:44:00 GMT 2018


Hi all,

This bug has been reported against GCC 7.3.0 but it is latent in all release branches and on trunk.
We underestimate the length of the LRSH instruction in Thumb state.
Unlike other load instructions LDRSH can be encoded in 16 bits only when using a register offset.
In the testcase we have "ldrsh   r2, [r4]" being assigned a length of 2, which is wrong.
So we don't calculate branch ranges properly and cause the assembler error.

The fix is to make the unaligned_loadhis insn similar to the *arm_extendqihi_insn insn that outputs an LDRSB.
Just remove the wrong 2-byte alternative. I don't think this is worth inventing a new "register-offset-only" constraint.
This also makes the patch safer for backporting.

Bootstrapped and tested on arm-none-linux-gnueabihf.

Committing to trunk and the branches after some soaking time.

Thanks,
Kyrill

2018-03-23  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     PR target/85026
     * config/arm/arm.md (unaligned_loadhis): Remove first alternative.
     Clean up attributes.

2018-03-23  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     PR target/85026
     * g++.dg/pr85026.C: New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: arm-ldrsh-len.patch
Type: text/x-patch
Size: 2372 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20180323/02df578b/attachment.bin>


More information about the Gcc-patches mailing list