base/asm-common.h, ...: Add missing `cmov' instruction (and `.CC' variants).
authorMark Wooding <mdw@distorted.org.uk>
Tue, 13 Oct 2020 23:15:17 +0000 (00:15 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 13 Oct 2020 23:17:03 +0000 (00:17 +0100)
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
symm/rijndael-arm64-crypto.S

index 18c61fc..323f2e8 100644 (file)
@@ -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)
index 98f6173..df0bb9d 100644 (file)
@@ -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