Skip to content

Conversation

@ldionne
Copy link
Member

@ldionne ldionne commented Mar 19, 2025

Otherwise, we wouldn't vectorize on compilers like AppleClang when in reality we know perfectly well how to do it.

…lers

Otherwise, we wouldn't vectorize on compilers like AppleClang when in
reality we know perfectly well how to do it.
@ldionne ldionne requested a review from a team as a code owner March 19, 2025 20:00
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Mar 19, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 19, 2025

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

Changes

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 --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

Copy link
Member

@mordante mordante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, LTGM modulo some small comments.

@ldionne ldionne merged commit aa80388 into llvm:main Mar 24, 2025
85 checks passed
@ldionne ldionne deleted the review/fix-vectorization-apple-clang branch March 24, 2025 17:22
@ldionne ldionne self-assigned this Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants