From 0e1fc52851be58fe4a06410556f62da47154c3c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Sat, 28 Nov 2020 14:24:43 +0100
Subject: [PATCH] ppc: Use vaddcuw instruction.

---
 ChangeLog                     | 3 +++
 powerpc64/p7/chacha-2core.asm | 4 +---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 76597950..82de3a48 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2020-11-28  Niels Möller  <nisse@lysator.liu.se>
 
+	* powerpc64/p7/chacha-2core.asm: Simplify counter carry handling
+	using the vaddcuw instruction.
+
 	Merge changes by Marco Bodrato and Torbjorn Granlund, from the
 	gmp/mini-gmp copy of this file.
 	* run-tests: Delete special handling of zero arguments. Update
diff --git a/powerpc64/p7/chacha-2core.asm b/powerpc64/p7/chacha-2core.asm
index 265918b6..4d4f4906 100644
--- a/powerpc64/p7/chacha-2core.asm
+++ b/powerpc64/p7/chacha-2core.asm
@@ -73,9 +73,7 @@ PROLOGUE(_nettle_chacha_2core)
 
 	lxvw4x	VSR(X3), r8, SRC
 
-	vsubuwm	X0, X0, X1	C {-1,0,...,0}
-	vcmpequw Y3, X3, X0
-	vand	Y3, Y3, X1	C Counter carry out
+	vaddcuw	Y3, X3, X1	C Counter carry out
 	vsldoi	Y3, Y3, Y3, 12
 	vor	Y3, Y3, X1
 
-- 
GitLab