RFR: 8356159: RISC-V: Add Zabha [v10]

Fei Yang fyang at openjdk.org
Thu May 29 02:33:54 UTC 2025


On Wed, 28 May 2025 07:36:40 GMT, Robbin Ehn <rehn at openjdk.org> wrote:

>> Hi, please consider.
>> 
>> This adds the byte and halfword atomic memory operations (Zabha) - https://github.com/riscv/riscv-zabha.
>> All amo-instructions, except load-reserve and store-conditional, can also be performed on natural aligned half-words and bytes. (i.e. the extension do not add lr.h/b or sc.h/b) This includes amocas if zacas extension is present.
>> 
>> The majority of this patch is to support amocas.h/b. We are now starting to really feel the pain of all these extensions, as CAS:ing 16/8-bits can now be done in three different ways:
>> - lr.w/sc.w 'narrow' CAS (no extension)
>> - amocas.w 'narrow' CAS (Zacas)
>> - amocas.h/b (Zacas + Zabha)
>> 
>> There is no hwprobe support yet.
>> 
>> Ran t1-3 with Zacas+Zabha and t1 without Zabha in qemu.
>> 
>> Thanks, Robbin
>
> Robbin Ehn has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 18 additional commits since the last revision:
> 
>  - Merge branch 'master' into 8356159
>  - ins cost fixes, print fixes
>  - Merge branch 'master' into 8356159
>  - Reg limits fixed
>  - Merge branch 'master' into 8356159
>  - Fixed reg selection
>  - More indention
>  - Indention
>  - Merge branch 'master' into 8356159
>  - Review comments
>  - ... and 8 more: https://git.openjdk.org/jdk/compare/12e113cc...4e572ee2

Latest version looks good to me. Thanks for the update.

src/hotspot/cpu/riscv/riscv.ad line 5315:

> 5313:   match(Set res (CompareAndSwapI mem (Binary oldval newval)));
> 5314: 
> 5315:   // TODO: If UseZacas use "2 * VOLATILE_REF_COST"

I see the aarch64 counterpart always use a cost of `2 * VOLATILE_REF_COST` [1][2][3], thus does not depend on `UseLSE`. I think maybe we can ignore `UseZacas` and alway use `2 * VOLATILE_REF_COST` to simply the case as well.

[1] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/aarch64/aarch64.ad#L8360
[2] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/aarch64/aarch64.ad#L3311
[3] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp#L3466

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

Marked as reviewed by fyang (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/25252#pullrequestreview-2876874206
PR Review Comment: https://git.openjdk.org/jdk/pull/25252#discussion_r2113058204


More information about the hotspot-dev mailing list