[libcxx-commits] [libcxx] [libc++] Ensure that we vectorize algorithms on all Clang-based compilers (PR #132090)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Mar 19 13:01:08 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Louis Dionne (ldionne)
<details>
<summary>Changes</summary>
Otherwise, we wouldn't vectorize on compilers like AppleClang when in reality we know perfectly well how to do it.
---
Full diff: https://github.com/llvm/llvm-project/pull/132090.diff
2 Files Affected:
- (modified) libcxx/include/__algorithm/simd_utils.h (+1-1)
- (added) libcxx/test/libcxx/algorithms/vectorization.compile.pass.cpp (+19)
``````````diff
diff --git a/libcxx/include/__algorithm/simd_utils.h b/libcxx/include/__algorithm/simd_utils.h
index e3c790998e902..196f02985d89d 100644
--- a/libcxx/include/__algorithm/simd_utils.h
+++ b/libcxx/include/__algorithm/simd_utils.h
@@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS
#include <__undef_macros>
// TODO: Find out how altivec changes things and allow vectorizations there too.
-#if _LIBCPP_STD_VER >= 14 && defined(_LIBCPP_CLANG_VER) && !defined(__ALTIVEC__)
+#if _LIBCPP_STD_VER >= 14 && defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(__ALTIVEC__)
# define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 1
#else
# define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 0
diff --git a/libcxx/test/libcxx/algorithms/vectorization.compile.pass.cpp b/libcxx/test/libcxx/algorithms/vectorization.compile.pass.cpp
new file mode 100644
index 0000000000000..5954798e75896
--- /dev/null
+++ b/libcxx/test/libcxx/algorithms/vectorization.compile.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// We don't know how to vectorize algorithms on GCC
+// XFAIL: gcc
+
+// This test ensures that we enable the vectorization of algorithms on the expected
+// platforms.
+
+#include <algorithm>
+
+#if !_LIBCPP_VECTORIZE_ALGORITHMS
+# error Algorithms should be vectorized on this platform
+#endif
``````````
</details>
https://github.com/llvm/llvm-project/pull/132090
More information about the libcxx-commits
mailing list