Christian Böhme wrote:
#include <stdint.h>
// ...
int32_t a;
uint16_t b = 8;
a = -(b * 2u);
--->8---
at which point and why will the hardware multiplier be
used to evaluate the expression ?
This is a completely constant expression. A good compiler will detect
this and assign the result as a constant to "a". Please note, that the
assignment to "a" may not be executed at this point in the compiled
program. This compiler may do it later if "a" is read by some
instruction. Have a look in the disassembled machine code.
Constant evaluation is common for integer variables. For floating point
variables the compiler /may/ infer code for computation.
Ralf