suboptimal GCC code generation for unsigned long long on sparc

Paul Eggert eggert@twinsun.com
Mon Sep 29 13:15:00 GMT 1997


Here's a message forwarded from comp.sys.sun.misc that suggests a
performance improvement for GCC on sparc.  I've verified that the
opportunity for improvement still exists in testgcc-970926.  I've
slightly edited the program so that it compiles without header files.

----

From: bengtk@damek.kth.se (Bengt Kleberg)
Newsgroups: comp.sys.sun.misc,comp.lang.c
Subject: q: GCC or Sun C
Date: Mon, 29 Sep 1997 13:09:43 +0100
Organization: DAMEK, KTH
Message-ID: <bengtk-2909971309470001@sl29.modempool.kth.se>

Just read that gcc on a Ultra Sparc has the following very serious
drawbacks in the code generating capabilities (example code follows
below). The author recommends Sun C instead, as gcc code is only 1/3 of
the speed of Sun C.

Is this correct?


C code:

unsigned
afunc( unsigned long long var1, unsigned long long var2) {
   return ((unsigned)( (var1 ^ var2) >> 48)) ;
}

Assembler code as follows:

gcc (2.7.2.1)

Xor %o0, %o2, %o0
Xor %o1, %o3, %o1
Srl %o0, 16, %g3
Mov 0, %g2
Retl
Mov %g3, %o0

Sun C (4.2)

Xor %o0, %o2, %g1
Retl
Srl %g1, 16, %o0

-- 
Best Wishes, Bengt

Email: bengtk@damek.kth.se



More information about the Gcc mailing list