Depending on this question Floating point division vs floating point multiplication. Division is slower than multiplication due to some reasons.
Will the compiler, usually, replace division by multiplication if it is possibe?
For example:
float a;
// During runtime a=5.4f
float b = a/10.f;
Will it be:
float a;
// During runtime a=5.4f
float b = a*0.1f;
If it is considered a compiler dependable question, I am using VS2013 default compiler. However, it would be nice if I got a generic answer (theoretical validity of this optimization)
fp:fast
option: msdn.microsoft.com/en-us/library/e7s85ffb.aspx – Serge Rogatch-freciprocal-math
, which is also automatically enabled when selecting either-funsafe-math-optimizations
,-ffast-math
or-Ofast
. See gcc.gnu.org/onlinedocs/gcc-4.9.1/gcc/Optimize-Options.html – Pedro Gimeno