RFR: 8356159: RISC-V: Add Zabha [v11]
Feilong Jiang
fjiang at openjdk.org
Tue Jun 3 13:24:56 UTC 2025
On Tue, 3 Jun 2025 13:14:26 GMT, Robbin Ehn <rehn at openjdk.org> wrote:
>> Looks like `UseZabha` relies on `UseZacas`? The following code will call `atomic_cas` only when `UseZacas` is true even if the size is `int8` or `int16`. If that is true (maybe `(UseZacas && UseZabha)` already explained), then it makes sense.
>>
>> https://github.com/openjdk/jdk/blob/78a392aa3b0cda52cfacfa15250fa61010519424/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp#L4019-L4031
>
> You can't use that method for int8/int16 if you don't have UseZabha (and Zacas).
> You must call the cmpxchg_narrow().
>
> The reason why we have two different method is the number of registers needed, i.e. cmpxchg_narrow requires scratch registers.
>
> So when you don't have UseZabha you should not be calling this method at all for int8/int16.
>
> There is an assert above that checks:
> `assert((UseZacas && UseZabha) || (size != int8 && size != int16), "unsupported operand size");`
>
> The relationship is:
>
> UseZacas=false and UseZabha=false => LR/SC and narrow LR/SC for sub word size.
> UseZacas=true and UseZabha=false => amocas and narrow amocas for sub word size.
> UseZacas=false and UseZabha=true => LR/SC and narrow LR/SC for sub word size.
> UseZacas=true and UseZabha=true => amocas and amocas for sub word size.
>
>
> There is no LR/SC for sub word sizes, int8/int16, thus without Zacas they always use narrow LR/SC.
Ah, I missed `(size != int8 && size != int16)` assertion. So it should be fine, thanks!
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25252#discussion_r2123799385
More information about the hotspot-dev
mailing list