Re: double argument casting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> In that case your patch modification seems to work better since it seems
> to remove the cast from the callee and does the sign extension on the
> caller:
>
> (gcc4.5.1 with your patch applied)
>
> 0001024c <somme>:
>    1024c:    10 80 00 04     b  1025c <somme+0x10>
>    10250:    82 10 20 00     clr  %g1
>    10254:    82 00 60 01     inc  %g1
>    10258:    91 3a 20 18     sra  %o0, 0x18, %o0
>    1025c:    80 a0 40 09     cmp  %g1, %o1
>    10260:    26 bf ff fd     bl,a   10254 <somme+0x8>
>    10264:    91 2a 20 19     sll  %o0, 0x19, %o0
>    10268:    90 02 00 09     add  %o0, %o1, %o0
>    1026c:    91 2a 20 10     sll  %o0, 0x10, %o0
>    10270:    81 c3 e0 08     retl
>    10274:    91 3a 20 10     sra  %o0, 0x10, %o0
>
>   000102ac <main>:
>    102ac:    9d e3 bf 98     save  %sp, -104, %sp
>    102b0:    82 10 20 01     mov  1, %g1
>    102b4:    c2 37 bf fc     sth  %g1, [ %fp + -4 ]
>    102b8:    c2 2f bf ff     stb  %g1, [ %fp + -1 ]
>    102bc:    c2 2f bf fe     stb  %g1, [ %fp + -2 ]
>    102c0:    d0 0f bf ff     ldub  [ %fp + -1 ], %o0
>    102c4:    d2 17 bf fc     lduh  [ %fp + -4 ], %o1
>    102c8:    91 2a 20 18     sll  %o0, 0x18, %o0
>    102cc:    93 2a 60 10     sll  %o1, 0x10, %o1
>    102d0:    91 3a 20 18     sra  %o0, 0x18, %o0
>    102d4:    7f ff ff de     call  1024c <somme>
>    102d8:    93 3a 60 10     sra  %o1, 0x10, %o1
>    102dc:    d0 37 bf fc     sth  %o0, [ %fp + -4 ]
>    102e0:    d0 0f bf fe     ldub  [ %fp + -2 ], %o0
>    102e4:    d2 17 bf fc     lduh  [ %fp + -4 ], %o1
>    102e8:    91 2a 20 18     sll  %o0, 0x18, %o0
>    102ec:    93 2a 60 10     sll  %o1, 0x10, %o1
>    102f0:    91 3a 20 18     sra  %o0, 0x18, %o0
>    102f4:    7f ff ff d6     call  1024c <somme>
> ...
>
> isn't that right?

Yes, the code is now correct, but still sub-optimal as the sequence:

>    102c4:    d2 17 bf fc     lduh  [ %fp + -4 ], %o1

>    102cc:    93 2a 60 10     sll  %o1, 0x10, %o1

>    102d8:    93 3a 60 10     sra  %o1, 0x10, %o1

could be reduced to just:

  ldsh  [ %fp + -4 ], %o1

but this requires more work in the back-end.  This is actually the bulk of the 
work to be done as the extension in the callee that TARGET_PROMOTE_PROTOTYPES 
triggers has very likely a marginal effect overall.

Note that x86, MIPS, HP-PA, m68k, IA-64 and many others have the same setting.

-- 
Eric Botcazou


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux