This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/42017] New: gcc compiling C for ARM has stopped using r14 in leaf functions?


In gcc4.2.1 targeting ARM processors, pure leaf functions were able to make use
of r14 / lr (the link register). However, in gcc4.3.2 and gcc4.4.1 (and
presumably since then, since I can't find it mentioned in any gcc bug reports),
this now uses the stack instead rather than this spare register (boo, hiss).

Here's some C test code: when compiled with the -O3 option, this uses lr on
gcc4.2.1 but [sp] on gcc4.3.2 and gcc4.4.1.

int foo(int r0) {
int r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14;

r1 = 0;

for(r2=0;r2<r0;r2++)
for(r3=0;r3<r0;r3++)
for(r4=0;r4<r0;r4++)
for(r5=0;r5<r0;r5++)
for(r6=0;r6<r0;r6++)
for(r7=0;r7<r0;r7++)
for(r8=0;r8<r0;r8++)
for(r9=0;r9<r0;r9++)
for(r10=0;r10<r0;r10++)
for(r11=0;r11<r0;r11++)
for(r12=0;r12<r0;r12++)
for(r13=0;r13<r0;r13++)
for(r14=0;r14<r0;r14++)
  r1++;

return r1;
}

PS: my guess is that this might have got broken when Thumb2 and ARMv7 support
was added in (round about gcc4.3)...


-- 
           Summary: gcc compiling C for ARM has stopped using r14 in leaf
                    functions?
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: nickpelling at nanodome dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42017


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]