[libc-commits] [PATCH] D137868: [libc] Fix builtin definition for memory functions

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Nov 14 14:16:05 PST 2022


michaelrj updated this revision to Diff 475273.
michaelrj marked an inline comment as done.
michaelrj added a comment.

add AVX512BW to the list of features to be checked and move to simpler redefinitions for the builtins.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137868/new/

https://reviews.llvm.org/D137868

Files:
  libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake
  libc/src/string/memory_utils/op_x86.h


Index: libc/src/string/memory_utils/op_x86.h
===================================================================
--- libc/src/string/memory_utils/op_x86.h
+++ libc/src/string/memory_utils/op_x86.h
@@ -20,15 +20,21 @@
 #include "src/string/memory_utils/op_builtin.h"
 #include "src/string/memory_utils/op_generic.h"
 
-#ifdef __SSE2__
+#if defined(__AVX512BW__) || defined(__AVX2__) || defined(__SSE2__)
 #include <immintrin.h>
-#else
+#endif
+
 // Define fake functions to prevent the compiler from failing on undefined
-// functions in case SSE2 is not present.
+// functions in case the builtin is not present.
+#ifndef _mm512_cmpneq_epi8_mask
 #define _mm512_cmpneq_epi8_mask(A, B) 0
-#define _mm_movemask_epi8(A) 0
+#endif
+#ifndef _mm256_movemask_epi8
 #define _mm256_movemask_epi8(A) 0
-#endif //  __SSE2__
+#endif
+#ifndef _mm_movemask_epi8
+#define _mm_movemask_epi8(A) 0
+#endif
 
 namespace __llvm_libc::x86 {
 
Index: libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake
===================================================================
--- libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake
+++ 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 FMA)
+  set(ALL_CPU_FEATURES SSE2 SSE4_2 AVX2 AVX512F AVX512BW FMA)
   set(LIBC_COMPILE_OPTIONS_NATIVE -march=native)
 elseif(${LIBC_TARGET_ARCHITECTURE_IS_AARCH64})
   set(LIBC_COMPILE_OPTIONS_NATIVE -mcpu=native)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137868.475273.patch
Type: text/x-patch
Size: 1503 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20221114/56323f50/attachment.bin>


More information about the libc-commits mailing list