Related articles |
---|
C compiler for PDP-11 sought, optimizing for size in general leob@mailcom.com (2003-09-23) |
Re: C compiler for PDP-11 sought, optimizing for size in general jthorn@aei.mpg.de (Jonathan Thornburg) (2003-09-23) |
Re: C compiler for PDP-11 sought, optimizing for size in general ertr1013@student.uu.se (Erik Trulsson) (2003-09-27) |
Re: C compiler for PDP-11 sought, optimizing for size in general Jeffrey.Kenton@comcast.net (Jeff Kenton) (2003-09-27) |
Re: , optimizing for size in general, was C compiler for PDP-11 sought xleobx@qmailcomq.com (2003-10-04) |
From: | Erik Trulsson <ertr1013@student.uu.se> |
Newsgroups: | comp.compilers |
Date: | 27 Sep 2003 13:52:36 -0400 |
Organization: | Compilers Central |
References: | 03-09-075 |
Keywords: | C, optimize |
Posted-Date: | 27 Sep 2003 13:52:36 EDT |
leob@mailcom.com wrote:
> I am looking for an optimizing compiler that can take ANSI C (I know
> about unprotoize, so a K&R C compiler will do) and produces PDP-11
> assembly code that is optimized for size rather than for speed.
[snip]
> But even if the GCC port had been finished, the way GCC optimizes for
> size is quite lightweight: the impact of forcing a variable or an
> address into a register is not analyzed wrt the code size, to start
> with: try compiling
>
> void foo() {
> extern int a;
> if(++a) ++a;
> }
>
> with various options for i386 to see what I'm talking about;
> no way you can make it produce
>
> foo: addl $1,a
> je .L1
> addl $1,a
> ..L1: ret
Wanna bet?
Using gcc -O -fomit-framepointer I got it to produce:
foo:
incl a
je .L3
incl a
..L3:
ret
which seems fairly optimal to me.
(Granted, just about any other combination of flags seems to produce
similar unnecessary as you show below.
>
> the best I got is (-O4 -Os)
> foo:
> movl a, %edx
> leal 1(%edx), %eax
> testl %eax, %eax
> movl %eax, a
> je .L1
> leal 2(%edx), %eax
> movl %eax, a
> ..L1:
> ret
>
--
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se
Return to the
comp.compilers page.
Search the
comp.compilers archives again.