GCC separates FMA deferral control for optimizations
GCC introduces a new parameter to control FMA deferral independently from reassoc reordering, benefiting targets like AArch64.
GCC’s tree-ssa-math-opts pass now allows finer control over floating-point fused multiply-add (FMA) optimizations. A new parameter, widening-mul-defer-fma, is introduced to gate the deferral of multiply-accumulate operations, separate from the avoid-fma-max-bits parameter which controls reassoc reordering. This change prevents performance regressions on targets like AArch64, where disabling reassoc reordering to avoid FMA also unnecessarily disabled other beneficial optimizations.
In Details
The param_avoid_fma_max_bits previously gated both the widening_mul FMA-deferring transform (leaving FMUL + FADD) and the reassoc loop-carried-FMA reordering. This commit separates these into two parameters: param_avoid_fma_max_bits for reassoc reordering and a new param_widening_mul_defer_fma for the multiply-add deferral. This allows targets, like AArch64 with AVOID_CROSS_LOOP_FMA, to selectively disable FMA deferral without impacting FMA reassoc reordering, improving performance for FP reductions.
- FMA
- Fused Multiply-Add, an instruction that performs a multiplication and an addition in a single operation, often with higher precision and performance than separate operations.
- tree-ssa-math-opts
- A GCC optimization pass that operates on the SSA (Static Single Assignment) form of the intermediate representation to perform various arithmetic optimizations, including those related to floating-point operations.
- reassoc reordering
- An optimization that reassociates arithmetic operations to potentially improve performance or enable other optimizations. In this context, it refers to reordering FMA operations.
- SSA form
- Static Single Assignment form is an intermediate representation in compilers where every variable is assigned a value only once. This simplifies many data-flow analyses and optimizations.
- AArch64
- The 64-bit ARM architecture, commonly used in mobile devices and servers.