aarch64: Implement clmul and clmul_widen optabs
aarch64 compiler now supports carry-less multiplication instructions for improved performance in crypto and other applications.
This commit introduces support for carry-less multiplication (clmul) and its widening variant (clmul_widen) on AArch64, utilizing the PMULL instruction. It adds specific optabs for clmuldi3, clmul_widendi3 (when TARGET_AES is available), and clmul_widenqi3 (for TARGET_SIMD). These implementations leverage AArch64’s PMULL capabilities to provide efficient carry-less multiplication, replacing slower software sequences. The changes include examples showing significant instruction count reductions for these operations, particularly when the necessary hardware features like FEAT_PMULL are present.
In Details
This patch adds clmuldi3, clmul_widendi3, and clmul_widenqi3 to the aarch64 optabs, mapping them to PMULL instructions. For clmuldi3/clmul_widendi3, it uses the 64x64->128 PMULL form when TARGET_AES is enabled, and zero-extends narrower operands. For clmul_widenqi3, it uses the 8x8->16 PMULL form, enabling 8-bit clmul without requiring TARGET_AES. These are restricted to non-streaming mode. The implementation handles the extraction of the high half of the product and spilling it when necessary, and enables a new runtime test requiring FEAT_PMULL.
- clmul
- Carry-less multiplication, an operation used in various fields like error correction codes and cryptography, where the multiplication is performed without generating carries.
- clmul_widen
- A widening version of carry-less multiplication that produces both the low and high parts of the result.
- optab
- Optimization table, a data structure within the compiler that maps high-level operations to specific machine instructions or sequences of instructions.
- PMULL
- An AArch64 instruction that performs a multiply-long operation, capable of producing a 128-bit result from two 64-bit operands, used here for carry-less multiplication.
- TARGET_AES
- A compiler target flag indicating that the hardware supports AES instructions, which in this context are leveraged by the PMULL instruction for cryptographic operations.
- FEAT_PMULL
- A specific hardware feature indicating the presence of the PMULL instruction set on the AArch64 architecture.