-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc] change PREFER_GENERIC to EXPLICIT_SIMD_OPT #79486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
SchrodingerZhu
merged 3 commits into
llvm:main
from
SchrodingerZhu:libc/change-simd-control-style
Jan 27, 2024
Merged
[libc] change PREFER_GENERIC to EXPLICIT_SIMD_OPT #79486
SchrodingerZhu
merged 3 commits into
llvm:main
from
SchrodingerZhu:libc/change-simd-control-style
Jan 27, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-libc Author: Schrodinger ZHU Yifan (SchrodingerZhu) Changesfixes #79474. Full diff: https://github.com/llvm/llvm-project/pull/79486.diff 4 Files Affected:
diff --git a/libc/cmake/modules/LLVMLibCFlagRules.cmake b/libc/cmake/modules/LLVMLibCFlagRules.cmake
index 7d663f0682e1f25..3e0776e04596c97 100644
--- a/libc/cmake/modules/LLVMLibCFlagRules.cmake
+++ b/libc/cmake/modules/LLVMLibCFlagRules.cmake
@@ -134,7 +134,7 @@ set(FMA_OPT_FLAG "FMA_OPT")
set(ROUND_OPT_FLAG "ROUND_OPT")
# This flag will define macros that gated away vectorization code such that
# one can always test the fallback generic code path.
-set(PREFER_GENERIC_FLAG "PREFER_GENERIC")
+set(EXPLICIT_SIMD_OPT_FLAG "EXPLICIT_SIMD_OPT")
# Skip FMA_OPT flag for targets that don't support fma.
if(NOT((LIBC_TARGET_ARCHITECTURE_IS_X86 AND (LIBC_CPU_FEATURES MATCHES "FMA")) OR
diff --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake b/libc/cmake/modules/LLVMLibCObjectRules.cmake
index 667d7548f783163..c5c9f7c09a144bb 100644
--- a/libc/cmake/modules/LLVMLibCObjectRules.cmake
+++ b/libc/cmake/modules/LLVMLibCObjectRules.cmake
@@ -18,12 +18,12 @@ function(_get_common_compile_options output_var flags)
set(ADD_SSE4_2_FLAG TRUE)
endif()
- list(FIND flags ${PREFER_GENERIC_FLAG} prefer_generic)
- if(${prefer_generic} LESS 0)
- list(FIND flags "${PREFER_GENERIC_FLAG}__ONLY" prefer_generic)
+ list(FIND flags ${EXPLICIT_SIMD_OPT_FLAG} explicit_simd)
+ if(${explicit_simd} LESS 0)
+ list(FIND flags "${EXPLICIT_SIMD_OPT_FLAG}__ONLY" explicit_simd)
endif()
- if(${prefer_generic} GREATER -1)
- set(ADD_PREFER_GENERIC_FLAG TRUE)
+ if(${explicit_simd} GREATER -1)
+ set(ADD_EXPLICIT_SIMD_OPT_FLAG TRUE)
endif()
set(compile_options ${LIBC_COMPILE_OPTIONS_DEFAULT})
@@ -73,8 +73,8 @@ function(_get_common_compile_options output_var flags)
if(ADD_SSE4_2_FLAG)
list(APPEND compile_options "-msse4.2")
endif()
- if(ADD_PREFER_GENERIC_FLAG)
- list(APPEND compile_options "-D__LIBC_PREFER_GENERIC")
+ if(ADD_EXPLICIT_SIMD_OPT_FLAG)
+ list(APPEND compile_options "-D__LIBC_EXPLICIT_SIMD_OPT")
endif()
elseif(MSVC)
list(APPEND compile_options "/EHs-c-")
@@ -82,8 +82,8 @@ function(_get_common_compile_options output_var flags)
if(ADD_FMA_FLAG)
list(APPEND compile_options "/arch:AVX2")
endif()
- if(ADD_PREFER_GENERIC_FLAG)
- list(APPEND compile_options "/D__LIBC_PREFER_GENERIC")
+ if(ADD_EXPLICIT_SIMD_OPT_FLAG)
+ list(APPEND compile_options "/D__LIBC_EXPLICIT_SIMD_OPT")
endif()
endif()
if (LIBC_TARGET_ARCHITECTURE_IS_GPU)
diff --git a/libc/src/__support/HashTable/CMakeLists.txt b/libc/src/__support/HashTable/CMakeLists.txt
index dce37fdb5143ffa..6fa90c780c90d32 100644
--- a/libc/src/__support/HashTable/CMakeLists.txt
+++ b/libc/src/__support/HashTable/CMakeLists.txt
@@ -3,7 +3,7 @@ add_header_library(
HDRS
bitmask.h
FLAGS
- PREFER_GENERIC
+ EXPLICIT_SIMD_OPT
DEPENDS
libc.src.__support.common
libc.src.__support.CPP.bit
diff --git a/libc/src/__support/HashTable/bitmask.h b/libc/src/__support/HashTable/bitmask.h
index f97a7bccde3276e..afdf7c2c43bfba3 100644
--- a/libc/src/__support/HashTable/bitmask.h
+++ b/libc/src/__support/HashTable/bitmask.h
@@ -83,7 +83,7 @@ template <class BitMask> struct IteratableBitMaskAdaptor : public BitMask {
} // namespace internal
} // namespace LIBC_NAMESPACE
-#if defined(LIBC_TARGET_CPU_HAS_SSE2) && !defined(__LIBC_PREFER_GENERIC)
+#if defined(LIBC_TARGET_CPU_HAS_SSE2) && defined(__LIBC_EXPLICIT_SIMD_OPT)
#include "sse2/bitmask_impl.inc"
#else
#include "generic/bitmask_impl.inc"
|
lntue
reviewed
Jan 26, 2024
lntue
approved these changes
Jan 27, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #79474.