[PATCH] i386: Keep _ep[i|u]{32, 64} names of scalar SAT CVT intrinsics [PR126581]

"Hu, Lin1" <[email protected]> Mon, 3 Aug 2026 15:16:02 +0800
Newsgroups gmane.comp.gcc.patches
Message-ID <[email protected]>
r16-9456 renamed the AVX10.2 scalar SAT CVT intrinsics to the _[i|u]{32,64}
suffix and was backported to releases/gcc-15 and releases/gcc-16.
Within a release series the old names have to keep working, so add them
back as aliases.

gcc/ChangeLog:

	PR target/126581
	* config/i386/avx10_2satcvtintrin.h
	(_mm_cvtts_sd_epi32): New alias of _mm_cvtts_sd_i32.
	(_mm_cvtts_sd_epu32): New alias of _mm_cvtts_sd_u32.
	(_mm_cvtts_ss_epi32): New alias of _mm_cvtts_ss_i32.
	(_mm_cvtts_ss_epu32): New alias of _mm_cvtts_ss_u32.
	(_mm_cvtts_roundsd_epi32): New alias of _mm_cvtts_roundsd_i32.
	(_mm_cvtts_roundsd_epu32): New alias of _mm_cvtts_roundsd_u32.
	(_mm_cvtts_roundss_epi32): New alias of _mm_cvtts_roundss_i32.
	(_mm_cvtts_roundss_epu32): New alias of _mm_cvtts_roundss_u32.
	(_mm_cvtts_sd_epi64): New alias of _mm_cvtts_sd_i64.
	(_mm_cvtts_sd_epu64): New alias of _mm_cvtts_sd_u64.
	(_mm_cvtts_ss_epi64): New alias of _mm_cvtts_ss_i64.
	(_mm_cvtts_ss_epu64): New alias of _mm_cvtts_ss_u64.
	(_mm_cvtts_roundsd_epi64): New alias of _mm_cvtts_roundsd_i64.
	(_mm_cvtts_roundsd_epu64): New alias of _mm_cvtts_roundsd_u64.
	(_mm_cvtts_roundss_epi64): New alias of _mm_cvtts_roundss_i64.
	(_mm_cvtts_roundss_epu64): New alias of _mm_cvtts_roundss_u64.

gcc/testsuite/ChangeLog:

	PR target/126581
	* gcc.target/i386/pr126581-1.c: New test.
---
 gcc/config/i386/avx10_2satcvtintrin.h      | 131 +++++++++++++++++++++
 gcc/testsuite/gcc.target/i386/pr126581-1.c |  65 ++++++++++
 2 files changed, 196 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr126581-1.c

diff --git a/gcc/config/i386/avx10_2satcvtintrin.h b/gcc/config/i386/avx10_2satcvtintrin.h
index f202ec862c9..3c323c9a52e 100644
--- a/gcc/config/i386/avx10_2satcvtintrin.h
+++ b/gcc/config/i386/avx10_2satcvtintrin.h
@@ -3013,6 +3013,137 @@ _mm_cvtts_roundss_u64 (__m128 __A, const int __R)
 #endif
 #endif /* __x86_64__ */
 
+/* The scalar SAT CVT intrinsics were originally named with an _ep[i|u]{32,64}
+   suffix, which is reserved for packed elements.  Keep the original names as
+   aliases.  */
+extern __inline int
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvtts_sd_epi32 (__m128d __A)
+{
+  return _mm_cvtts_sd_i32 (__A);
+}
+
+extern __inline unsigned int
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvtts_sd_epu32 (__m128d __A)
+{
+  return _mm_cvtts_sd_u32 (__A);
+}
+
+extern __inline int
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvtts_ss_epi32 (__m128 __A)
+{
+  return _mm_cvtts_ss_i32 (__A);
+}
+
+extern __inline unsigned int
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvtts_ss_epu32 (__m128 __A)
+{
+  return _mm_cvtts_ss_u32 (__A);
+}
+
+#ifdef __OPTIMIZE__
+extern __inline int
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvtts_roundsd_epi32 (__m128d __A, const int __R)
+{
+  return _mm_cvtts_roundsd_i32 (__A, __R);
+}
+
+extern __inline unsigned int
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvtts_roundsd_epu32 (__m128d __A, const int __R)
+{
+  return _mm_cvtts_roundsd_u32 (__A, __R);
+}
+
+extern __inline int
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvtts_roundss_epi32 (__m128 __A, const int __R)
+{
+  return _mm_cvtts_roundss_i32 (__A, __R);
+}
+
+extern __inline unsigned int
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvtts_roundss_epu32 (__m128 __A, const int __R)
+{
+  return _mm_cvtts_roundss_u32 (__A, __R);
+}
+#else
+#define _mm_cvtts_roundsd_epi32(A, R) _mm_cvtts_roundsd_i32 ((A), (R))
+#define _mm_cvtts_roundsd_epu32(A, R) _mm_cvtts_roundsd_u32 ((A), (R))
+#define _mm_cvtts_roundss_epi32(A, R) _mm_cvtts_roundss_i32 ((A), (R))
+#define _mm_cvtts_roundss_epu32(A, R) _mm_cvtts_roundss_u32 ((A), (R))
+#endif
+
+#ifdef __x86_64__
+extern __inline long long
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvtts_sd_epi64 (__m128d __A)
+{
+  return _mm_cvtts_sd_i64 (__A);
+}
+
+extern __inline unsigned long long
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvtts_sd_epu64 (__m128d __A)
+{
+  return _mm_cvtts_sd_u64 (__A);
+}
+
+extern __inline long long
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvtts_ss_epi64 (__m128 __A)
+{
+  return _mm_cvtts_ss_i64 (__A);
+}
+
+extern __inline unsigned long long
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvtts_ss_epu64 (__m128 __A)
+{
+  return _mm_cvtts_ss_u64 (__A);
+}
+
+#ifdef __OPTIMIZE__
+extern __inline long long
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvtts_roundsd_epi64 (__m128d __A, const int __R)
+{
+  return _mm_cvtts_roundsd_i64 (__A, __R);
+}
+
+extern __inline unsigned long long
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvtts_roundsd_epu64 (__m128d __A, const int __R)
+{
+  return _mm_cvtts_roundsd_u64 (__A, __R);
+}
+
+extern __inline long long
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvtts_roundss_epi64 (__m128 __A, const int __R)
+{
+  return _mm_cvtts_roundss_i64 (__A, __R);
+}
+
+extern __inline unsigned long long
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm_cvtts_roundss_epu64 (__m128 __A, const int __R)
+{
+  return _mm_cvtts_roundss_u64 (__A, __R);
+}
+#else
+#define _mm_cvtts_roundsd_epi64(A, R) _mm_cvtts_roundsd_i64 ((A), (R))
+#define _mm_cvtts_roundsd_epu64(A, R) _mm_cvtts_roundsd_u64 ((A), (R))
+#define _mm_cvtts_roundss_epi64(A, R) _mm_cvtts_roundss_i64 ((A), (R))
+#define _mm_cvtts_roundss_epu64(A, R) _mm_cvtts_roundss_u64 ((A), (R))
+#endif
+#endif /* __x86_64__ */
+
 #ifdef __DISABLE_AVX10_2__
 #undef __DISABLE_AVX10_2__
 #pragma GCC pop_options
diff --git a/gcc/testsuite/gcc.target/i386/pr126581-1.c b/gcc/testsuite/gcc.target/i386/pr126581-1.c
new file mode 100644
index 00000000000..dd254c2faf1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr126581-1.c
@@ -0,0 +1,65 @@
+/* PR target/126581  */
+/* { dg-do compile { target { *-*-linux* && lp64 } } } */
+/* { dg-options "-O2 -march=x86-64-v4 -mavx10.2 -Wno-deprecated-declarations" } */
+/* { dg-final { scan-assembler-times "vcvttss2usis\[ \t]*%xmm0, %eax" 1 } } */
+/* { dg-final { scan-assembler-times "vcvttss2usis\[ \t]*\{sae\}, %xmm0, %eax" 1 } } */
+/* { dg-final { scan-assembler-times "vcvttss2sis\[ \t]*%xmm0, %eax" 1 } } */
+/* { dg-final { scan-assembler-times "vcvttss2sis\[ \t]*\{sae\}, %xmm0, %eax" 1 } } */
+/* { dg-final { scan-assembler-times "vcvttsd2usis\[ \t]*%xmm0, %eax" 1 } } */
+/* { dg-final { scan-assembler-times "vcvttsd2usis\[ \t]*\{sae\}, %xmm0, %eax" 1 } } */
+/* { dg-final { scan-assembler-times "vcvttsd2sis\[ \t]*%xmm0, %eax" 1 } } */
+/* { dg-final { scan-assembler-times "vcvttsd2sis\[ \t]*\{sae\}, %xmm0, %eax" 1 } } */
+
+#include <x86intrin.h>
+
+unsigned long long
+func1 (__m128 x)
+{
+  return _mm_cvtts_ss_epu32 (x);
+}
+
+unsigned long long
+func2 (__m128 x)
+{
+  return _mm_cvtts_roundss_epu32
+    (x, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC);
+}
+
+unsigned long long
+func3 (__m128 x)
+{
+  return (unsigned int) _mm_cvtts_ss_epi32 (x);
+}
+
+unsigned long long
+func4 (__m128 x)
+{
+  return (unsigned int) _mm_cvtts_roundss_epi32
+    (x, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC);
+}
+
+unsigned long long
+func5 (__m128d x)
+{
+  return _mm_cvtts_sd_epu32 (x);
+}
+
+unsigned long long
+func6 (__m128d x)
+{
+  return _mm_cvtts_roundsd_epu32
+    (x, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC);
+}
+
+unsigned long long
+func7 (__m128d x)
+{
+  return (unsigned int) _mm_cvtts_sd_epi32 (x);
+}
+
+unsigned long long
+func8 (__m128d x)
+{
+  return (unsigned int) _mm_cvtts_roundsd_epi32
+    (x, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC);
+}
-- 
2.31.1