[clang] 8cb6b65 - [X86][CFE] Correct parameter type of _cmpccxadd_epi64 (#114367)

via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 1 01:03:32 PDT 2024


Author: Freddy Ye
Date: 2024-11-01T16:03:28+08:00
New Revision: 8cb6b65542591e6bdbd70d94a8ae74b13ab2e5c0

URL: https://github.com/llvm/llvm-project/commit/8cb6b65542591e6bdbd70d94a8ae74b13ab2e5c0
DIFF: https://github.com/llvm/llvm-project/commit/8cb6b65542591e6bdbd70d94a8ae74b13ab2e5c0.diff

LOG: [X86][CFE] Correct parameter type of _cmpccxadd_epi64 (#114367)

This fixes correctness of https://gcc.godbolt.org/z/vexf5fW5r

Added: 
    

Modified: 
    clang/include/clang/Basic/BuiltinsX86_64.def
    clang/lib/Headers/cmpccxaddintrin.h
    clang/test/CodeGen/X86/cmpccxadd-builtins-error.c

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/BuiltinsX86_64.def b/clang/include/clang/Basic/BuiltinsX86_64.def
index 68904ae8abcd15..c343cf81fac01f 100644
--- a/clang/include/clang/Basic/BuiltinsX86_64.def
+++ b/clang/include/clang/Basic/BuiltinsX86_64.def
@@ -150,7 +150,7 @@ TARGET_BUILTIN(__builtin_ia32_tcmmrlfp16ps, "vIUcIUcIUc", "n", "amx-complex")
 
 TARGET_BUILTIN(__builtin_ia32_prefetchi, "vvC*Ui", "nc", "prefetchi")
 TARGET_BUILTIN(__builtin_ia32_cmpccxadd32, "Siv*SiSiIi", "n", "cmpccxadd")
-TARGET_BUILTIN(__builtin_ia32_cmpccxadd64, "SLLiv*SLLiSLLiIi", "n", "cmpccxadd")
+TARGET_BUILTIN(__builtin_ia32_cmpccxadd64, "SLLiSLLi*SLLiSLLiIi", "n", "cmpccxadd")
 
 // AMX_FP16 FP16
 TARGET_BUILTIN(__builtin_ia32_tdpfp16ps, "vIUcIUcIUc", "n", "amx-fp16")

diff  --git a/clang/lib/Headers/cmpccxaddintrin.h b/clang/lib/Headers/cmpccxaddintrin.h
index 6957498996c89b..0076c402f5ffc9 100644
--- a/clang/lib/Headers/cmpccxaddintrin.h
+++ b/clang/lib/Headers/cmpccxaddintrin.h
@@ -63,7 +63,7 @@ typedef enum {
                                     (int)(__D))))
 
 #define _cmpccxadd_epi64(__A, __B, __C, __D)                                   \
-  ((long long)(__builtin_ia32_cmpccxadd64((void *)(__A), (long long)(__B),     \
+  ((long long)(__builtin_ia32_cmpccxadd64((__A), (long long)(__B),             \
                                           (long long)(__C), (int)(__D))))
 
 #endif // __x86_64__

diff  --git a/clang/test/CodeGen/X86/cmpccxadd-builtins-error.c b/clang/test/CodeGen/X86/cmpccxadd-builtins-error.c
index 8d9ca671f30f8f..f7ecf12d0becfa 100644
--- a/clang/test/CodeGen/X86/cmpccxadd-builtins-error.c
+++ b/clang/test/CodeGen/X86/cmpccxadd-builtins-error.c
@@ -10,3 +10,7 @@ int test_cmpccxadd32(void *__A, int __B, int __C) {
 long long test_cmpccxadd64(void *__A, long long __B, long long __C) {
   return _cmpccxadd_epi64(__A, __B, __C, 16); // expected-error {{argument value 16 is outside the valid range [0, 15]}}
 }
+
+long long test_cmpccxadd64_2(int *__A, long long __B, long long __C) {
+  return _cmpccxadd_epi64(__A, __B, __C, 3); // expected-warning {{incompatible pointer types passing 'int *' to parameter of type 'long long *'}}
+}


        


More information about the cfe-commits mailing list