Skip to content

Commit 4ed3895

Browse files
committed
Reduce dependency chain.
Change-Id: I63749bfd31917c1924ee559caff987f48dd44374
1 parent 5c15fb8 commit 4ed3895

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/crypto/md5/md5block_amd64.s

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,18 @@ loop:
7171
MOVL DX, R9
7272
MOVL DX, R10
7373

74+
// Uses https://github.com/animetosho/md5-optimisation#dependency-shortcut-in-g-function
75+
7476
#define ROUND2(a, b, c, d, index, const, shift) \
7577
XORL R11, R9; \
7678
ADDL $const, a; \
7779
ADDL R8, a; \
7880
ANDL b, R10; \
7981
ANDL c, R9; \
8082
MOVL (index*4)(SI),R8; \
81-
ORL R9, R10; \
83+
ADDL R9, a; \
84+
ADDL R10, a; \
8285
MOVL c, R9; \
83-
ADDL R10, a; \
8486
MOVL c, R10; \
8587
ROLL $shift, a; \
8688
ADDL b, a
@@ -104,18 +106,30 @@ loop:
104106

105107
MOVL CX, R9
106108

107-
#define ROUND3(a, b, c, d, index, const, shift) \
109+
// Uses https://github.com/animetosho/md5-optimisation#h-function-re-use
110+
111+
#define ROUND3FIRST(a, b, c, d, index, const, shift) \
112+
MOVL d, R9; \
113+
XORL c, R9; \
114+
XORL b, R9; \
108115
ADDL $const, a; \
109116
ADDL R8, a; \
110117
MOVL (index*4)(SI),R8; \
111-
XORL d, R9; \
118+
ADDL R9, a; \
119+
ROLL $shift, a; \
120+
ADDL b, a
121+
122+
#define ROUND3(a, b, c, d, index, const, shift) \
123+
XORL a, R9; \
112124
XORL b, R9; \
125+
ADDL $const, a; \
126+
ADDL R8, a; \
127+
MOVL (index*4)(SI),R8; \
113128
ADDL R9, a; \
114129
ROLL $shift, a; \
115-
MOVL b, R9; \
116130
ADDL b, a
117131

118-
ROUND3(AX,BX,CX,DX, 8,0xfffa3942, 4);
132+
ROUND3FIRST(AX,BX,CX,DX, 8,0xfffa3942, 4);
119133
ROUND3(DX,AX,BX,CX,11,0x8771f681,11);
120134
ROUND3(CX,DX,AX,BX,14,0x6d9d6122,16);
121135
ROUND3(BX,CX,DX,AX, 1,0xfde5380c,23);

0 commit comments

Comments
 (0)