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 rtl-optimization/27468] sign-extending Alpha instructions not exploited



------- Comment #2 from mattst88 at gmail dot com  2009-04-18 15:22 -------
For reference, here's what the Compaq C compiler generates for each of these.

(In reply to comment #0)
> The sign-extending Alpha instructions like addl are sometimes not used. I
> don't know whether the SEE pass is supposed to affect this, or whether it
> is something a combiner pass should do...


Compaq C:
0000000000000000 <f5>:
   0:   10 00 f0 43     sextl   a0,a0
   4:   20 01 f0 43     negl    a0,v0
   8:   c0 08 10 46     cmovge  a0,a0,v0
   c:   00 00 fe 2f     unop    
  10:   01 80 fa 6b     ret

> #include <stdlib.h>
> 
> /* gcc 4.2.0 20060506:
>         negq    a0,v0
>         cmovge  a0,a0,v0
>         sextl   v0,v0
>    optimal:
>         negl    a0,v0
>         cmovge  a0,a0,v0  */   
> int f5(int x) {
>     return abs(x);
> }
> 
> 

Compaq C:
0000000000000000 <f23>:
   0:   30 17 06 4a     sll     a0,0x30,a0
   4:   90 17 06 4a     sra     a0,0x30,a0
   8:   62 05 10 42     s4subq  a0,a0,t1
   c:   42 06 50 40     s8addq  t1,a0,t1
  10:   42 06 50 40     s8addq  t1,a0,t1
  14:   40 06 50 40     s8addq  t1,a0,v0
  18:   01 80 fa 6b     ret

> /* gcc 4.2.0 20060506:
>         s4addq  a0,a0,v0
>         s4addq  v0,v0,v0
>         s8addq  v0,a0,v0
>         s8addq  v0,a0,v0 #
>         sextl   v0,v0    # can be combined to s8addl  v0,a0,v0 */
> int64_t f23(int16_t x) {
>     return 1609 * x;
> }
> 
> 

Compaq C:
0000000000000000 <f49>:
   0:   00 80 5f 24     ldah    t1,-32768
   4:   00 80 7f 24     ldah    t2,-32768
   8:   02 08 02 46     xor     a0,t1,t1
   c:   00 00 43 40     addl    t1,t2,v0
  10:   01 80 fa 6b     ret

> /* gcc 4.2.0 20060506:
>        ldah    t0,-32768
>        xor     a0,t0,v0
>        addq    v0,t0,v0 #
>        sextl   v0,v0    # can be combined to addl    v0,t0,v0 */
> unsigned f49(unsigned val) {
>     return (val ^ 0x80000000) - 0x80000000;
> }
> 

In the first two cases, the Compaq C compiler seems to be more careful about
input arguments.


-- 

mattst88 at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mattst88 at gmail dot com


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


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