Skip to contentSkip to conversation

crypto: x86/sha512-intel: Use TEST %reg,%reg instead of CMP $0,%reg

PATCH In review Uros Bizjak 2 participants 2 messages Nov 27, 2020 – Dec 4, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: x86/sha512-intel: Use TEST %reg,%reg instead of CMP $0,%reg

CMP $0,%reg can't set overflow flag, so we can use shorter TEST %reg,%reg instruction when only zero and sign flags are checked (E,L,LE,G,GE conditions).

Cc Herbert Xu <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
---
 arch/x86/crypto/sha512-avx-asm.S   | 2 +-
 arch/x86/crypto/sha512-ssse3-asm.S | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/crypto/sha512-avx-asm.S +1 -1
index 63470fd6ae32..684d58c8bc4f 100644
@@ -278,7 +278,7 @@ frame_size = frame_GPRSAVE + GPRSAVE_SIZE
 # "blocks" is the message length in SHA512 blocks
 ########################################################################
 SYM_FUNC_START(sha512_transform_avx)
-	cmp $0, msglen
+	test msglen, msglen
 	je nowork
 
 	# Allocate Stack Space
arch/x86/crypto/sha512-ssse3-asm.S +1 -1
index 7946a1bee85b..50812af0b083 100644
@@ -280,7 +280,7 @@ frame_size = frame_GPRSAVE + GPRSAVE_SIZE
 ########################################################################
 SYM_FUNC_START(sha512_transform_ssse3)
 
-	cmp $0, msglen
+	test msglen, msglen
 	je nowork
 
 	# Allocate Stack Space
Signature · 1 line
2.26.2
maintainer
#1 lore raw
Quoted 11 lines · Uros Bizjak

CMP $0,%reg can't set overflow flag, so we can use shorter TEST %reg,%reg instruction when only zero and sign flags are checked (E,L,LE,G,GE conditions).

Cc Herbert Xu <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
---
 arch/x86/crypto/sha512-avx-asm.S   | 2 +-
 arch/x86/crypto/sha512-ssse3-asm.S | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt