RFR: 8319716: RISC-V: Add SHA-2

Robbin Ehn rehn at openjdk.org
Mon Nov 20 16:03:26 UTC 2023


On Wed, 15 Nov 2023 07:34:22 GMT, Fei Yang <fyang at openjdk.org> wrote:

>> Hi, please consider.
>> 
>> Main author is @luhenry, I only fixed some minor things and tested it.
>> 
>> Such as:
>> test/hotspot/jtreg/compiler/intrinsics/sha/
>> test/jdk/java/security/MessageDigest/
>> test/jdk/jdk/security/
>> tier1
>> 
>> And still running some test.
>
> src/hotspot/cpu/riscv/stubGenerator_riscv.cpp line 3769:
> 
>> 3767:     __ vslidedown_vi(v16, v27, 2);                   // v16 = {_,_,e,f}
>> 3768:     // Merge elements [3..2] of v26 ({a,b}) into elements [3..2] of v16
>> 3769:     __ vmerge_vvm(v16, v26, v16);                    // v16 = {a,b,e,f}
> 
> I see the openssl version makes use of index-load to get {f,e,b,a},{h,g,d,c} pre-loop and index-store to put {f,e,b,a},{h,g,d,c} back to {a,b,c,d},{e,f,g,h} post-loop, which is much simpler than this code. Please consider.
> 
> [1] https://github.com/openssl/openssl/blob/master/crypto/sha/asm/sha256-riscv64-zvkb-zvknha_or_zvknhb.pl#L124-L142

The vsetivli is often expensive:ish,  the code in openssl sets it five times before reaching first round.
That don't seem like a good idea, now vsetivli make the code much easier to read yes...

I guess I need to check numbers for that also.. :)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16562#discussion_r1399418241


More information about the hotspot-dev mailing list