FRIDAY, OCTOBER 30, 2026
x86/apx — Proposed
x86/APX: optimize {nf} forms of AND with small immediates
Optimize AND instructions with small immediate values for better code density in x86 assembly.
This patch introduces optimizations for AND instructions in x86 assembly, specifically targeting forms with small immediate values. It leverages implied zero-extension of EVEX.ND encodings to replace wider operations with narrower byte or word forms, improving code density.
In Details
This patch modifies gas's instruction selection logic for x86. It targets the 'nf' (no-fused) forms of AND instructions, which are part of the APX extension. The optimization replaces certain AND operations with smaller immediate values (e.g., 8-bit or 16-bit) by utilizing EVEX encoding properties, aiming to reduce code size.
For Context
- x86
- A family of instruction set architectures (ISAs) for CPUs, commonly used in personal computers and servers.
- APX
- Advanced Performance Extensions, a set of new instructions and features for x86 processors.
- {nf}
- Refers to instruction forms that do not utilize fused operations, often implying more explicit or less optimized instruction sequences.
- AND
- A bitwise logical operation that outputs 1 only when both inputs are 1.
- immediate value
- A constant value embedded directly within an instruction.
- EVEX.ND encoding
- A specific encoding scheme used in x86 instruction sets (particularly AVX-512) that allows for implied zero-extension of operands.