Skip to content

Commit aa80388

Browse files
authored
[libc++] Ensure that we vectorize algorithms on all Clang-based compilers (llvm#132090)
Otherwise, we wouldn't vectorize on compilers like AppleClang when in reality we know perfectly well how to do it.
1 parent ef4f479 commit aa80388

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

libcxx/include/__algorithm/simd_utils.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ _LIBCPP_PUSH_MACROS
2626
#include <__undef_macros>
2727

2828
// TODO: Find out how altivec changes things and allow vectorizations there too.
29-
#if _LIBCPP_STD_VER >= 14 && defined(_LIBCPP_CLANG_VER) && !defined(__ALTIVEC__)
29+
// TODO: Simplify this condition once we stop building with AppleClang 15 in the CI.
30+
#if _LIBCPP_STD_VER >= 14 && defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(__ALTIVEC__) && \
31+
!(defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1600)
3032
# define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 1
3133
#else
3234
# define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// We don't know how to vectorize algorithms on GCC
10+
// XFAIL: gcc
11+
12+
// XFAIL: FROZEN-CXX03-HEADERS-FIXME
13+
14+
// We don't vectorize algorithms before C++14
15+
// XFAIL: c++03, c++11
16+
17+
// We don't vectorize algorithms on AIX right now.
18+
// XFAIL: target={{.+}}-aix{{.*}}
19+
20+
// We don't vectorize on AppleClang 15 since that apparently breaks std::mismatch
21+
// XFAIL: apple-clang-15
22+
23+
// This test ensures that we enable the vectorization of algorithms on the expected
24+
// platforms.
25+
26+
#include <algorithm>
27+
28+
#ifndef _LIBCPP_VECTORIZE_ALGORITHMS
29+
# error It looks like the test needs to be updated since _LIBCPP_VECTORIZE_ALGORITHMS isn't defined anymore
30+
#endif
31+
32+
#if !_LIBCPP_VECTORIZE_ALGORITHMS
33+
# error Algorithms should be vectorized on this platform
34+
#endif

0 commit comments

Comments
 (0)