https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85026

--- Comment #5 from ktkachov at gcc dot gnu.org ---
Author: ktkachov
Date: Fri Mar 23 16:43:43 2018
New Revision: 258818

URL: https://gcc.gnu.org/viewcvs?rev=258818&root=gcc&view=rev
Log:
[arm] PR target/85026: Fix ldrsh length estimate in Thumb state

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.

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

        * g++.dg/pr85026.C: New test.


Added:
    trunk/gcc/testsuite/g++.dg/pr85026.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/arm/arm.md
    trunk/gcc/testsuite/ChangeLog

Reply via email to