[sdiy] Using Cortex Mx Arms in Synth DIY
Nils Pipenbrinck
np at planetarc.de
Sat Dec 24 05:44:37 CET 2011
On 12/24/2011 12:57 AM, John Speth wrote:
> Can anyone comment on the code output efficiency of the ARM GCC? I've
> used the IAR EWARM and it produces high quality and highly optimized
> code. Does ARM GCC come close to it (or better it)? I haven't done a
> side by side comparison.
I can only speak about the code generated for the the 32 bit instruction
set, so it does not apply to the Cortex-M line directly, but I doubt the
differences between 32 bit and thumb mode are that large.
GCC code quality is a little behind the commercial compilers, but not
that much. The code - in general - is a bit more bloated and as such
larger and a bit slower. Last time I took a look GCC still had no idea
how to schedule instructions using the built-in barrel shifter.
This is probably only a problem for the larger ARM cores like Cortex-A
but a bit annoying because it is so unnecessary.
Example:
if you calculate r1 + 530 * r0 GCC tries to be clever and will replace
the constant multiplication with several additions:
add r3, r0, r0, asl #5
add r0, r0, r3, asl #3
add r0, r1, r0, asl #1
This code will take twice as long as necessary because on Cortex-A you
must not use a register with shifting if you have modified it in the
last cycle. The compiler could generate the following code:
mov r2, #530
mla r0, r2, r0, r1
which is not only shorter but also faster. Problem is, that such
patterns occur often in address calculations :-(
But we are only talking about 5-10% difference in size and performance
here, and if something stupid is generated in a critical path there is
still the option to optimize it.
Btw: Texas Instruments has the TMS470 compiler package for linux
available somewhere on their website for free. This is yet another
generic ARM core compiler, so with a little bit of hacking it can be
used for other chips as well. the code quality is very nice.
Nils
More information about the Synth-diy
mailing list