When this function is compiled: int a, b; int foo(void) { return a + b; } using -O2 -m4 -fPIC -S, the following code is created: _foo: mov.l r12,@-r15 mova .L3,r0 mov.l .L3,r12 mov.l r14,@-r15 add r0,r12 mov.l .L4,r0 sts.l pr,@-r15 <- PR saved unnecessarily mov.l @(r0,r12),r1 mov r12,r0 mov r15,r14 mov.l @r1,r2 mov.l .L5,r1 mov.l @(r0,r1),r1 mov.l @r1,r1 add r1,r2 mov r2,r0 mov r14,r15 lds.l @r15+,pr <- PR restored unnecessarily mov.l @r15+,r14 rts mov.l @r15+,r12
This version did not have the store/restore of the return register: ./cc1 --version GNU C version 3.4 20030718 (experimental) (sh4-hardhat-linux) compiled by GNU C version 3.4 20030718 (experimental). GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
I can confirm this on the mainline (20031108), looks like sh-linux does do the saving or restoring of the return register for some reason.
(In reply to comment #2) > I can confirm this on the mainline (20031108), looks like sh-linux does do the saving or > restoring of the return register for some reason. Hi, Above mentioned bug is solved in gcc 3.5 mainline (snapshot dated 27-03-2004). But this bug is still there in released gcc 3.4. Can anybody tell me which patch will fix this bug in gcc 3.4 ? Regards, Anil Paranjpe
Fixed with - http://gcc.gnu.org/ml/gcc-patches/2004-02/msg02248.html http://gcc.gnu.org/ml/gcc-cvs/2004-02/msg01310.html This PR can be closed. -Dhananjay
Fixed for 3.5.0.