GCC Newspaper
NOVEMBER 30, 2026
gcc — Proposed

ffp-contract=local: contraction decided before IPA

Proposes function attributes to enable floating-point contraction across calls to intrinsics and wrapper types when -ffp-contract=on is used.

Paavan Indela proposes three new function attributes (fp_contractable_add, fp_contractable_sub, fp_contractable_mul) to enable floating-point contraction for expressions involving calls to intrinsics or operators of floating-point wrapper types. This proposal extends the behavior of -ffp-contract=on to scenarios where operations are not direct source-level expressions but function calls, allowing for fused multiply-add (FMA) optimizations. The attributes imply const and nothrow and have specific requirements regarding function signature and argument types.

In Details

This proposal introduces function attributes to extend the scope of the -ffp-contract=on optimization. Currently, this flag only enables contraction (e.g., FMA) for operations within a single source expression. The new attributes (fp_contractable_add, fp_contractable_sub, fp_contractable_mul) would allow contraction to occur across calls to functions (like intrinsics or methods of wrapper types) that are declared to perform these operations. This requires the compiler to trust the attribute declaration as a promise, similar to const, and the compiler verifies the function signature…

For Context
-ffp-contract=on
A GCC optimization flag that enables floating-point contraction, allowing certain operations like multiply-add to be combined into a single FMA instruction for performance.
IPA
Interprocedural Analysis. A compiler optimization technique that analyzes code across function calls, not just within a single function, to find optimization opportunities.
intrinsic
A function or operation that is recognized by the compiler and may have a special, optimized implementation, often corresponding to a specific machine instruction.
floating-point wrapper type
A user-defined type (e.g., a class or struct) that encapsulates a floating-point number and overloads operators to mimic built-in floating-point arithmetic, potentially adding features or enabling specific optimizations.
FMA
Fused Multiply-Add. A single machine instruction that performs both a multiplication and an addition, often with higher precision and performance than separate multiply and add operations.
function attribute
A GCC extension that allows specifying special properties or behaviors for functions, such as const, nothrow, or the proposed fp_contractable_* attributes.
cv-qualifiers
Const (const) and volatile (volatile) qualifiers applied to types in C++. They indicate whether a variable can be modified or if its value might change unexpectedly.
Filed Under: optimizationfloating-pointattributesintrinsics