Are compilers allowed to optimize floating point constant multiplication
问题 the questionable Code is the following: float32_t f = someValueFromSomewhere; f = f * 4; will compiler optimize this? According to C-Standard (if i understood it correctly) the second operand has to be promoted to float32_t ; So the multiplication has to be done using the FPU (or fp emulation). Theoretically the operation could be done in a normal hardware register by just adding an immediate (and may be overflow checking ). Are compiler allowed to do this optimization? Are there compiler