RFR: 8297753: AArch64: Add optimized rules for vector compare with zero on NEON [v6]

Andrew Haley aph at openjdk.org
Thu Feb 23 11:05:19 UTC 2023


On Mon, 20 Feb 2023 10:21:50 GMT, Chang Peng <duke at openjdk.org> wrote:

>> We can use the compare-with-zero instructions like cmgt(zero)[1] immediately to avoid the extra scalar2vector operations.
>> 
>> The following instruction sequence
>> 
>> movi  v16.4s, #0x0
>> cmgt  v16.4s, v17.4s, v16.4s
>> 
>> can be optimized to:
>> 
>> cmgt v16.4s, v17.4s, #0x0
>> 
>> This patch does the following:
>> 1. Add NEON floating-point compare-with-zero instructions.
>> 2. Add optimized match rules to generate the compare-with-zero instructions.
>> 
>> [1]: https://developer.arm.com/documentation/ddi0602/2022-06/SIMD-FP-Instructions/CMGT--zero---Compare-signed-Greater-than-zero--vector--
>
> Chang Peng has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Remove some switch-case stmts in c2_MacroAssembler_aarch64.cpp and avoid
>    unsigned comparison.
>  - Revert "Remove switch-case stmts in c2_MacroAssembler_aarch64.cpp"
>    
>    This reverts commit d899238d0cb98fdf375b3011670495c3bfe8bbaf.

src/hotspot/cpu/aarch64/aarch64.ad line 1197:

> 1195:   // Convert BootTest condition to Assembler condition.
> 1196:   // Replicate the logic of cmpOpOper::ccode() and cmpOpUOper::ccode().
> 1197:   Assembler::Condition booltest_cond_to_assembler_cond(BoolTest::mask cond);

Suggestion:

  Assembler::Condition to_assembler_cond(BoolTest::mask cond);
``` ...because we already know the type of the arg.

src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp line 983:

> 981:       case Assembler::GT: cmgt(dst, size, src); break;
> 982:       case Assembler::LE: cmle(dst, size, src); break;
> 983:       case Assembler::LT: cmlt(dst, size, src); break;

Suggestion:

    switch (cond) {
      case Assembler::NE: {
        cm(EQ, dst, size, src);
        notr(dst, isQ ? T16B : T8B, dst);
        break;
      }
      case Assembler::EQ: 
      case Assembler::GE: 
      case Assembler::GT: 
      case Assembler::LE: 
      case Assembler::LT: cm(cond, dst, size, src); break;
``` ...etc.

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

PR: https://git.openjdk.org/jdk/pull/11822


More information about the hotspot-compiler-dev mailing list