Skip to content

Commit fff2e58

Browse files
author
Hamlin Li
committedDec 19, 2023
8322195: RISC-V: Minor improvement of MD5 instrinsic
Reviewed-by: luhenry, fyang
1 parent 7b4d62c commit fff2e58

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed
 

‎src/hotspot/cpu/riscv/stubGenerator_riscv.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -4155,14 +4155,18 @@ class StubGenerator: public StubCodeGenerator {
41554155

41564156
// to minimize the number of memory operations:
41574157
// read the 4 state 4-byte values in pairs, with a single ld,
4158-
// and split them into 2 registers
4159-
__ mv(t0, mask32);
4158+
// and split them into 2 registers.
4159+
//
4160+
// And, as the core algorithm of md5 works on 32-bits words, so
4161+
// in the following code, it does not care about the content of
4162+
// higher 32-bits in state[x]. Based on this observation,
4163+
// we can apply further optimization, which is to just ignore the
4164+
// higher 32-bits in state0/state2, rather than set the higher
4165+
// 32-bits of state0/state2 to zero explicitly with extra instructions.
41604166
__ ld(state0, Address(state));
41614167
__ srli(state1, state0, 32);
4162-
__ andr(state0, state0, t0);
41634168
__ ld(state2, Address(state, 8));
41644169
__ srli(state3, state2, 32);
4165-
__ andr(state2, state2, t0);
41664170

41674171
Label md5_loop;
41684172
__ BIND(md5_loop);

0 commit comments

Comments
 (0)
Failed to load comments.