Content originally posted in LPCWare by cyberstudio on Thu Jun 06 17:58:25 MST 2013
I am using LPCXpresso 5.2.4 too, and just to make sure we are talking about the same thing,
1, the chip I used was LPC1114 (this discussion does NOT apply to Cortex M3), and,
2, the multiplied constant must be simple, with only 2 or 3 ones in the multiplied constant, otherwise the compiler would reason that MULS is cheaper for multiplying a complicated constant than a series of shifts and adds.
I searched through my disassmebly listing - the only time the compiler generate a plain MULS was when both operands are variables but not constants.
We know the root cause of this is the compiler assumes MULS takes 32 cycles to execute when in reality it takes only one on LPC1114. Even if gcc now supports Cortex M0, it still needs to be told that LPC1114's particular implementation is single cycle not 32, and it seems like no one has ever told the compiler about that, no?