RFR: 8370454: C2 SuperWord: unsigned comparison information is lost for VectorMaskCmp
    Emanuel Peter 
    epeter at openjdk.org
       
    Thu Oct 23 05:42:02 UTC 2025
    
    
  
On Wed, 22 Oct 2025 20:48:17 GMT, Hamlin Li <mli at openjdk.org> wrote:
> Hi,
> Can you help to review the patch? @eme64 
> 
> Currently, in SLP if we support transformation from (Bool + CmpU + CMove) to (VectorMaskCmp + VectorBlend), the unsigned comparison information is lost, it's in CmpU, but current code only check Bool for the information. For details please check code at `SuperWordVTransformBuilder::make_vector_vtnode_for_pack` and `PackSet::get_bool_test`.
> 
> This loss of unsigned comparison information blocks the optimization proposed in https://github.com/openjdk/jdk/pull/25336 and https://github.com/openjdk/jdk/pull/25341.
> 
> Currently, `BoolTest` does not support an unsigned construction (`BoolTest( mask btm ) : _test(btm) { assert((btm & unsigned_compare) == 0, "unsupported");}`), seems to me a feasible solution would be get the unsigned information from CmpU (which could be an input of Bool) and pass it to VectorMaskCmp.
> 
> Thanks
@Hamlin-Li That looks like a great improvement :)
All I am missing are some test cases. And if possible: IR rules 😉
src/hotspot/share/opto/superword.cpp line 1704:
> 1702:                      cmp0->Opcode() == Op_CmpUL ||
> 1703:                      cmp0->Opcode() == Op_CmpU3 ||
> 1704:                      cmp0->Opcode() == Op_CmpUL3;
Maybe it is time to create a `switch` statement below ;)
src/hotspot/share/opto/superword.cpp line 1751:
> 1749:     }
> 1750:   } else if (is_unsigned) {
> 1751:     mask = BoolTest::unsigned_mask(mask);
This means more cases could now vectorize. Do we have good test cases for this? We should be able to get IR tests for this, right? Do x86 or aarch64 backends (or other platforms) not already have vector instructions for this?
-------------
PR Review: https://git.openjdk.org/jdk/pull/27942#pullrequestreview-3368300725
PR Review Comment: https://git.openjdk.org/jdk/pull/27942#discussion_r2453970205
PR Review Comment: https://git.openjdk.org/jdk/pull/27942#discussion_r2453971569
    
    
More information about the hotspot-compiler-dev
mailing list