RFR: 8353600: RISC-V: compiler/vectorization/TestRotateByteAndShortVector.java is failing with Zvbb [v3]

Hamlin Li mli at openjdk.org
Thu Apr 3 13:49:05 UTC 2025


> Hi,
> Can you help to review this patch?
> 
> Currently, the followign code is considered an RotateLeftV of byte by hotspot, but it's not a real rotate, as the `-shift` will 30, which makes `b >> -shift` zero, rather the value we expected.
> 
> int shift = 2;
> byte b = 83;
> byte res = (byte) (b << shift | b >> -shift); // res = 76
> // but a real left rotate of 83 should be 77 ??
> ``` 
> 
> So, the simple fix is to enable RotateLeftV only for  int and long, disable it for other types.
> 
> <del>A more rational fix should be change C2 to not convert code like ` (byte) (b << shift | b >> -shift)` to a RotateLeftV node, but it needs more investigation, and I'm not sure if it's feasible to do so, as currently no platform support RotateLeftV for non-int/long types.</del>
> 
> The vector instruction behaviour is different from java language spec, so seems there is no way to do it for now.
> 
> Thanks!

Hamlin Li has updated the pull request incrementally with one additional commit since the last revision:

  comment

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/24414/files
  - new: https://git.openjdk.org/jdk/pull/24414/files/fa5e7375..592d4270

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=24414&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=24414&range=01-02

  Stats: 5 lines in 1 file changed: 4 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/24414.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/24414/head:pull/24414

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


More information about the hotspot-compiler-dev mailing list