binutils Newspaper
NOVEMBER 30, 2026
x86/apx — Proposed

x86/APX: optimize {nf} forms of XOR with all-ones immediate

Replaces XOR instructions with an all-ones immediate with NOT, simplifying the instruction.

This patch optimizes x86 XOR instructions when the immediate value is all ones (-1) or 0xFF. It replaces these operations with the NOT (bitwise NOT) instruction, which achieves the same result with potentially fewer bytes or a simpler instruction encoding.

In Details

This patch modifies gas's instruction selection for x86 APX. It identifies XOR instructions with an immediate operand of -1 (all ones) or 0xFF and rewrites them as NOT instructions. This applies to various operand sizes and forms, aiming for code size reduction by using the more specific NOT instruction.

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.
XOR
Exclusive OR, a bitwise logical operation.
immediate value
A constant value embedded directly within an instruction.
NOT
Bitwise NOT (complement) instruction in x86 architecture.
Filed Under: binutilsx86optimizationassembly