Re: , optimizing for size in general, was C compiler for PDP-11 sought

xleobx@qmailcomq.com
4 Oct 2003 14:37:55 -0400

          From comp.compilers

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 ertr1013@student.uu.se (Erik Trulsson) (2003-09-27)
Re: , optimizing for size in general, was C compiler for PDP-11 sought xleobx@qmailcomq.com (2003-10-04)
| List of all articles for this month |
From: xleobx@qmailcomq.com
Newsgroups: comp.compilers
Date: 4 Oct 2003 14:37:55 -0400
Organization: Verio
References: 03-09-075 03-09-101
Keywords: optimize
Posted-Date: 04 Oct 2003 14:37:55 EDT

Erik Trulsson <ertr1013@student.uu.se> wrote:
> leob@mailcom.com wrote:


>> 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;
>> }


> 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


And that is exactly what I'm talking about. What happened to the good old
peephole optimizations? All data dependency related performance issues aside,
why not (especially when -Os is given):


foo:
movl a, %edx
leal 1(%edx), %eax
testl %eax, %eax
je .L1
leal 2(%edx), %eax
...L1:
movl %eax, a
ret


Is there a reason not to do such an optimization?
What are cases when bb tail combining is bad, if ever?


Leo


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.