[ARM][PR gas/19217] Fix wrong use of MOVT to replace LDR

Ramana Radhakrishnan ramana.gcc@googlemail.com
Thu Nov 12 10:28:00 GMT 2015

On Thu, Nov 12, 2015 at 10:03 AM, Matthew Wahab
<matthew.wahab@foss.arm.com> wrote:
> Hello,
> PR gas/18499 implemented an optimization in which a load-immediate (LDR
> _, =<imm>) was replaced by a MOVW if the bottom half of <imm> was
> non-zero or by a MOVT if the top half was non-zero
> This optimization is wrong because, unlike the LDR, the MOVT leaves
> the bottom half of the destination register unchanged. The
> implementation also doesn't deal with the case when the immediate is
> non-zero in both halves. In that case, the LDR would have to be replaced
> with a MOVW+MOVT sequence.

> The use of MOVT appears to be the cause of PR gas/19217. This patch
> fixes that miscompilation by dropping the use of MOVT, so that the LDR _,
> =<imm> will only be replaced by MOVW and only if the upper half of <imm>
> is zero. It also removes a redundant feature check and fixes some
> formatting in the code.
> Tested arm-none-linux-gnueabihf with cross-compiled check-binutils and
> check-gas.
> Ok for trunk?



> Matthew
> gas/
> 2015-11-11  Matthew Wahab  <matthew.wahab@arm.com>
>         * config/tc-arm.c (move_or_literal_pool): Remove redundant feature
>         check.  Fix some code formatting.  Drop use of MOVT.  Add some
>         comments.
> gas/testsuite/
> 2015-11-11  Matthew Wahab  <matthew.wahab@arm.com>
>         * gas/arm/thumb2_ldr_immediate_armv6t2.d: Update expected output.

More information about the Binutils mailing list