Liu Haibin <[EMAIL PROTECTED]> writes:

> I compiled the following code using nios gcc -da -O3 (gcc version 3.3.3)
> 
> #include <math.h>
> #define PI         (4*atan(1))
> 
> double rad2deg(double rad)
> {
>      return (180.0 * rad / (PI));
> }
> 
> The begining of the .s file is
> rad2deg:
>       addi    sp, sp, -16
>       stw     fp, 8(sp)
>       mov     r6, zero
>       mov     fp, sp
>       movhi   r7, %hiadj(1080459264)
>       addi    r7, r7, %lo(1080459264)
>       stw     ra, 12(sp)
>       stw     r16, 4(sp)
>       stw     r17, 0(sp)
>       call    __muldf3
>       mov     r4, zero
>       movhi   r5, %hiadj(1072693248)
>       addi    r5, r5, %lo(1072693248)
>       mov     r16, r2
>       mov     r17, r3
>       call    atan
> ......
> 
> The corresponding rtl to "call __muldf3" in .c.26.flow2 file is
> 
> (call_insn/u 17 16 21 0 0x0 (parallel [
>             (set (reg:DF 2 r2)
>                 (call (mem:QI (symbol_ref:SI ("__muldf3")) [0 S1 A8])
>                     (const_int 0 [0x0])))
>             (clobber (reg:SI 31 ra))
>         ]) 44 {*call_value} (insn_list 15 (nil))
>     (expr_list:REG_DEAD (reg:DF 4 r4)
>         (expr_list:REG_DEAD (reg:DF 6 r6)
>             (expr_list:REG_UNUSED (reg:SI 31 ra)
>                 (expr_list:REG_EH_REGION (const_int -1 [0xffffffff])
>                     (nil)))))
>     (expr_list (use (reg:DF 6 r6))
>         (expr_list (use (reg:DF 4 r4))
>             (nil))))
> 
> According to the rtl, it uses r4, r5, r6 and r7 as arguements. But the
> assemble codes show no r4 or r5 is ever used before "call __muldf3".
> Any idea why it is so?

Presumably r4 and r5 hold the value of rad which was passed into the
function.  The compiler loads 180.0 into r6 and r7, and calls muldf3
to multiply rad (in r4/r5) by 180.0 (in r6/r7).

Ian

Reply via email to