Skip to contentSkip to conversation

crypto: x86/poly1305-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/poly1305-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/poly1305-x86_64-cryptogams.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/crypto/poly1305-x86_64-cryptogams.pl +1 -1
index 7d568012cc15..71fae5a09e56 100644
@@ -251,7 +251,7 @@ $code.=<<___;
 	mov	%rax,8($ctx)
 	mov	%rax,16($ctx)
 
-	cmp	\$0,$inp
+	test	$inp,$inp
 	je	.Lno_key
 ___
 $code.=<<___ if (!$kernel);
Signature · 1 line
2.26.2
maintainer
#1 lore raw
Quoted 10 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/poly1305-x86_64-cryptogams.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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