GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
aarch64

Prevent FP intrinsics from being DCE'd with -ftrapping-math.

Ensure floating-point intrinsics are not optimized away when -ftrapping-math is enabled to catch signalling NaNs.

This change prevents floating-point intrinsics, like vadd_f32, from being optimized away when the -ftrapping-math option is used. Previously, if the result of such an intrinsic was unused, the instruction would be removed, which is problematic if it could generate a floating-point exception from a signalling NaN. A new function build_optimization_barrier is introduced to insert an asm volatile statement, creating a dependency on the result and preventing its dead code elimination.

In Details

This commit addresses a codegen issue in aarch64 where FP intrinsics expanded from NEON builtins might be DCE'd by the optimizer. When -ftrapping-math is active, this can lead to missed floating-point exceptions. The fix involves inserting an asm volatile statement as an optimization barrier to ensure the intrinsic's result is not discarded, particularly affecting the gimple_arith::fold expansion.

Filed Under: aarch64optimizationfloating-point