This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug optimization/11826] New: [ARM] Minor register allocation problem before function return
- From: "alga at rgai dot hu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Aug 2003 09:13:54 -0000
- Subject: [Bug optimization/11826] New: [ARM] Minor register allocation problem before function return
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11826
Summary: [ARM] Minor register allocation problem before function
return
Product: gcc
Version: 3.4
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: alga at rgai dot hu
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: arm-unknown-elf
For C functions with a return value GCC should store the result of the last
instruction just before returning it in r0 (in order to avoid using unnecessary
register moves).
The new register allocation algorithm doesn't solve this problem either.
--- c example ---
int foo (int a, int b)
{
if(a+b == 0) return a-b;
return b-a;
}
--- arm code ---
--- arm-elf-gcc -S -g0 -Os -o reg-alloc.s reg-alloc.c ---
foo:
cmn r0, r1
rsb r3, r1, r0
rsbne r3, r0, r1
mov r0, r3
mov pc, lr
--- arm code with new-ra ---
--- arm-elf-gcc -S -g0 -Os -fnew-ra -o reg-alloc.s reg-alloc.c ---
foo:
mov r3, r0
cmn r3, r1
rsb r0, r1, r0
rsbne r0, r3, r1
mov pc, lr
--- possible solution ---
foo:
cmn r0, r1
rsbeq r0, r1, r0
rsbne r0, r0, r1
mov pc, lr