diff mbox series

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

Message ID 20201127101812.72787-1-ubizjak@gmail.com
State Accepted
Commit be169fe3cec9efe2bfff98b3f645bca6cc7d09cd
Headers show
Series crypto: x86/poly1305-intel: Use TEST %reg,%reg instead of CMP $0,%reg | expand

Commit Message

Uros Bizjak Nov. 27, 2020, 10:18 a.m. UTC
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).

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
 arch/x86/crypto/poly1305-x86_64-cryptogams.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Herbert Xu Dec. 4, 2020, 7:15 a.m. UTC | #1
On Fri, Nov 27, 2020 at 11:18:12AM +0100, Uros Bizjak wrote:
> 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).

> 

> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>

> Cc: Herbert Xu <herbert@gondor.apana.org.au>

> Cc: Borislav Petkov <bp@alien8.de>

> Cc: "H. Peter Anvin" <hpa@zytor.com>

> ---

>  arch/x86/crypto/poly1305-x86_64-cryptogams.pl | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)


Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
diff mbox series

Patch

diff --git a/arch/x86/crypto/poly1305-x86_64-cryptogams.pl b/arch/x86/crypto/poly1305-x86_64-cryptogams.pl
index 7d568012cc15..71fae5a09e56 100644
--- a/arch/x86/crypto/poly1305-x86_64-cryptogams.pl
+++ b/arch/x86/crypto/poly1305-x86_64-cryptogams.pl
@@ -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);