avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Question about code size


From: Dave Hylands
Subject: Re: [avr-gcc-list] Question about code size
Date: Sat, 17 Mar 2007 05:33:39 -0800

Hi Joerg,

> The numbers are the size in bytes of the .text section for the
> function above. It appears that the compiler is promoting the
> unsigned char's to ints.

It has to do this internally, but it correctly removed the high byte
handling in all three compiler versions then, as it does not
contribute to the result.  Your disassembled code is a bit misleading,
as it does not fill in the relocatable offsets of the branches
correctly.

Yeah - In this particular case, I was just compiling a snippet of C
code. Normally I would dissassemble the fully located elf file.

The difference between 4.1.x and 4.2.0 is that in your
version, instead of immediately testing the loop count against 0, it
jumps to the end of the loop first.  This is probably the consequence
of using -Os, as it is correct that way: it takes more time but one
less instruction.

The major difference is that it no longer recognizes it could reorder
the loop counter to count down rather than up.  If you manually
reorder the loop like this:

unsigned char getch(void);
void getNch(unsigned char count)
{
    for(;count > 0; count--)
        getch();
}

....you get the same result as in 3.x.

Would that be considered an optimization already that is worth a GCC
bug report?

To me, I don't really care which way it counts (internally). I was
shocked to see a working bootloader grow by 60% when all I did was go
to a newer compiler. A big portion of the increase was due to the way
it was inlining stuff. The failure to optimize out the int promotions
i small potatoes in comparison to the inlining decision.

I'd be happy to file a bug a report. I just wanted to make sure I
wasn't overlooking something obvious.

> Aside: I've just moved my development platform from Windows to
> linux.  Where would I go to get the latest patches for
> gcc/binutils/et al.?

See Bingo600's script, it's referenced in a "sticky" article on top of
the AVR-GCC forum of http://www.avrfreaks.net/ .

Thanks, I'll check it out.

--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]