RFR: 8318509: x86 count_positives intrinsic broken for -XX:AVX3Threshold=0

Claes Redestad redestad at openjdk.org
Thu Oct 19 18:03:03 UTC 2023


On Thu, 19 Oct 2023 17:01:28 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:

>> The AVX-512 implementation of count_positives is broken when there are negative values in the tail block, since the len register is repurposed to then re-read as-if it still contained the original value. 
>> 
>> Proposed fix is to restore len from the value in tmp1, which at this point holds the count of bytes in the tail. 
>> 
>> Existing TestCountPositives test is pretty exhaustive and just needs to be run explicitly with AVX3Threshold=0 enabled.
>
> src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp line 3888:
> 
>> 3886:       mov64(tmp3_aliased, 0xFFFFFFFFFFFFFFFF);
>> 3887:       shlxq(tmp3_aliased, tmp3_aliased, tmp1);
>> 3888:       notq(tmp3_aliased);
> 
> We can replace these two instructions with BZHI under BMI2 check.

We probably shouldn't do incremental enhancements in this PR. For code enhancements to make much sense we also need a plan to refactor this so that this AVX-512 version can be enabled in production modes (when/if it makes sense).

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16267#discussion_r1365888630


More information about the hotspot-compiler-dev mailing list