Marvin, > > Gcc generates this with -O3, an abomination in my > > eyes: > > Larger numbers behind the -O option do not > automatically cause "better" optimization. There is no > universal definition for how to get "better" optimized code > (It depends on what the application is what is you are trying > to accomplish). With regards to optimization. anyway you > look at it, it's a speed vs. code size tradeoff. > > With that said, In the example that you cited, using > -O3, gcc attempts to inline all "simple" functions. There are no simple functions in this example--the overhead is stack frame setup and teardown. > So, you got what you asked for: A lot of inline > functions resulting in large code size. I repeat for the hard of thinking: there are no inline functions, the overhead is stack maintenance code and is generated irrespective of optimization setting. > For the AVR > target, this normally constitutes a large > pessimization due to the code increasement. However, > there are exceptions (But, your example is not one of > them...). > > So, to sum up your example, when you used the -O3 > switch, you told gcc to include TONS of inline code. Buggered if I did. -O0, -O1, -02 produce the same entry/exit code as -O3 if you'd care to try them. You can't get rid of that code, even by subroutining it, as it's required. If you don't believe me, just try. That's to say, the decisions made for the runtime architecture of GCC for AVR are probably more to do with the limitations of GDB, why else have a unified stack? So, how would you get GCC to produce the 6 words of code that my compiler generates if it's so good? I mean, you've got loads of switches and buttons to try with GCC, more than you can shake a stick at. What reasonable human is going to sit there and flip individual switches to try to get GCC to generate good code? > gcc did exactly what you asked it to do: increase code > size. No, it did what it had to, that is set up and tear down a stack frame. > To check my statements, query the internet for : To check my statements, try running gcc yourself or write a code generator for it, like I have. I do happen to know what I'm talking about here. -O3 optimizes the RTL inside GCC and does nothing to eliminate stack maintenance code when it's required. Why stick up for GCC on AVR? GCC is a generic compiler and would never really compete with compilers crafted to the specific architectures. -- Paul.
Message
RE: [AVR-Chat] Re: STK500, STK501 & AVR Studio not a complete environment
2004-04-26 by Paul Curtis
Attachments
- No local attachments were found for this message.