[Bug c/23782] New: -Os +22%: gcc-3.4.4 does it in 230 bytes, gcc-4.0.2-pre in 281 bytes
etienne_lorrain at yahoo dot fr
gcc-bugzilla@gcc.gnu.org
Thu Sep 8 17:08:00 GMT 2005
etienne@cygne:~/projet/gujin$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-
languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr --enable-shared --
with-system-zlib --libexecdir=/usr/lib --enable-nls --without-included-
gettext --enable-threads=posix --program-suffix=-4.0 --enable-__cxa_atexit --
enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug --
enable-java-gc=boehm --enable-java-awt=gtk --enable-gtk-cairo --with-java-
home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre --enable-mpfr --disable-
werror --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.0.2 20050821 (prerelease) (Debian 4.0.1-6)
etienne@cygne:~/projet/gujin$ gcc -Os -c -o tmp.o tmp.c && size tmp.o
text data bss dec hex filename
281 0 0 281 119 tmp.o
etienne@cygne:~/projet/gujin$ ../toolchain-3.4.4-2.16/bin/gcc -v
Reading specs from /home/etienne/projet/toolchain-3.4.4-
2.16/bin/../lib/gcc/i686-pc-linux-gnu/3.4.4/specs
Configured with: ../configure --prefix=/home/etienne/projet/toolchain --enable-
languages=c
Thread model: posix
gcc version 3.4.4
etienne@cygne:~/projet/gujin$ ../toolchain-3.4.4-2.16/bin/gcc -Os -c -o tmp.o
tmp.c && size tmp.o
text data bss dec hex filename
230 0 0 230 e6 tmp.o
etienne@cygne:~/projet/gujin$ cat tmp.c
typedef struct {
unsigned short x, y; /* x should be the easyest to read */
} __attribute__ ((packed)) coord;
#define FASTCALL __attribute__ (( fastcall ))
struct user_interface_fct_str {
void (*setpixel) (coord xy, unsigned color) FASTCALL;
void (*plotHline) (coord xy, unsigned short xend, unsigned color);
} function;
extern inline void
UI_plotHline (coord xy, unsigned short xend, unsigned color) {
function.plotHline (xy, xend, color);
}
extern inline void
UI_setpixel (coord xy, unsigned color) {
function.setpixel (xy, color);
}
extern unsigned stack_limit;
extern inline void bound_stack (void)
{
asm volatile (" bound %%esp,%0 " : : "m" (stack_limit) );
}
void drawbutton (coord upperleft, coord lowerright,
unsigned upperleftcolor, unsigned lowerrightrcolor,
unsigned fillcolor, unsigned drawbackground)
{bound_stack();{
/* Enlarge the button by few pixels: */
upperleft.x -= 2;
lowerright.x += 2;
lowerright.y -= 1; /* do not overlap two consecutive lines */
UI_plotHline (upperleft, lowerright.x, upperleftcolor); /* top line */
/* do not change VESA1 banks too often, process horizontally,
left to right, line per line */
for (;;) {
upperleft.y += 1;
if (upperleft.y >= lowerright.y)
break;
UI_setpixel (upperleft, upperleftcolor);
if (drawbackground)
UI_plotHline (((coord) { .x = upperleft.x + 1, .y = upperleft.y }),
lowerright.x - 1, fillcolor);
UI_setpixel (((coord) { .x = lowerright.x - 1, .y = upperleft.y }),
lowerrightrcolor);
}
UI_plotHline (upperleft, lowerright.x, lowerrightrcolor); /* bottom line
*/
}}
etienne@cygne:~/projet/gujin$
Doing the commands:
../toolchain-3.4.4-2.16/bin/gcc -Os -S -o tmp.a tmp.c
gcc -Os -S -o tmp.b tmp.c
diff -y tmp.a tmp.b
does not give me a clear idea of the reason...
--
Summary: -Os +22%: gcc-3.4.4 does it in 230 bytes, gcc-4.0.2-pre
in 281 bytes
Product: gcc
Version: 4.0.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: etienne_lorrain at yahoo dot fr
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i486-linux-gnu
GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23782
More information about the Gcc-bugs
mailing list