Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/crypto Use vshlq_n_s32 rather than vsliq_n_s32 with zero...



details:   https://anonhg.NetBSD.org/src/rev/44353a56d9c6
branches:  trunk
changeset: 1012735:44353a56d9c6
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Aug 09 02:48:38 2020 +0000

description:
Use vshlq_n_s32 rather than vsliq_n_s32 with zero destination.

Not sure why I reached for vsliq_n_s32 at first -- probably so I
wouldn't have to deal with a new intrinsic in arm_neon.h!

diffstat:

 sys/crypto/aes/arch/arm/aes_neon_subr.c |   6 +++---
 sys/crypto/aes/arch/arm/arm_neon.h      |  18 +++++++++++++++++-
 sys/crypto/chacha/arch/arm/arm_neon.h   |  18 +++++++++++++++++-
 3 files changed, 37 insertions(+), 5 deletions(-)

diffs (91 lines):

diff -r 1007567e657c -r 44353a56d9c6 sys/crypto/aes/arch/arm/aes_neon_subr.c
--- a/sys/crypto/aes/arch/arm/aes_neon_subr.c   Sun Aug 09 02:00:57 2020 +0000
+++ b/sys/crypto/aes/arch/arm/aes_neon_subr.c   Sun Aug 09 02:48:38 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aes_neon_subr.c,v 1.6 2020/08/09 02:00:57 riastradh Exp $      */
+/*     $NetBSD: aes_neon_subr.c,v 1.7 2020/08/09 02:48:38 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: aes_neon_subr.c,v 1.6 2020/08/09 02:00:57 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aes_neon_subr.c,v 1.7 2020/08/09 02:48:38 riastradh Exp $");
 
 #ifdef _KERNEL
 #include <sys/systm.h>
@@ -151,7 +151,7 @@
        t = vreinterpretq_s32_u8(t8);
        mask = vcltq_s32(t, zero);              /* -1 if high bit set else 0 */
        mask = vextq_u32(mask, mask, 3);        /* rotate quarters */
-       t_ = vsliq_n_s32(zero, t, 1);           /* shift */
+       t_ = vshlq_n_s32(t, 1);                 /* shift */
        t_ ^= carry & mask;
 
        return vreinterpretq_u8_s32(t_);
diff -r 1007567e657c -r 44353a56d9c6 sys/crypto/aes/arch/arm/arm_neon.h
--- a/sys/crypto/aes/arch/arm/arm_neon.h        Sun Aug 09 02:00:57 2020 +0000
+++ b/sys/crypto/aes/arch/arm/arm_neon.h        Sun Aug 09 02:48:38 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arm_neon.h,v 1.8 2020/08/08 14:47:01 riastradh Exp $   */
+/*     $NetBSD: arm_neon.h,v 1.9 2020/08/09 02:48:38 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -466,6 +466,22 @@
 
 #if defined(__GNUC__) && !defined(__clang__)
 _INTRINSATTR
+static __inline int32x4_t
+vshlq_n_s32(int32x4_t __v, uint8_t __bits)
+{
+#ifdef __aarch64__
+       return (int32x4_t)__builtin_aarch64_ashlv4si(__v, __bits);
+#else
+       return (int32x4_t)__builtin_neon_vshl_nv4si(__v, __bits);
+#endif
+}
+#elif defined(__clang__)
+#define        vshlq_n_s32(__v, __bits)                                              \
+       (int32x4_t)__builtin_neon_vshlq_n_v((int32x4_t)(__v), (__bits), 34)
+#endif
+
+#if defined(__GNUC__) && !defined(__clang__)
+_INTRINSATTR
 static __inline uint32x4_t
 vshlq_n_u32(uint32x4_t __v, uint8_t __bits)
 {
diff -r 1007567e657c -r 44353a56d9c6 sys/crypto/chacha/arch/arm/arm_neon.h
--- a/sys/crypto/chacha/arch/arm/arm_neon.h     Sun Aug 09 02:00:57 2020 +0000
+++ b/sys/crypto/chacha/arch/arm/arm_neon.h     Sun Aug 09 02:48:38 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arm_neon.h,v 1.4 2020/08/08 14:47:01 riastradh Exp $   */
+/*     $NetBSD: arm_neon.h,v 1.5 2020/08/09 02:48:38 riastradh Exp $   */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -466,6 +466,22 @@
 
 #if defined(__GNUC__) && !defined(__clang__)
 _INTRINSATTR
+static __inline int32x4_t
+vshlq_n_s32(int32x4_t __v, uint8_t __bits)
+{
+#ifdef __aarch64__
+       return (int32x4_t)__builtin_aarch64_ashlv4si(__v, __bits);
+#else
+       return (int32x4_t)__builtin_neon_vshl_nv4si(__v, __bits);
+#endif
+}
+#elif defined(__clang__)
+#define        vshlq_n_s32(__v, __bits)                                              \
+       (int32x4_t)__builtin_neon_vshlq_n_v((int32x4_t)(__v), (__bits), 34)
+#endif
+
+#if defined(__GNUC__) && !defined(__clang__)
+_INTRINSATTR
 static __inline uint32x4_t
 vshlq_n_u32(uint32x4_t __v, uint8_t __bits)
 {



Home | Main Index | Thread Index | Old Index