-fp-model
Description
-fp-model controls the precision and behavior of floating-point computation. The description is as follows:
- -fp-model=normal
Default configuration, which is equivalent to not setting the fp-model option. Other options are not affected.
- -fp-model=fast
Equivalent to setting -ffast-math. Multiple optimization that causes precision loss is enabled, such as the associative and commutative properties and strength reduction.
- -fp-model=precise
Disable all optimizations that may reduce the floating-point precision to ensure the correctness of the calculation result. The optimizations include disabling exchange associative law, strength reduction, flushing to zero, and fma instruction generation.
- -fp-model=except
Enables the floating-point computation exception mechanism. The compiler considers floating-point exceptions during optimization to prevent aggressive optimization that ignores floating-point exceptions. Note that the Kunpeng chipset currently does not support the floating-point exception interrupt function.
- -fp-model=strict
It is equivalent to enabling both -fp-model=precise and -fp-model=except.
Usage
Add the corresponding option values based on the requirement of the floating-point computation precision.
This option is developed based on GCC. In principle, the original GCC option priority does not change. Therefore, the priority of -fp-model is as follows:
The priority of -fp-model=precise/strict/normal/fast/except is the same as that of -ffast-math and is higher than that of -Ofast/-O3.
- When multiple -fp-model options are specified in the command line, only the last one takes effect. If overriding occurs, the compiler displays a warning message in the output.
- If -fp-model is set to precise or strict, the -Ofast option before -fp-model is replaced by -O3 and the -ffast-math option is deleted. In addition, a warning is reported.
- The priority of -fp-model is equivalent to that of the open-source -ffast-math; therefore, the priority of -fp-model is the same as that of options such as -fmath-errno and -funsafe-math-optimizations. Options take effect depending on their occurrence sequence among command lines and different frontend code.