David Brown schrieb:
variable names "tmp16", "tmp32" and "tmpS16" are truly awful. It is
also (usually) best to declare such temporaries in as small a block as
possible. Thus they should not be at the start of the function, but
instead make your cases like this:
{// (N * 0.75) - 40 DB41 -40 to +150 °C
int16_t temp = (int16_t)(KLineFrameM1[41]) * 3 / 4 - 40;
var_format_S16(buff, temp, 0);
break;
}
That will give clearer code and let the optimiser be more flexible in
its register choices.
As far as "the optimizer" of gcc is concerned, that makes no difference.
It knows exactly what register contains what value and is aware of the
place where a register "dies", i.e. the register can be reused for
whatever other stuff. Anyway, even if just one temp variabe is used, gcc
will produce a new (pseudo) register vor every result like moves,
arithmetic, etc. These pseudos may or may not end up in the same macine
register. On that level, blocks are just syntactic sugar (if they are
not used to hide visibility, e.g. like in int tmp=0; {int tmp = 1;} )
To get a notion of the various machine intependant transformations, have
a glance at gcc's output with -fdump-tree-all, and for the machine
dependent it is -fdump-rtl all. They make clear that do-while, while,
for and if-goto are just flavours of same sugar.
Georg-Johann
_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list