[libc-commits] [libc] 310b619 - Revert D137868 "[libc] Fix builtin definition for memory functions"

Fangrui Song via libc-commits libc-commits at lists.llvm.org
Wed Nov 16 14:47:58 PST 2022


Author: Fangrui Song
Date: 2022-11-16T22:47:53Z
New Revision: 310b619e9505c373713e46ed466abd83ffcda3fa

URL: https://github.com/llvm/llvm-project/commit/310b619e9505c373713e46ed466abd83ffcda3fa
DIFF: https://github.com/llvm/llvm-project/commit/310b619e9505c373713e46ed466abd83ffcda3fa.diff

LOG: Revert D137868 "[libc] Fix builtin definition for memory functions"

This reverts commit da5d00ad0cf4d45e38287280c670b08e84e27411.

This caused -Wmacro-redefined
```
.../libc/src/string/memory_utils/op_x86.h:31:9: error: '_mm512_cmpneq_epi8_mask' macro redefined [-Werror,-Wmacro-redefined]
        ^
.../lib/clang/google3-trunk/include/avx512bwintrin.h:294:9: note: previous definition is here
        ^
```

Added: 
    

Modified: 
    libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake
    libc/src/string/CMakeLists.txt
    libc/src/string/memory_utils/op_x86.h

Removed: 
    


################################################################################
diff  --git a/libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake b/libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake
index fdd477c1155ec..358d07480ab80 100644
--- a/libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake
+++ b/libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake
@@ -6,7 +6,7 @@
 set(ALL_CPU_FEATURES "")
 
 if(${LIBC_TARGET_ARCHITECTURE_IS_X86})
-  set(ALL_CPU_FEATURES SSE2 SSE4_2 AVX2 AVX512F AVX512BW FMA)
+  set(ALL_CPU_FEATURES SSE2 SSE4_2 AVX2 AVX512F FMA)
   set(LIBC_COMPILE_OPTIONS_NATIVE -march=native)
 elseif(${LIBC_TARGET_ARCHITECTURE_IS_AARCH64})
   set(LIBC_COMPILE_OPTIONS_NATIVE -mcpu=native)

diff  --git a/libc/src/string/CMakeLists.txt b/libc/src/string/CMakeLists.txt
index 9e8287fe8b938..e300a036655ab 100644
--- a/libc/src/string/CMakeLists.txt
+++ b/libc/src/string/CMakeLists.txt
@@ -355,7 +355,7 @@ if(${LIBC_TARGET_ARCHITECTURE_IS_X86})
   add_bcmp(bcmp_x86_64_opt_sse2   COMPILE_OPTIONS -march=k8             REQUIRE SSE2)
   add_bcmp(bcmp_x86_64_opt_sse4   COMPILE_OPTIONS -march=nehalem        REQUIRE SSE4_2)
   add_bcmp(bcmp_x86_64_opt_avx2   COMPILE_OPTIONS -march=haswell        REQUIRE AVX2)
-  add_bcmp(bcmp_x86_64_opt_avx512 COMPILE_OPTIONS -march=skylake-avx512 REQUIRE AVX512BW)
+  add_bcmp(bcmp_x86_64_opt_avx512 COMPILE_OPTIONS -march=skylake-avx512 REQUIRE AVX512F)
   add_bcmp(bcmp_opt_host          COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
   add_bcmp(bcmp)
 else()
@@ -409,7 +409,7 @@ if(${LIBC_TARGET_ARCHITECTURE_IS_X86})
   add_memcmp(memcmp_x86_64_opt_sse2   COMPILE_OPTIONS -march=k8             REQUIRE SSE2)
   add_memcmp(memcmp_x86_64_opt_sse4   COMPILE_OPTIONS -march=nehalem        REQUIRE SSE4_2)
   add_memcmp(memcmp_x86_64_opt_avx2   COMPILE_OPTIONS -march=haswell        REQUIRE AVX2)
-  add_memcmp(memcmp_x86_64_opt_avx512 COMPILE_OPTIONS -march=skylake-avx512 REQUIRE AVX512BW)
+  add_memcmp(memcmp_x86_64_opt_avx512 COMPILE_OPTIONS -march=skylake-avx512 REQUIRE AVX512F)
   add_memcmp(memcmp_opt_host          COMPILE_OPTIONS ${LIBC_COMPILE_OPTIONS_NATIVE})
   add_memcmp(memcmp)
 elseif(${LIBC_TARGET_ARCHITECTURE_IS_AARCH64})

diff  --git a/libc/src/string/memory_utils/op_x86.h b/libc/src/string/memory_utils/op_x86.h
index a729cf28bbf4b..8e6432233ca31 100644
--- a/libc/src/string/memory_utils/op_x86.h
+++ b/libc/src/string/memory_utils/op_x86.h
@@ -20,22 +20,15 @@
 #include "src/string/memory_utils/op_builtin.h"
 #include "src/string/memory_utils/op_generic.h"
 
-#if defined(__AVX512BW__) || defined(__AVX512F__) || defined(__AVX2__) ||      \
-    defined(__SSE2__)
+#ifdef __SSE2__
 #include <immintrin.h>
-#endif
-
+#else
 // Define fake functions to prevent the compiler from failing on undefined
-// functions in case the CPU extension is not present.
-#ifndef __AVX512BW__
+// functions in case SSE2 is not present.
 #define _mm512_cmpneq_epi8_mask(A, B) 0
-#endif
-#ifndef __AVX2__
-#define _mm256_movemask_epi8(A) 0
-#endif
-#ifndef __SSE2__
 #define _mm_movemask_epi8(A) 0
-#endif
+#define _mm256_movemask_epi8(A) 0
+#endif //  __SSE2__
 
 namespace __llvm_libc::x86 {
 


        


More information about the libc-commits mailing list