From 5f49478bd78e79bedb811e93f1f8feea83fc2979 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Wed, 14 Oct 2020 00:15:17 +0100 Subject: [PATCH] base/asm-common.h, ...: Add missing `cmov' instruction (and `.CC' variants). This instruction conditionally moves a value from one register to another, otherwise leaving the destination unchanged: cmov RD, RN, CC == csel RD, RN, RD, CC Also define `cmov.CC' for all condition codes CC. Use this to slightly improve `rijndael_setup_arm64_crypto'. --- base/asm-common.h | 7 ++++++- symm/rijndael-arm64-crypto.S | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/base/asm-common.h b/base/asm-common.h index 18c61fc1..323f2e8f 100644 --- a/base/asm-common.h +++ b/base/asm-common.h @@ -1114,6 +1114,11 @@ name: .macro endprologue .endm +// cmov RD, RN, CC: set RD to RN if CC is satisfied, otherwise do nothing +.macro cmov rd, rn, cc + csel \rd, \rn, \rd, \cc +.endm + // Notational improvement: write `csel.CC' etc., rather than `csel ..., CC'. #define _COND(_) \ _(eq) _(ne) _(cs) _(cc) _(vs) _(vc) _(mi) _(pl) \ @@ -1121,7 +1126,7 @@ name: _(hs) _(lo) #define _INST(_) \ _(ccmp) _(ccmn) \ - _(csel) \ + _(csel) _(cmov) \ _(csinc) _(cinc) _(cset) \ _(csneg) _(cneg) \ _(csinv) _(cinv) _(csetm) diff --git a/symm/rijndael-arm64-crypto.S b/symm/rijndael-arm64-crypto.S index 98f61734..df0bb9d9 100644 --- a/symm/rijndael-arm64-crypto.S +++ b/symm/rijndael-arm64-crypto.S @@ -131,7 +131,7 @@ FUNC(rijndael_setup_arm64_crypto) sub x6, x6, #1 cmp x8, x3 cbz x6, 9f - csel x8, x8, xzr, cc + cmov.cs x8, xzr b 0b // Next job is to construct the decryption keys. The keys for the -- 2.11.0