]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
i386: Do not allow pointer conversion for CMPccXADD intrin under -O0
authorHaochen Jiang <haochen.jiang@intel.com>
Fri, 1 Nov 2024 07:59:47 +0000 (15:59 +0800)
committerHaochen Jiang <haochen.jiang@intel.com>
Fri, 1 Nov 2024 18:15:46 +0000 (02:15 +0800)
The pointer conversion to wider type under macro would not consider
whether the higher bit is cleaned or not. It will lead to unexpected
cmp result.

After this change, it will throw an incompatible pointer type error just
like -O2 does currently.

gcc/ChangeLog:

* config/i386/cmpccxaddintrin.h (_cmpccxadd_epi32): Do not do
type conversion for pointer.
(_cmpccxadd_epi64): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/i386/cmpccxadd-1b.c: New test.

gcc/config/i386/cmpccxaddintrin.h
gcc/testsuite/gcc.target/i386/cmpccxadd-1b.c [new file with mode: 0644]

index 39f368ffc082e21692bbea180bcb992ab2be2871..9349fb00c1ba4c02a0fcf45c8b351d046ad65bbb 100644 (file)
@@ -72,11 +72,11 @@ _cmpccxadd_epi64 (long long *__A, long long __B, long long __C,
 }
 #else
 #define _cmpccxadd_epi32(A,B,C,D) \
-  __builtin_ia32_cmpccxadd ((int *) (A), (int) (B), (int) (C), \
+  __builtin_ia32_cmpccxadd ((A), (int) (B), (int) (C), \
                            (_CMPCCX_ENUM) (D))
 #define _cmpccxadd_epi64(A,B,C,D) \
-  __builtin_ia32_cmpccxadd64 ((long long *) (A), (long long) (B), \
-                             (long long) (C), (_CMPCCX_ENUM) (D))
+  __builtin_ia32_cmpccxadd64 ((A), (long long) (B), (long long) (C), \
+                             (_CMPCCX_ENUM) (D))
 #endif
 
 #ifdef __DISABLE_CMPCCXADD__
diff --git a/gcc/testsuite/gcc.target/i386/cmpccxadd-1b.c b/gcc/testsuite/gcc.target/i386/cmpccxadd-1b.c
new file mode 100644 (file)
index 0000000..7d20325
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-options "-O0 -mcmpccxadd" } */
+#include <x86gprintrin.h>
+
+short *a;
+int b, c;
+int *d;
+long long e, f;
+
+void extern
+cmpccxadd_test(void)
+{
+  b = _cmpccxadd_epi32 (a, b, c, _CMPCCX_O); /* { dg-error "incompatible pointer type" } */
+  e = _cmpccxadd_epi64 (d, e, f, _CMPCCX_O); /* { dg-error "incompatible pointer type" } */
+}