Module Name:    src
Committed By:   riastradh
Date:           Mon Jul 15 13:59:19 UTC 2024

Modified Files:
        src/sys/crypto/arch/x86: immintrin.h immintrin_ext.h

Log Message:
sys/crypto: Fix mistakes in previous gcc12 immintrin fixes.

Compile-tested the ChaCha code, not the whole kernel, and it turns
out the AES code trips over the mistakes.

PR toolchain/58350


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/crypto/arch/x86/immintrin.h
cvs rdiff -u -r1.1 -r1.2 src/sys/crypto/arch/x86/immintrin_ext.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/crypto/arch/x86/immintrin.h
diff -u src/sys/crypto/arch/x86/immintrin.h:1.2 src/sys/crypto/arch/x86/immintrin.h:1.3
--- src/sys/crypto/arch/x86/immintrin.h:1.2	Mon Jul 15 13:51:10 2024
+++ src/sys/crypto/arch/x86/immintrin.h	Mon Jul 15 13:59:19 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: immintrin.h,v 1.2 2024/07/15 13:51:10 riastradh Exp $	*/
+/*	$NetBSD: immintrin.h,v 1.3 2024/07/15 13:59:19 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -63,6 +63,7 @@ typedef unsigned __v4su __attribute__((_
 typedef float __v4sf __attribute__((__vector_size__(16)));
 typedef short __v8hi __attribute__((__vector_size__(16)));
 typedef char __v16qi __attribute__((__vector_size__(16)));
+typedef char __v16qi_u __attribute__((__vector_size__(16), __aligned__(1)));
 
 #elif defined(__clang__)
 
@@ -133,7 +134,7 @@ static __inline __m128i
 _mm_loadu_si32(const void *__p)
 {
 #if defined(__GNUC__) && !defined(__clang__)
-	int32_t __v = (*(__m32_u *)__p)[0];
+	int32_t __v = (*(const __m32_u *)__p)[0];
 #else
 	int32_t __v = ((const struct { int32_t __v; } _PACKALIAS *)__p)->__v;
 #endif
@@ -145,7 +146,7 @@ static __inline __m128i
 _mm_loadu_si64(const void *__p)
 {
 #if defined(__GNUC__) && !defined(__clang__)
-	int64_t __v = (*(__m64_u *)__p)[0];
+	int64_t __v = (*(const __m64_u *)__p)[0];
 #else
 	int64_t __v = ((const struct { int64_t __v; } _PACKALIAS *)__p)->__v;
 #endif

Index: src/sys/crypto/arch/x86/immintrin_ext.h
diff -u src/sys/crypto/arch/x86/immintrin_ext.h:1.1 src/sys/crypto/arch/x86/immintrin_ext.h:1.2
--- src/sys/crypto/arch/x86/immintrin_ext.h:1.1	Mon Aug  7 01:07:36 2023
+++ src/sys/crypto/arch/x86/immintrin_ext.h	Mon Jul 15 13:59:19 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: immintrin_ext.h,v 1.1 2023/08/07 01:07:36 rin Exp $	*/
+/*	$NetBSD: immintrin_ext.h,v 1.2 2024/07/15 13:59:19 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -35,14 +35,22 @@ _INTRINSATTR
 static __inline __m128i
 _mm_loadu_epi8(const void *__p)
 {
+#if defined(__GNUC__) && !defined(__clang__)
+	return (__m128i)(*(const __v16qi_u *)__p);
+#else
 	return ((const struct { __m128i_u __v; } _PACKALIAS *)__p)->__v;
+#endif
 }
 
 _INTRINSATTR
 static __inline void
 _mm_storeu_epi8(void *__p, __m128i __v)
 {
+#if defined(__GNUC__) && !defined(__clang__)
+	*(__v16qi_u *)__p = (__v16qi_u)__v;
+#else
 	((struct { __m128i_u __v; } _PACKALIAS *)__p)->__v = __v;
+#endif
 }
 
 #endif	/* _SYS_CRYPTO_ARCH_X86_IMMINTRIN_EXT_H */

Reply via email to