summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@iki.fi>2023-03-14 19:20:09 +0200
committerJussi Kivilinna <jussi.kivilinna@iki.fi>2023-03-19 21:59:02 +0200
commit79a79d3dc6268f4d72597f7db6c83511dbbef645 (patch)
tree0531182f4509fe0b3898c815b3838531459dd912
parent3c98ae9cb60a8a72d3fa6641e59775f98ec78786 (diff)
downloadlibgcrypt-79a79d3dc6268f4d72597f7db6c83511dbbef645.tar.gz
camellia-simd128: use 8-bit right shift for rotate function
* cipher/camellia-simd128.h (rol32_1_16): Use vpsrlb128 for uint8 right shift by 7 if available. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
-rw-r--r--cipher/camellia-simd128.h20
1 files changed, 12 insertions, 8 deletions
diff --git a/cipher/camellia-simd128.h b/cipher/camellia-simd128.h
index 6b44961f..ed26afb7 100644
--- a/cipher/camellia-simd128.h
+++ b/cipher/camellia-simd128.h
@@ -593,23 +593,27 @@ static const uint8x16_t shift_row =
* v0..3: (IN <<< 1)
*/
#define rol32_1_16(v0, v1, v2, v3, t0, t1, t2, zero) \
- vpcmpgtb128(v0, zero, t0); \
+ if_vpsrlb128(vpsrlb128(7, v0, t0)); \
+ if_not_vpsrlb128(vpcmpgtb128(v0, zero, t0)); \
vpaddb128(v0, v0, v0); \
- vpabsb128(t0, t0); \
+ if_not_vpsrlb128(vpabsb128(t0, t0)); \
\
- vpcmpgtb128(v1, zero, t1); \
+ if_vpsrlb128(vpsrlb128(7, v1, t1)); \
+ if_not_vpsrlb128(vpcmpgtb128(v1, zero, t1)); \
vpaddb128(v1, v1, v1); \
- vpabsb128(t1, t1); \
+ if_not_vpsrlb128(vpabsb128(t1, t1)); \
\
- vpcmpgtb128(v2, zero, t2); \
+ if_vpsrlb128(vpsrlb128(7, v2, t2)); \
+ if_not_vpsrlb128(vpcmpgtb128(v2, zero, t2)); \
vpaddb128(v2, v2, v2); \
- vpabsb128(t2, t2); \
+ if_not_vpsrlb128(vpabsb128(t2, t2)); \
\
vpor128(t0, v1, v1); \
\
- vpcmpgtb128(v3, zero, t0); \
+ if_vpsrlb128(vpsrlb128(7, v3, t0)); \
+ if_not_vpsrlb128(vpcmpgtb128(v3, zero, t0)); \
vpaddb128(v3, v3, v3); \
- vpabsb128(t0, t0); \
+ if_not_vpsrlb128(vpabsb128(t0, t0)); \
\
vpor128(t1, v2, v2); \
vpor128(t2, v3, v3); \