From: Nick Clifton Date: Thu, 2 May 2002 09:11:14 +0000 (+0000) Subject: Do not convert a subtract of zero into an add of zero. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=358b94bdb1b02dbc21a19719fbaa9fbe9c93c61a;p=binutils-gdb.git Do not convert a subtract of zero into an add of zero. --- diff --git a/gas/ChangeLog b/gas/ChangeLog index 76b97adf60d..6244a875175 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,8 @@ +2002-05-02 Nick Clifton + + * config/tc-arm.c (thumb_add_sub): Do not convert a subtract of + zero into an add of zero - it is not the same. + 2002-05-01 Arati Dikey * tc-sh.c (get_specific): Generate warning if the same diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index 162553f6436..1370f13e5ae 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -7433,11 +7433,11 @@ thumb_add_sub (str, subtract) int offset = inst.reloc.exp.X_add_number; if (subtract) - offset = -offset; + offset = - offset; if (offset < 0) { - offset = -offset; + offset = - offset; subtract = 1; /* Quick check, in case offset is MIN_INT. */ @@ -7447,7 +7447,9 @@ thumb_add_sub (str, subtract) return; } } - else + /* Note - you cannot convert a subtract of 0 into an + add of 0 because the carry flag is set differently. */ + else if (offset > 0) subtract = 0; if (Rd == REG_SP) diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index 428b6a20457..6e552b7e11f 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2002-05-02 Nick Clifton + + * gas/arm/arm7t.s: Add thumb mode "sub r?, #0" and "add r?, #0". + * gas/arm/arm7t.d: Add expected results. (Make sure that the + subtract is not converted into an add). + 2002-04-23 H.J. Lu * gas/mips/elempic.d: Use empic.l. diff --git a/gas/testsuite/gas/arm/arm7t.d b/gas/testsuite/gas/arm/arm7t.d index dc4993a0b52..87b388f5e63 100644 --- a/gas/testsuite/gas/arm/arm7t.d +++ b/gas/testsuite/gas/arm/arm7t.d @@ -66,3 +66,5 @@ Disassembly of section .text: [ ]*dc:.*fred 0+e0 <[^>]*> 0000c0de ? .* 0+e4 <[^>]*> 0000dead ? .* +0+e8 <[^>]*> 3800 sub r0, #0 +0+ea <[^>]*> 3000 add r0, #0 diff --git a/gas/testsuite/gas/arm/arm7t.s b/gas/testsuite/gas/arm/arm7t.s index d155752eedd..f3251117d18 100644 --- a/gas/testsuite/gas/arm/arm7t.s +++ b/gas/testsuite/gas/arm/arm7t.s @@ -72,3 +72,11 @@ misc: .align .L2: .word fred + + .ltorg + .thumb + .global thumb_tests + .thumb_func +thumb_tests: + sub r0, #0 + add r0, #0