Is there any way the RealView compiler can take advantage of the multiply-and-accumulate instructions of the Cortex M3?
I wrote a simple MAC loop and the compiler didn't generate any SMLAL or UMLAL instructions, which was disappointing.
Thanks, Andrew Queisser HP
Hi Marcus,
Thanks for the tip - I'm using armcc 4.1 Build 561 from the Keil UV4 installation. What are the command line options you use to see the UMLAL instructions?
Thanks, Andrew
You mean other than "--cpu=cortex-m3"? Nothing in case of my Q&D test. I think that by default, "-O2 -Ospace" are selected by the compiler.
Regarding your statement
> Once I've forced the compiler to generate close to what I want, in this case the MAC > instructions, I throw away the C-code and tweak the assembly.
May I ask why? The RealView compiler is fairly good at generating very efficient code. Implementing things in C increases the chance that you will remember what you did two weeks from now. I don't find many places where I could have outsmarted the compiler.
-- Marcus
>> Once I've forced the compiler to generate close to what I want, in this case the MAC >> instructions, I throw away the C-code and tweak the assembly.
> May I ask why? The RealView compiler is fairly good at generating very efficient code. > Implementing things in C increases the chance that you will remember what you did two > weeks from now. I don't find many places where I could have outsmarted the compiler.
Exactly. In this particular case, if the compiler uses the MAC instructions I'm happy. Otherwise I might grudgingly resort to assembly but only if our profiling shows that optimizing this particular operation is worthwhile. Since our application is very power sensitive we want to get the RMS calculation done as quickly as possible so we can put the CPU back to sleep.
Andrew