binutils Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
x86/apx

x86/APX: optimize {nf} forms of AND with small negative immediates

Optimizes AND instructions with small negative immediates on x86 APX for size.

This commit enhances the x86 assembler’s APX extension support by optimizing AND instructions that use small negative immediate values. It allows the use of shorter byte or word instruction forms when the non-EVEX.ND byte/word operations do not alter upper register bits. This optimization is specifically for reducing code size, considering that byte/word forms might introduce length-changing prefixes or cause partial register stalls.

In Details

In tc-i386.c, new logic is added to the optimize_nf_encoding function to handle AND instructions with small negative immediates. When the APX extension is active and optimize_for_space is enabled, the assembler can transform these instructions into more compact byte or word forms, provided certain conditions are met (e.g., opcode, operand type, value range). This leverages the behavior of non-EVEX.ND operations and is purely a size optimization.

For Context
x86 APX
An extension to the x86 instruction set architecture, likely referring to Advanced Performance Extensions, which introduces new instructions and capabilities.
{nf}
Likely refers to instructions that do not use the VEX prefix or a specific encoding form, possibly 'non-VEX' or 'normal form'.
EVEX.ND
Encoding VEX-ND is a specific encoding scheme in x86 instruction set extensions, possibly related to 'no data' or 'natural dimension'.
Length-changing prefix
A byte prefix (like 0x66 for operand-size override or 0x67 for address-size override) that modifies the default behavior of instructions regarding operand or address size, potentially increasing instruction length.
Partial register stalls
A performance issue where writing to a portion of a larger register (e.g., the lower 8 bits of a 32-bit register) can cause pipeline stalls because the processor needs to ensure the upper bits are preserved or updated correctly.
Filed Under: x86apxoptimizationassemblersize