]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Instruction Reordering Further Optimizes OpenSSL SHA256 Performance on RISC-V
authorzhoulu <zhou.lu1@zte.com.cn>
Fri, 26 Sep 2025 10:43:08 +0000 (18:43 +0800)
committerTomas Mraz <tomas@openssl.org>
Mon, 10 Nov 2025 19:40:26 +0000 (20:40 +0100)
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28673)

crypto/sha/asm/sha256-riscv64-zvkb-zvknha_or_zvknhb.pl

index 5e4d6be345741ff0a77f31bff240df799d73fc3a..74fc9a7555e3c638facaf5f174a9b7b6788a2947 100644 (file)
@@ -117,9 +117,11 @@ $code .= <<___;
 .globl sha256_block_data_order_zvkb_zvknha_or_zvknhb
 .type   sha256_block_data_order_zvkb_zvknha_or_zvknhb,\@function
 sha256_block_data_order_zvkb_zvknha_or_zvknhb:
-    @{[vsetivli "zero", 4, "e32", "m1", "ta", "ma"]}
 
-    @{[sha_256_load_constant]}
+    # Setup v0 mask for the vmerge to replace the first word (idx==0) in key-scheduling.
+    # The AVL is 4 in SHA, so we could use a single e8(8 element masking) for masking.
+    @{[vsetivli "zero", 1, "e8", "m1", "ta", "ma"]}
+    @{[vmv_v_i $V0, 0x01]}
 
     # H is stored as {a,b,c,d},{e,f,g,h}, but we need {f,e,b,a},{h,g,d,c}
     # The dst vtype is e32m1 and the index vtype is e8mf4.
@@ -141,12 +143,7 @@ sha256_block_data_order_zvkb_zvknha_or_zvknhb:
     @{[vluxei8_v $V6, $H, $V26]}
     @{[vluxei8_v $V7, $H2, $V26]}
 
-    # Setup v0 mask for the vmerge to replace the first word (idx==0) in key-scheduling.
-    # The AVL is 4 in SHA, so we could use a single e8(8 element masking) for masking.
-    @{[vsetivli "zero", 1, "e8", "m1", "ta", "ma"]}
-    @{[vmv_v_i $V0, 0x01]}
-
-    @{[vsetivli "zero", 4, "e32", "m1", "ta", "ma"]}
+    @{[sha_256_load_constant]}
 
 L_round_loop:
     # Decrement length by 1