[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Thumb: Do not convert "sub r?, #0" into "add r?, #0"
From: |
Nick Clifton |
Subject: |
Thumb: Do not convert "sub r?, #0" into "add r?, #0" |
Date: |
02 May 2002 10:10:00 +0100 |
Hi Guys,
I am applying the patch below to fix a small bug in the ARM
assembler: In thumb mode it would convert a subtract of zero into
an add of zero. This does not work because the semantics for the
setting of the Carry flag are different. The patch also includes a
test case to make sure that this bug does not recur.
Cheers
Nick
2002-05-02 Nick Clifton <address@hidden>
* 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-02 Nick Clifton <address@hidden>
* 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).
Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.117
diff -c -3 -p -w -r1.117 tc-arm.c
*** gas/config/tc-arm.c 21 Mar 2002 09:13:34 -0000 1.117
--- gas/config/tc-arm.c 2 May 2002 09:05:31 -0000
*************** thumb_add_sub (str, subtract)
*** 7447,7453 ****
return;
}
}
! else
subtract = 0;
if (Rd == REG_SP)
--- 7447,7455 ----
return;
}
}
! /* 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)
Index: gas/testsuite/gas/arm/arm7t.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/arm/arm7t.s,v
retrieving revision 1.3
diff -c -3 -p -w -r1.3 arm7t.s
*** gas/testsuite/gas/arm/arm7t.s 1 Nov 1999 17:10:27 -0000 1.3
--- gas/testsuite/gas/arm/arm7t.s 2 May 2002 09:05:31 -0000
*************** misc:
*** 72,74 ****
--- 72,82 ----
.align
.L2:
.word fred
+
+ .ltorg
+ .thumb
+ .global thumb_tests
+ .thumb_func
+ thumb_tests:
+ sub r0, #0
+ add r0, #0
Index: gas/testsuite/gas/arm/arm7t.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/arm/arm7t.d,v
retrieving revision 1.6
diff -c -3 -p -w -r1.6 arm7t.d
*** gas/testsuite/gas/arm/arm7t.d 16 Jul 2001 19:06:09 -0000 1.6
--- gas/testsuite/gas/arm/arm7t.d 2 May 2002 09:05:31 -0000
*************** Disassembly of section .text:
*** 66,68 ****
--- 66,70 ----
[ ]*dc:.*fred
0+e0 <[^>]*> 0000c0de ? .*
0+e4 <[^>]*> 0000dead ? .*
+ 0+e8 <[^>]*> 3800 sub r0, #0
+ 0+ea <[^>]*> 3000 add r0, #0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Thumb: Do not convert "sub r?, #0" into "add r?, #0",
Nick Clifton <=