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

Matthew Wahab matthew.wahab@foss.arm.com
Thu Nov 12 10:03:00 GMT 2015


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ARM-PR-gas-19217-Fix-incorrect-use-of-MOVT-to-replac.patch
Type: text/x-patch
Size: 3396 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20151112/00b1552d/attachment.bin>


More information about the Binutils mailing list