AVR-gcc 4.5.0

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,
a couple months ago I posted an information about gcc 4.4.2 on Linux. The main advantage of new compiler version was smaller code, but the benefits were not very huge.
Today I checked pretty new gcc 4.5.0, and compiled my C++ program, the results are as follows:
gcc 4.3.3 "“ 52708 bytes, SRAM 964 bytes
gcc 4.4.2 "“ 46528 bytes, SRAM 858 bytes
gcc 4.5.0 "“ 42708 bytes, SRAM 858 bytes.

So my code is now 19% smaller than the code produced by the newest WinAVR. I quickly checked how it works, and it seems to work without any problems. Because tested application is pretty large, I can assume that at least there is no any major issues with tested compiler version.
There is still some space for optimization, because to compile my application I've used the same compiler and linker parameters, whereas gcc 4.5 has some more options, so it can possibly produce even smaller code.
Of course gcc 4.5 suffers from the same disease as gcc 4.3.x "“ constant strings in FLASH are not merged, and VTABLES are still copied to SRAM, wasting a lot of memory.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

So my code is now 19% smaller

Impressive improvement!

Any idea on what has been optimized better than before?

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It’s hard to say. I will try to compare lss listings of my program. At first look it seems that gcc 4.5 don’t so aggressively inline functions, but obviously there is a lot of other changes. What is interesting I’ve found that gcc now prepares a few versions of the same functions, apparently for different parameter set – for example if some or all parameters are constants known during compilation the produced code is different and smaller. And because it uses MPC library, so a function called with constant parameters known during compilation is replaced by the result of the function without any need of code generation. Generally produced code looks cleaner.
Unfortunately my gcc is not compiled with LTO enabled (is it still not supported on AVR platform?), so I cannot check –flto and –fwhopr. I didn’t use –fwhole-program too.