-ffp-contract=fast

GCC per default enables one optimization for x86_64 that can change the result of floating-point operations: -ffp-contract=fast.1 This allows the compiler to do floating-point expression contraction such as combining multiplication and addition instructions with an FMA instruction.2

  1. -ffp-contract=fast is enabled for C++ and GNU C. It is not enabled for standard C (that is, when compiling with -std=c99, etc.). 

  2. The FMA instruction omits the rounding done in the multiplication instruction, making the calculations produce different results for some input values. 

Read More

Optimizations enabled by -ffast-math

This blog post describes the optimizations enabled by -ffast-math when compiling C or C++ code with GCC 11 for x86_64 Linux (other languages/operating systems/CPU architectures may enable slightly different optimizations).

Read More