[libcxx-commits] [libcxx] [libc++] Ensure that we vectorize algorithms on all Clang-based compilers (PR #132090)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Mar 19 13:00:29 PDT 2025
https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/132090
Otherwise, we wouldn't vectorize on compilers like AppleClang when in reality we know perfectly well how to do it.
>From 1502090fab337042d6bd1ca9e25f841bd463b6b9 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Wed, 19 Mar 2025 15:59:13 -0400
Subject: [PATCH] [libc++] Ensure that we vectorize algorithms on all
Clang-based compilers
Otherwise, we wouldn't vectorize on compilers like AppleClang when in
reality we know perfectly well how to do it.
---
libcxx/include/__algorithm/simd_utils.h | 2 +-
.../algorithms/vectorization.compile.pass.cpp | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
create mode 100644 libcxx/test/libcxx/algorithms/vectorization.compile.pass.cpp
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
More information about the libcxx-commits
mailing list