x86/APX: optimize {nf} forms of OR/XOR with small immediates
Optimizes OR/XOR instructions with small immediates on x86 APX for size.
This commit optimizes certain forms of the OR and XOR instructions on x86 with the APX extension when small immediate values are used. Specifically, it allows the assembler to use shorter byte or word forms of these instructions when the non-EVEX.ND byte/word operations leave upper bits unaltered. This optimization is restricted to size improvement, acknowledging potential performance implications like length-changing prefixes or partial register stalls.
In Details
The tc-i386.c code now includes logic to transform OR/XOR instructions with small immediate values (e.g., fitting in 8 or 16 bits) into their shorter byte or word forms when the APX extension is enabled and optimize_for_space is active. This leverages the behavior of non-EVEX.ND operations where upper register bits are unaffected. Conditions include opcode checks, operand counts, and prefix availability. The transformation is primarily for size reduction.
- 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.