GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
aarch64 Performance Win

aarch64: Use single FP condition mode when exceptions are unobservable.

Optimizes AArch64 floating-point comparisons by using a single condition mode when exceptions are not observable.

This commit optimizes floating-point comparisons on AArch64 by using a single condition mode (CCFPmode) when exceptions like NaN-related invalid operations are unobservable, such as with -ffinite-math-only. Previously, both ordered and equality comparisons might emit separate instructions even when the exception difference was irrelevant. This change consolidates the instruction selection, potentially improving code density and performance. It also updates existing assembly scans and adds new tests.

In Details

The aarch64_fp_cc_mode helper function is introduced to select between CCFPEmode (which traps on quiet NaNs) and CCFPmode (which does not) based on whether FP exceptions are observable. When exceptions are unobservable (e.g., due to -ffinite-math-only), CCFPmode is used for both ordered and equality comparisons to allow instruction selection reuse. The existing aarch64_select_cc_mode uses this new helper. FP assembly scans are anchored to prevent incorrect interpretations, and new tests validate the behavior.

For Context
CCFPmode
A floating-point condition code mode on AArch64 that does not raise an Invalid exception for quiet NaNs. It is used when floating-point exceptions are not observable or not enabled.
CCFPEmode
A floating-point condition code mode on AArch64 that raises an Invalid exception for quiet NaNs. This mode is used when floating-point exceptions are expected to be observable.
NaN
Not a Number. A special floating-point value indicating an undefined or unrepresentable result, such as from dividing zero by zero. Quiet NaNs propagate through calculations without signaling exceptions, while signaling NaNs can raise exceptions.
AArch64
The 64-bit ARM architecture, commonly used in mobile devices and servers. GCC has specific code generation targets for this architecture.
-ffinite-math-only
A GCC compiler flag that instructs the compiler to assume that floating-point operations do not produce NaNs or infinities, and that floating-point exceptions are not observable. This allows for more aggressive optimizations.
Filed Under: aarch64optimizationfloating-point