Expose AdvSIMD integer multiply-add optabs for better optimization.
AArch64 now exposes integer multiply-add operations for AdvSIMD, enabling better use of FMA instructions.
The GCC compiler for AArch64 has gained support for exposing AdvSIMD integer multiply-add operations (FMA) through its optab system. Previously, AArch64 lacked specific optabs for integer FMA, causing sequences like e - ey * 3 to be expanded into separate multiply and add instructions, preventing recognition of fused multiply-subtract operations. This change introduces new optabs and expands existing ones to leverage hardware FMA capabilities.
This enhancement allows the tree math pass to retain multiply-add operations, leading to more efficient code generation. For example, a specific cbrtf implementation in glibc sees a 1.69% reduction in instructions. Test cases cover various scenarios including signed/unsigned modes, constant/variable factors, and wraparound values.
In Details
AdvSIMD on AArch64 supports integer multiply-accumulate (MLA) and multiply-subtract (MLS) operations, which are forms of Fused Multiply-Add (FMA). However, GCC's AArch64 backend lacked dedicated optabs for these integer FMA operations, meaning that an expression like a + b*c or a - b*c would be lowered into separate GIMPLE multiply and add/subtract statements. The combine pass could then potentially recognize a multiply-subtract pattern, but a true FMA optab would allow the tree-optimization passes to preserve the FMA operation directly. This commit adds fma<mode>4 and fnma<mode>4 e…
- AArch64
- The 64-bit ARM architecture. GCC's backend for this architecture supports various instruction sets, including NEON (AdvSIMD) and SVE.
- AdvSIMD
- An Advanced Single Instruction, Multiple Data (SIMD) extension for ARM processors, also known as NEON. It allows operations on multiple data elements simultaneously.
- optab
- Optimization table. A data structure used by GCC to map high-level operations (like multiply-add) to specific machine instructions or patterns for a given target architecture.
- FMA
- Fused Multiply-Add. An instruction that performs a multiplication and an addition (or subtraction) in a single operation, often with higher precision and speed than separate instructions.
- GIMPLE
- GCC's internal tuple representation for intermediate code, used after the initial front-end parsing and before lower-level RTL generation. It's a form of Static Single Assignment (SSA) representation.
- tree math pass
- A compiler optimization pass that operates on GCC's internal 'tree' representation, performing algebraic simplifications and transformations on arithmetic expressions.
- VDQ_BHSI
- A specific type of instruction pattern or macro used in GCC's machine description files, likely related to vector operations on AArch64.