To first order approximation, icc does use -ffast-math
by default.
If you run icc --help
, it will show you its options. One of the sections is Floating Point
, which begins like this:
Floating Point
--------------
-fp-model <name>
enable <name> floating point model variation
[no-]except - enable/disable floating point semantics
fast[=1|2] - enables more aggressive floating point optimizations
precise - allows value-safe optimizations
source - enables intermediates in source precision
strict - enables -fp-model precise -fp-model except, disables
contractions and enables pragma stdc fenv_access
double - rounds intermediates in 53-bit (double) precision
extended - rounds intermediates in 64-bit (extended) precision
It doesn't say it here, but in icc documentation here, it says that fast=1
is the default.
The other options similar to -ffast-math
are:
-[no-]prec-sqrt
determine if certain square root optimizations are enabled
-[no-]prec-div
improve precision of FP divides (some speed impact)
-[no-]fast-transcendentals
generate a faster version of the transcendental functions
...
-[no-]ftz
enable/disable flush denormal results to zero
-[no-]fma
enable/disable the combining of floating point multiplies and
add/subtract operations
E.g., fused multiply-adds are on by default, and precise square root is off by default.
But the correspondence between -ffast-math
and -fp-model fast=1
is probably not very precise - it could well be that some other specific options are included in fast-math
(which can be seen here) but excluded in fp-model fast=1
or vice versa. It looks to me like among other things -ffast-math
would disable non-finite floating-point arithmetic (inf
, nan
), which icc doesn't do by default.