RFR: 8357982: Fix several failing BMI tests with -XX:+UseAPX [v3]

Emanuel Peter epeter at openjdk.org
Tue Jun 3 17:13:55 UTC 2025


On Tue, 3 Jun 2025 08:19:06 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:

>> A) Patch extends the following tests with hard-coded encoding checks for various BMI instructions to cover REX2 or extended EVEX encodings supported by APX. 
>> 
>> 
>>      compiler/intrinsics/bmi/verifycode/AndnTestI.java
>>      compiler/intrinsics/bmi/verifycode/AndnTestL.java
>>      compiler/intrinsics/bmi/verifycode/BzhiTestI2L.java
>>      compiler/intrinsics/bmi/verifycode/LZcntTestL.java
>>      compiler/intrinsics/bmi/verifycode/TZcntTestL.java
>> 
>> 
>> B) After integration of JDK-8349582, which added APX NDD support, AndN instruction selection patterns that expect (Xor SRC, -1) as one of its operands were not getting selected because of a lower-cost generic immediate pattern match; patch fixes this issue through strict predicate checks.
>> 
>> Above tests are now passing, validations were carried out using Intel Software Development emulator.
>> 
>> Kindly review and share your feedback.
>> 
>> Best Regards,
>> Jatin
>
> Jatin Bhateja has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Update src/hotspot/cpu/x86/x86_64.ad
>   
>   Thanks :-)
>   
>   Co-authored-by: Tobias Hartmann <tobias.hartmann at oracle.com>

@jatin-bhateja Thanks for looking into this!

`predicate(!UseAPX && n->in(2)->bottom_type()->is_int()->get_con() != -1);`

The PR title seems to suggest the bug is only about -XX:+UseAPX. Why are you changing things for the case !UseAPX?

Are these not cases like a ^ -1, which basically flips all bits.
What alternative does this end up using now?

A code comment would be helpful.

src/hotspot/cpu/x86/x86_64.ad line 10620:

> 10618: instruct xorI_rReg_imm(rRegI dst, immI src, rFlagsReg cr)
> 10619: %{
> 10620:   predicate(!UseAPX && n->in(2)->bottom_type()->is_int()->get_con() != -1);

The PR title seems to suggest the bug is only about -XX:+UseAPX. Why are you changing things for the case !UseAPX?

-------------

PR Review: https://git.openjdk.org/jdk/pull/25501#pullrequestreview-2893385310
PR Review Comment: https://git.openjdk.org/jdk/pull/25501#discussion_r2124452416


More information about the hotspot-compiler-dev mailing list