RFR: 8357554: Enable vectorization of Bool -> CMove with different type size (on riscv)

Emanuel Peter epeter at openjdk.org
Tue Nov 11 13:56:12 UTC 2025


On Tue, 11 Nov 2025 11:24:12 GMT, Hamlin Li <mli at openjdk.org> wrote:

> Hi,
> 
> Can you help to review this patch?
> 
> This patch enables the vectorization of statement like `op_1 bop op_2 ? res_f_d_1 : res_f_d_2` in a loop, where op_x's size is different from res_f_d_x's.
> 
> To assist with code review, this pr contains only the shared code change, is splitted from https://github.com/openjdk/jdk/pull/28230, which enable & implement the riscv part. The similar optimization could be extended to other platforms. 
> 
> ## Some background
> 
> Previously, it's https://github.com/openjdk/jdk/pull/25336, which was blocked by unsigned comparison issue. The issue was recently resolved by https://github.com/openjdk/jdk/pull/27942, so I'm re-start working on this optimization.
> 
> This pr only relaxes one of the constraints in https://github.com/openjdk/jdk/pull/25336, i.e. transform CMoveF/D to vector operations no matter what's the size of comparison's operator, but remove the optimization of transform CMoveI/L to vector operations which I think need more investigation.
> 
> # Test
> ## Jtreg
> 
> in progress...
> 
> ## Performance
> 
> check the performance data in https://github.com/openjdk/jdk/pull/25341 on riscv.
> 
> Thanks

@Hamlin-Li Thanks for your continued effort on CMove!

Just a first initial comment. And yes, you'll need some IR tests. Would also be nice if we could get some aarch64 or x64 implementation, so we can test it. Maybe we can collaborate on this PR to make it work together :)

src/hotspot/share/opto/superword.cpp line 2339:

> 2337:   } else if (VectorNode::is_different_use_def_size_supported()) {
> 2338:     return use->is_CMove() && def->is_Bool();
> 2339:   }

This looks a little tangled, and harder to extend. Can we make it linear like this?

Suggestion:

  // Input size of use equals output size of def
  if (type2aelembytes(use_bt) == type2aelembytes(def_bt)) {
    return true;
  }

  // Allow CMove to have different type for comparision and moving.
  if (VectorNode::is_different_use_def_size_supported() && return use->is_CMove() && def->is_Bool()) {
    return true;
  }

Because what if `is_different_use_def_size_supported` is true, but we don't have a CMove case, and then we would be able to go on with yet something else below later on?

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

PR Review: https://git.openjdk.org/jdk/pull/28231#pullrequestreview-3448170017
PR Review Comment: https://git.openjdk.org/jdk/pull/28231#discussion_r2514311100


More information about the hotspot-compiler-dev mailing list