RFR: 8351016: RA support for EVEX to REX/REX2 demotion to optimize NDD instructions
Jatin Bhateja
jbhateja at openjdk.org
Mon Aug 4 15:52:28 UTC 2025
Currently, while choosing the colour (register) for a definition live range during the select phase of register allocation, we pick the first available colour which does not match with already allocated nebouring live ranges.
With Intel APX NDD ISA extension several existing two address arithmetic instruction can now have an explicit non-destructive desitination operand, this in general saves addition spills for two address instruciton where destination is also first source operand and whose live range surpasses this instruction.
All NDD instructions mandates extended EVEX encoding with a bulky 4 byte prefix, [JDK-8351994](https://github.com/openjdk/jdk/pull/24431) added logic for NDD to REX/REX2 deomotion in the assembler layer but due to existing first color selection register allocation policy the demotions are rare. This patch biases the allocation of NDD definition to first source operand or second source operand for commutative class of operations.
Biasing is compile time hint to allocator and is different from live range coalescing (aggressive / conservative) which merge the two live ranges using union find algorithm. Given that REX encoding needs 1 byte prefix and REX2 encoding need 2 byte prefix, domotion saves considerable JIT code size.
Patch shows around 5-20% improment in code size by facilitating NDD demotion.
For following micro, method JIT code size reduced from 136 to 120 bytes which is around 13% reduction in code size.
**Micro:-**
<img width="1344" height="315" alt="image" src="https://github.com/user-attachments/assets/9cbe9da8-d6af-4b1c-bb55-3e5d86eb2cf9" />
**Baseline :-**
<img width="1013" height="163" alt="image" src="https://github.com/user-attachments/assets/ff5d50c6-fdfa-40e8-b93d-5f117d5a1ac6" />
**With opt:-**
<img width="940" height="160" alt="image" src="https://github.com/user-attachments/assets/bff425b0-f7bf-4ffd-a43d-18bdeb36b000" />
Thorough validation are underway using latest [Intel Software Developement Emulator version 9.58](https://www.intel.com/content/www/us/en/download/684897/intel-software-development-emulator.html).
Kindly review and share your feedback.
Best Regards,
Jatin
-------------
Commit messages:
- Some refactoring
- 8351016: RA support for EVEX to REX/REX2 demotion to optimize NDD instructions
Changes: https://git.openjdk.org/jdk/pull/26283/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=26283&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8351016
Stats: 89 lines in 2 files changed: 72 ins; 6 del; 11 mod
Patch: https://git.openjdk.org/jdk/pull/26283.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/26283/head:pull/26283
PR: https://git.openjdk.org/jdk/pull/26283
More information about the hotspot-compiler-dev
mailing list