Skip to content

[libc++] Implement any_of in terms of find_if - #207274

Merged
ldionne merged 8 commits into
llvm:mainfrom
ldionne:review/rewrite-any_of
Jul 23, 2026
Merged

ldionne merged 8 commits into
llvm:mainfrom
ldionne:review/rewrite-any_of

Conversation

@ldionne

@ldionne ldionne commented Jul 2, 2026

Copy link
Copy Markdown
Member

This way, any optimizations in find_if will be picked up by any_of.

Closes #129310

This way, any optimizations in find_if will be picked up by any_of.

Closes llvm#129310
@ldionne
ldionne requested a review from a team as a code owner July 2, 2026 20:42
@llvmorg-github-actions llvmorg-github-actions Bot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Jul 2, 2026
@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

Changes

This way, any optimizations in find_if will be picked up by any_of.

Closes #129310


Full diff: https://github.com/llvm/llvm-project/pull/207274.diff

1 Files Affected:

  • (modified) libcxx/include/__algorithm/any_of.h (+5-7)
diff --git a/libcxx/include/__algorithm/any_of.h b/libcxx/include/__algorithm/any_of.h
index 4b6eb94517286..94a0917899d63 100644
--- a/libcxx/include/__algorithm/any_of.h
+++ b/libcxx/include/__algorithm/any_of.h
@@ -10,9 +10,10 @@
 #ifndef _LIBCPP___ALGORITHM_ANY_OF_H
 #define _LIBCPP___ALGORITHM_ANY_OF_H
 
+#include <__algorithm/find_if.h>
 #include <__config>
 #include <__functional/identity.h>
-#include <__type_traits/invoke.h>
+#include <__utility/forward.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
@@ -23,18 +24,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 template <class _Iter, class _Sent, class _Proj, class _Pred>
 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
 __any_of(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
-  for (; __first != __last; ++__first) {
-    if (std::__invoke(__pred, std::__invoke(__proj, *__first)))
-      return true;
-  }
-  return false;
+  auto __found = std::__find_if(std::move(__first), __last, std::forward<_Pred>(__pred), std::forward<_Proj>(__proj));
+  return __found != __last;
 }
 
 template <class _InputIterator, class _Predicate>
 [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
 any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
   __identity __proj;
-  return std::__any_of(__first, __last, __pred, __proj);
+  return std::__any_of(std::move(__first), std::move(__last), __pred, __proj);
 }
 
 _LIBCPP_END_NAMESPACE_STD

Comment thread libcxx/include/__algorithm/any_of.h Resolved
Comment thread libcxx/include/__algorithm/any_of.h Resolved
@ldionne
ldionne marked this pull request as draft July 3, 2026 19:37
@ldionne

ldionne commented Jul 6, 2026 •

Copy link
Copy Markdown
Member Author

/libcxx-bot benchmark libcxx/test/benchmarks/algorithms/nonmodifying/any_all_none_of.bench.cpp

Running benchmarks in https://github.com/llvm/llvm-project/actions/runs/28816633091

Benchmark results for Linux x86_64:
Benchmark                                        Baseline    Candidate    Difference    % Difference
---------------------------------------------  ----------  -----------  ------------  --------------
std::all_of(deque<int>)_(process_all)/32            28.98        23.29         -5.69         -19.63%
std::all_of(deque<int>)_(process_all)/32768      27159.58     21059.35      -6100.23         -22.46%
std::all_of(deque<int>)_(process_all)/50            43.99        34.48         -9.51         -21.62%
std::all_of(deque<int>)_(process_all)/8              9.16         7.07         -2.09         -22.78%
std::all_of(deque<int>)_(process_all)/8192        6750.65      5207.15      -1543.50         -22.86%
std::all_of(list<int>)_(process_all)/32             41.06        31.03        -10.03         -24.43%
std::all_of(list<int>)_(process_all)/32768       53479.42     50368.98      -3110.45          -5.82%
std::all_of(list<int>)_(process_all)/50             68.38        54.84        -13.53         -19.79%
std::all_of(list<int>)_(process_all)/8               7.29         5.55         -1.74         -23.91%
std::all_of(list<int>)_(process_all)/8192        21879.81     23805.28       1925.47           8.80%
std::all_of(vector<int>)_(process_all)/32           24.18        21.28         -2.90         -11.98%
std::all_of(vector<int>)_(process_all)/32768     24444.31     20608.86      -3835.45         -15.69%
std::all_of(vector<int>)_(process_all)/50           37.82        32.58         -5.24         -13.85%
std::all_of(vector<int>)_(process_all)/8             6.17         5.32         -0.84         -13.70%
std::all_of(vector<int>)_(process_all)/8192       6119.59      5134.31       -985.28         -16.10%
std::any_of(deque<int>)_(process_all)/32            29.64        22.99         -6.65         -22.42%
std::any_of(deque<int>)_(process_all)/32768      27182.57     21029.04      -6153.53         -22.64%
std::any_of(deque<int>)_(process_all)/50            44.61        34.79         -9.82         -22.02%
std::any_of(deque<int>)_(process_all)/8              9.88         7.06         -2.82         -28.53%
std::any_of(deque<int>)_(process_all)/8192        6941.57      5219.69      -1721.88         -24.81%
std::any_of(list<int>)_(process_all)/32             40.97        39.22         -1.76          -4.29%
std::any_of(list<int>)_(process_all)/32768       54071.34     65478.56      11407.22          21.10%
std::any_of(list<int>)_(process_all)/50             68.53        69.08          0.55           0.80%
std::any_of(list<int>)_(process_all)/8               7.84         6.46         -1.37         -17.52%
std::any_of(list<int>)_(process_all)/8192        22189.83     26808.01       4618.18          20.81%
std::any_of(vector<int>)_(process_all)/32           24.17        14.62         -9.55         -39.51%
std::any_of(vector<int>)_(process_all)/32768     24365.14     12498.21     -11866.93         -48.70%
std::any_of(vector<int>)_(process_all)/50           37.42        22.14        -15.28         -40.85%
std::any_of(vector<int>)_(process_all)/8             6.16         4.18         -1.98         -32.07%
std::any_of(vector<int>)_(process_all)/8192       6092.08      3125.19      -2966.89         -48.70%
std::none_of(deque<int>)_(process_all)/32           29.61        23.05         -6.57         -22.17%
std::none_of(deque<int>)_(process_all)/32768     27025.52     20679.22      -6346.29         -23.48%
std::none_of(deque<int>)_(process_all)/50           44.53        33.73        -10.80         -24.25%
std::none_of(deque<int>)_(process_all)/8             9.89         7.27         -2.62         -26.50%
std::none_of(deque<int>)_(process_all)/8192       6759.48      5203.88      -1555.60         -23.01%
std::none_of(list<int>)_(process_all)/32            40.90        39.28         -1.62          -3.96%
std::none_of(list<int>)_(process_all)/32768      53973.80     64395.52      10421.72          19.31%
std::none_of(list<int>)_(process_all)/50            68.39        69.19          0.80           1.17%
std::none_of(list<int>)_(process_all)/8              7.92         6.44         -1.48         -18.71%
std::none_of(list<int>)_(process_all)/8192       21725.78     24063.79       2338.01          10.76%
std::none_of(vector<int>)_(process_all)/32          24.15        14.57         -9.58         -39.67%
std::none_of(vector<int>)_(process_all)/32768    24397.16     12771.73     -11625.44         -47.65%
std::none_of(vector<int>)_(process_all)/50          37.48        21.95        -15.54         -41.45%
std::none_of(vector<int>)_(process_all)/8            6.19         4.17         -2.02         -32.59%
std::none_of(vector<int>)_(process_all)/8192      6099.48      3115.53      -2983.95         -48.92%
Geomean                                            325.76       256.20        -69.56         -21.35%

Benchmark results for macOS 26.5 arm64:
Benchmark                                        Baseline    Candidate    Difference    % Difference
---------------------------------------------  ----------  -----------  ------------  --------------
std::all_of(deque<int>)_(process_all)/32            20.81        16.24         -4.57         -21.95%
std::all_of(deque<int>)_(process_all)/32768      20950.67     15886.87      -5063.80         -24.17%
std::all_of(deque<int>)_(process_all)/50            32.36        24.78         -7.57         -23.41%
std::all_of(deque<int>)_(process_all)/8              5.68         5.04         -0.64         -11.34%
std::all_of(deque<int>)_(process_all)/8192        5244.70      3936.70      -1308.00         -24.94%
std::all_of(list<int>)_(process_all)/32             28.04        28.05          0.01           0.03%
std::all_of(list<int>)_(process_all)/32768       42431.96     43634.48       1202.51           2.83%
std::all_of(list<int>)_(process_all)/50             46.96        46.99          0.04           0.08%
std::all_of(list<int>)_(process_all)/8               4.89         4.78         -0.11          -2.22%
std::all_of(list<int>)_(process_all)/8192        11719.90     12906.61       1186.71          10.13%
std::all_of(vector<int>)_(process_all)/32           15.17        10.87         -4.30         -28.34%
std::all_of(vector<int>)_(process_all)/32768     15036.31     10431.43      -4604.88         -30.63%
std::all_of(vector<int>)_(process_all)/50           23.45        16.83         -6.62         -28.24%
std::all_of(vector<int>)_(process_all)/8             4.03         3.13         -0.90         -22.36%
std::all_of(vector<int>)_(process_all)/8192       3738.82      2625.49      -1113.34         -29.78%
std::any_of(deque<int>)_(process_all)/32            20.79        16.21         -4.58         -22.05%
std::any_of(deque<int>)_(process_all)/32768      20842.88     15756.62      -5086.26         -24.40%
std::any_of(deque<int>)_(process_all)/50            32.12        24.62         -7.50         -23.35%
std::any_of(deque<int>)_(process_all)/8              5.69         5.09         -0.59         -10.42%
std::any_of(deque<int>)_(process_all)/8192        5217.37      3910.88      -1306.49         -25.04%
std::any_of(list<int>)_(process_all)/32             27.82        27.84          0.02           0.08%
std::any_of(list<int>)_(process_all)/32768       40302.89     41559.28       1256.39           3.12%
std::any_of(list<int>)_(process_all)/50             46.68        46.73          0.05           0.10%
std::any_of(list<int>)_(process_all)/8               4.89         4.80         -0.10          -1.94%
std::any_of(list<int>)_(process_all)/8192        13789.54     12210.04      -1579.50         -11.45%
std::any_of(vector<int>)_(process_all)/32           14.92        11.08         -3.84         -25.73%
std::any_of(vector<int>)_(process_all)/32768     15016.84     10454.79      -4562.05         -30.38%
std::any_of(vector<int>)_(process_all)/50           23.05        17.07         -5.98         -25.93%
std::any_of(vector<int>)_(process_all)/8             4.05         3.47         -0.58         -14.30%
std::any_of(vector<int>)_(process_all)/8192       3726.91      2627.46      -1099.46         -29.50%
std::none_of(deque<int>)_(process_all)/32           20.74        17.70         -3.05         -14.69%
std::none_of(deque<int>)_(process_all)/32768     20924.36     15777.81      -5146.55         -24.60%
std::none_of(deque<int>)_(process_all)/50           32.09        24.82         -7.28         -22.67%
std::none_of(deque<int>)_(process_all)/8             5.67         4.99         -0.68         -12.04%
std::none_of(deque<int>)_(process_all)/8192       5219.85      3936.15      -1283.70         -24.59%
std::none_of(list<int>)_(process_all)/32            28.07        28.06         -0.01          -0.04%
std::none_of(list<int>)_(process_all)/32768      42378.98     43819.09       1440.11           3.40%
std::none_of(list<int>)_(process_all)/50            46.95        46.97          0.02           0.05%
std::none_of(list<int>)_(process_all)/8              4.90         4.78         -0.12          -2.53%
std::none_of(list<int>)_(process_all)/8192       13109.45     14223.05       1113.60           8.49%
std::none_of(vector<int>)_(process_all)/32          14.89        11.02         -3.87         -25.99%
std::none_of(vector<int>)_(process_all)/32768    14989.76     10391.47      -4598.28         -30.68%
std::none_of(vector<int>)_(process_all)/50          23.01        16.83         -6.17         -26.83%
std::none_of(vector<int>)_(process_all)/8            4.04         3.46         -0.58         -14.29%
std::none_of(vector<int>)_(process_all)/8192      3718.34      2614.13      -1104.20         -29.70%
Geomean                                            217.08       181.71        -35.37         -16.29%

@ldionne

ldionne commented Jul 6, 2026 •

Copy link
Copy Markdown
Member Author

/libcxx-bot benchmark libcxx/test/benchmarks/algorithms/nonmodifying/any_all_none_of.bench.cpp

Running benchmarks in https://github.com/llvm/llvm-project/actions/runs/28817937408

Benchmark results for Linux x86_64:
Benchmark                                        Baseline    Candidate    Difference    % Difference
---------------------------------------------  ----------  -----------  ------------  --------------
std::all_of(deque<int>)_(process_all)/32            29.16        24.51         -4.65         -15.94%
std::all_of(deque<int>)_(process_all)/32768      27196.93     20780.31      -6416.62         -23.59%
std::all_of(deque<int>)_(process_all)/50            43.79        34.19         -9.61         -21.93%
std::all_of(deque<int>)_(process_all)/8              9.46         7.08         -2.38         -25.16%
std::all_of(deque<int>)_(process_all)/8192        6812.58      5211.95      -1600.63         -23.50%
std::all_of(list<int>)_(process_all)/32             39.66        31.19         -8.47         -21.36%
std::all_of(list<int>)_(process_all)/32768       53855.12    140554.17      86699.06         160.99%
std::all_of(list<int>)_(process_all)/50             67.21        55.70        -11.51         -17.13%
std::all_of(list<int>)_(process_all)/8               7.12         5.52         -1.60         -22.44%
std::all_of(list<int>)_(process_all)/8192        22549.16     24498.35       1949.20           8.64%
std::all_of(vector<int>)_(process_all)/32           24.23        21.21         -3.02         -12.46%
std::all_of(vector<int>)_(process_all)/32768     24503.51     20462.04      -4041.47         -16.49%
std::all_of(vector<int>)_(process_all)/50           37.60        32.54         -5.06         -13.45%
std::all_of(vector<int>)_(process_all)/8             6.18         5.30         -0.88         -14.24%
std::all_of(vector<int>)_(process_all)/8192       6123.24      5119.25      -1003.99         -16.40%
std::any_of(deque<int>)_(process_all)/32            29.63        22.68         -6.96         -23.47%
std::any_of(deque<int>)_(process_all)/32768      27824.61     20763.50      -7061.11         -25.38%
std::any_of(deque<int>)_(process_all)/50            44.32        33.66        -10.66         -24.05%
std::any_of(deque<int>)_(process_all)/8              9.89         7.38         -2.51         -25.36%
std::any_of(deque<int>)_(process_all)/8192        6808.34      5183.33      -1625.01         -23.87%
std::any_of(list<int>)_(process_all)/32             39.75        39.27         -0.48          -1.21%
std::any_of(list<int>)_(process_all)/32768       53015.21     57666.47       4651.26           8.77%
std::any_of(list<int>)_(process_all)/50             67.28        68.95          1.67           2.47%
std::any_of(list<int>)_(process_all)/8               7.21         6.49         -0.72          -9.97%
std::any_of(list<int>)_(process_all)/8192        21745.58     22299.32        553.74           2.55%
std::any_of(vector<int>)_(process_all)/32           24.21        14.61         -9.60         -39.66%
std::any_of(vector<int>)_(process_all)/32768     24374.79     12475.36     -11899.42         -48.82%
std::any_of(vector<int>)_(process_all)/50           37.70        21.95        -15.76         -41.79%
std::any_of(vector<int>)_(process_all)/8             6.20         4.20         -2.00         -32.28%
std::any_of(vector<int>)_(process_all)/8192       6178.68      3108.48      -3070.20         -49.69%
std::none_of(deque<int>)_(process_all)/32           29.64        22.30         -7.34         -24.76%
std::none_of(deque<int>)_(process_all)/32768     27020.08     20739.71      -6280.37         -23.24%
std::none_of(deque<int>)_(process_all)/50           44.52        34.28        -10.24         -23.00%
std::none_of(deque<int>)_(process_all)/8             9.96         7.00         -2.96         -29.73%
std::none_of(deque<int>)_(process_all)/8192       6750.56      5213.03      -1537.53         -22.78%
std::none_of(list<int>)_(process_all)/32            40.15        39.41         -0.74          -1.84%
std::none_of(list<int>)_(process_all)/32768      54636.30     57477.45       2841.15           5.20%
std::none_of(list<int>)_(process_all)/50            67.26        69.32          2.06           3.06%
std::none_of(list<int>)_(process_all)/8              7.28         6.47         -0.81         -11.10%
std::none_of(list<int>)_(process_all)/8192       21528.74     22226.19        697.44           3.24%
std::none_of(vector<int>)_(process_all)/32          24.10        14.54         -9.57         -39.70%
std::none_of(vector<int>)_(process_all)/32768    24468.33     12463.14     -12005.19         -49.06%
std::none_of(vector<int>)_(process_all)/50          37.49        21.90        -15.59         -41.58%
std::none_of(vector<int>)_(process_all)/8            6.26         4.17         -2.09         -33.42%
std::none_of(vector<int>)_(process_all)/8192      6101.36      3107.04      -2994.33         -49.08%
Geomean                                            324.07       258.92        -65.15         -20.10%

Benchmark results for macOS 26.5 arm64:
Benchmark                                        Baseline    Candidate    Difference    % Difference
---------------------------------------------  ----------  -----------  ------------  --------------
std::all_of(deque<int>)_(process_all)/32            20.77        16.20         -4.57         -22.01%
std::all_of(deque<int>)_(process_all)/32768      20874.77     15930.52      -4944.25         -23.69%
std::all_of(deque<int>)_(process_all)/50            32.11        24.75         -7.36         -22.93%
std::all_of(deque<int>)_(process_all)/8              5.74         5.02         -0.72         -12.54%
std::all_of(deque<int>)_(process_all)/8192        5225.63      3949.79      -1275.85         -24.42%
std::all_of(list<int>)_(process_all)/32             27.15        28.08          0.93           3.41%
std::all_of(list<int>)_(process_all)/32768       42130.96     43275.78       1144.82           2.72%
std::all_of(list<int>)_(process_all)/50             46.54        47.00          0.46           0.99%
std::all_of(list<int>)_(process_all)/8               4.74         4.71         -0.02          -0.44%
std::all_of(list<int>)_(process_all)/8192        15617.89     13497.06      -2120.84         -13.58%
std::all_of(vector<int>)_(process_all)/32           14.92        10.91         -4.01         -26.86%
std::all_of(vector<int>)_(process_all)/32768     15020.96     10420.65      -4600.31         -30.63%
std::all_of(vector<int>)_(process_all)/50           23.03        16.86         -6.17         -26.81%
std::all_of(vector<int>)_(process_all)/8             4.12         3.15         -0.98         -23.71%
std::all_of(vector<int>)_(process_all)/8192       3740.31      2639.42      -1100.90         -29.43%
std::any_of(deque<int>)_(process_all)/32            20.77        16.15         -4.63         -22.28%
std::any_of(deque<int>)_(process_all)/32768      20919.96     15860.97      -5058.99         -24.18%
std::any_of(deque<int>)_(process_all)/50            32.14        24.61         -7.53         -23.44%
std::any_of(deque<int>)_(process_all)/8              5.68         5.04         -0.63         -11.12%
std::any_of(deque<int>)_(process_all)/8192        5229.24      3947.36      -1281.88         -24.51%
std::any_of(list<int>)_(process_all)/32             27.52        27.87          0.35           1.29%
std::any_of(list<int>)_(process_all)/32768       41035.26     41838.04        802.78           1.96%
std::any_of(list<int>)_(process_all)/50             46.63        46.96          0.33           0.72%
std::any_of(list<int>)_(process_all)/8               5.04         4.93         -0.11          -2.27%
std::any_of(list<int>)_(process_all)/8192        11663.39     13302.50       1639.10          14.05%
std::any_of(vector<int>)_(process_all)/32           14.88        11.05         -3.83         -25.76%
std::any_of(vector<int>)_(process_all)/32768     15004.50     10387.55      -4616.95         -30.77%
std::any_of(vector<int>)_(process_all)/50           22.98        16.89         -6.09         -26.51%
std::any_of(vector<int>)_(process_all)/8             4.05         3.46         -0.58         -14.42%
std::any_of(vector<int>)_(process_all)/8192       3720.72      2622.26      -1098.46         -29.52%
std::none_of(deque<int>)_(process_all)/32           20.61        16.22         -4.40         -21.33%
std::none_of(deque<int>)_(process_all)/32768     20770.78     15788.61      -4982.16         -23.99%
std::none_of(deque<int>)_(process_all)/50           31.89        24.67         -7.22         -22.63%
std::none_of(deque<int>)_(process_all)/8             5.63         5.04         -0.58         -10.35%
std::none_of(deque<int>)_(process_all)/8192       5187.08      3943.87      -1243.21         -23.97%
std::none_of(list<int>)_(process_all)/32            26.96        28.03          1.07           3.96%
std::none_of(list<int>)_(process_all)/32768      43744.76     43805.36         60.59           0.14%
std::none_of(list<int>)_(process_all)/50            46.50        46.77          0.27           0.58%
std::none_of(list<int>)_(process_all)/8              4.70         4.72          0.02           0.44%
std::none_of(list<int>)_(process_all)/8192       15282.22     15320.56         38.34           0.25%
std::none_of(vector<int>)_(process_all)/32          14.80        11.01         -3.79         -25.61%
std::none_of(vector<int>)_(process_all)/32768    14916.55     10391.10      -4525.45         -30.34%
std::none_of(vector<int>)_(process_all)/50          22.87        16.81         -6.06         -26.49%
std::none_of(vector<int>)_(process_all)/8            4.10         3.46         -0.64         -15.70%
std::none_of(vector<int>)_(process_all)/8192      3673.33      2611.18      -1062.15         -28.92%
Geomean                                            217.54       182.16        -35.38         -16.26%

@ldionne

ldionne commented Jul 6, 2026 •

Copy link
Copy Markdown
Member Author

/libcxx-bot benchmark libcxx/test/benchmarks/algorithms/nonmodifying/any_all_none_of.bench.cpp

Running benchmarks in https://github.com/llvm/llvm-project/actions/runs/28818135765

Benchmark results for macOS 26.5 arm64:
Benchmark                                        Baseline    Candidate    Difference    % Difference
---------------------------------------------  ----------  -----------  ------------  --------------
std::all_of(deque<int>)_(process_all)/32            20.89        16.13         -4.76         -22.79%
std::all_of(deque<int>)_(process_all)/32768      20926.21     15880.78      -5045.43         -24.11%
std::all_of(deque<int>)_(process_all)/50            32.41        24.56         -7.85         -24.22%
std::all_of(deque<int>)_(process_all)/8              5.71         4.87         -0.84         -14.76%
std::all_of(deque<int>)_(process_all)/8192        5284.78      3980.07      -1304.71         -24.69%
std::all_of(list<int>)_(process_all)/32             28.02        28.10          0.08           0.27%
std::all_of(list<int>)_(process_all)/32768       42255.84     42137.52       -118.33          -0.28%
std::all_of(list<int>)_(process_all)/50             46.96        47.17          0.21           0.44%
std::all_of(list<int>)_(process_all)/8               4.89         4.73         -0.17          -3.42%
std::all_of(list<int>)_(process_all)/8192        17443.42     11278.50      -6164.92         -35.34%
std::all_of(vector<int>)_(process_all)/32           14.87        11.07         -3.80         -25.57%
std::all_of(vector<int>)_(process_all)/32768     15013.86     10376.98      -4636.88         -30.88%
std::all_of(vector<int>)_(process_all)/50           22.96        16.94         -6.02         -26.24%
std::all_of(vector<int>)_(process_all)/8             4.03         3.13         -0.90         -22.33%
std::all_of(vector<int>)_(process_all)/8192       3736.93      2608.48      -1128.46         -30.20%
std::any_of(deque<int>)_(process_all)/32            20.89        23.76          2.87          13.75%
std::any_of(deque<int>)_(process_all)/32768      20934.28     15829.10      -5105.18         -24.39%
std::any_of(deque<int>)_(process_all)/50            32.39        24.92         -7.47         -23.06%
std::any_of(deque<int>)_(process_all)/8              5.75         4.88         -0.87         -15.10%
std::any_of(deque<int>)_(process_all)/8192        5245.79      3977.24      -1268.56         -24.18%
std::any_of(list<int>)_(process_all)/32             28.04        27.97         -0.07          -0.24%
std::any_of(list<int>)_(process_all)/32768       40369.19     38846.34      -1522.85          -3.77%
std::any_of(list<int>)_(process_all)/50             46.60        47.09          0.49           1.05%
std::any_of(list<int>)_(process_all)/8               5.00         4.97         -0.03          -0.62%
std::any_of(list<int>)_(process_all)/8192        11497.73     11568.81         71.07           0.62%
std::any_of(vector<int>)_(process_all)/32           14.97        11.10         -3.87         -25.85%
std::any_of(vector<int>)_(process_all)/32768     15067.39     10592.09      -4475.30         -29.70%
std::any_of(vector<int>)_(process_all)/50           23.07        16.87         -6.20         -26.89%
std::any_of(vector<int>)_(process_all)/8             4.07         3.50         -0.56         -13.85%
std::any_of(vector<int>)_(process_all)/8192       3748.17      2616.97      -1131.20         -30.18%
std::none_of(deque<int>)_(process_all)/32           20.82        24.80          3.99          19.15%
std::none_of(deque<int>)_(process_all)/32768     21030.39     16105.25      -4925.14         -23.42%
std::none_of(deque<int>)_(process_all)/50           32.04        24.93         -7.11         -22.19%
std::none_of(deque<int>)_(process_all)/8             5.69         4.92         -0.77         -13.55%
std::none_of(deque<int>)_(process_all)/8192       5234.40      3994.45      -1239.95         -23.69%
std::none_of(list<int>)_(process_all)/32            28.08        28.01         -0.06          -0.22%
std::none_of(list<int>)_(process_all)/32768      42799.96     42374.21       -425.75          -0.99%
std::none_of(list<int>)_(process_all)/50            46.94        47.02          0.08           0.16%
std::none_of(list<int>)_(process_all)/8              4.92         4.77         -0.14          -2.91%
std::none_of(list<int>)_(process_all)/8192       15333.75     12678.32      -2655.42         -17.32%
std::none_of(vector<int>)_(process_all)/32          14.91        11.04         -3.86         -25.92%
std::none_of(vector<int>)_(process_all)/32768    14982.75     10477.74      -4505.01         -30.07%
std::none_of(vector<int>)_(process_all)/50          22.97        16.86         -6.11         -26.60%
std::none_of(vector<int>)_(process_all)/8            4.04         3.47         -0.56         -13.93%
std::none_of(vector<int>)_(process_all)/8192      3716.36      2632.72      -1083.65         -29.16%
Geomean                                            219.25       183.10        -36.16         -16.49%

Benchmark results for Linux x86_64:
Benchmark                                        Baseline    Candidate    Difference    % Difference
---------------------------------------------  ----------  -----------  ------------  --------------
std::all_of(deque<int>)_(process_all)/32            29.00        23.40         -5.60         -19.31%
std::all_of(deque<int>)_(process_all)/32768      27009.43     20958.36      -6051.07         -22.40%
std::all_of(deque<int>)_(process_all)/50            44.35        35.00         -9.35         -21.08%
std::all_of(deque<int>)_(process_all)/8              9.16         7.12         -2.04         -22.30%
std::all_of(deque<int>)_(process_all)/8192        6813.80      5216.61      -1597.20         -23.44%
std::all_of(list<int>)_(process_all)/32             39.65        31.12         -8.52         -21.49%
std::all_of(list<int>)_(process_all)/32768       53145.87     52482.14       -663.74          -1.25%
std::all_of(list<int>)_(process_all)/50             67.09        54.81        -12.29         -18.32%
std::all_of(list<int>)_(process_all)/8               7.10         5.54         -1.56         -21.98%
std::all_of(list<int>)_(process_all)/8192        21400.50     24325.19       2924.69          13.67%
std::all_of(vector<int>)_(process_all)/32           24.27        21.27         -3.00         -12.34%
std::all_of(vector<int>)_(process_all)/32768     24382.21     20480.32      -3901.89         -16.00%
std::all_of(vector<int>)_(process_all)/50           37.43        33.38         -4.05         -10.83%
std::all_of(vector<int>)_(process_all)/8             6.17         5.32         -0.85         -13.79%
std::all_of(vector<int>)_(process_all)/8192       6096.66      5385.17       -711.48         -11.67%
std::any_of(deque<int>)_(process_all)/32            29.64        24.68         -4.96         -16.73%
std::any_of(deque<int>)_(process_all)/32768      26961.86     20728.08      -6233.78         -23.12%
std::any_of(deque<int>)_(process_all)/50            44.48        34.96         -9.52         -21.41%
std::any_of(deque<int>)_(process_all)/8              9.89         7.07         -2.82         -28.53%
std::any_of(deque<int>)_(process_all)/8192        6757.90      5203.89      -1554.01         -23.00%
std::any_of(list<int>)_(process_all)/32             39.92        39.17         -0.74          -1.86%
std::any_of(list<int>)_(process_all)/32768       55680.06     65395.51       9715.44          17.45%
std::any_of(list<int>)_(process_all)/50             67.39        70.13          2.73           4.06%
std::any_of(list<int>)_(process_all)/8               7.21         6.45         -0.76         -10.54%
std::any_of(list<int>)_(process_all)/8192        21429.27     22156.06        726.79           3.39%
std::any_of(vector<int>)_(process_all)/32           24.42        14.60         -9.81         -40.19%
std::any_of(vector<int>)_(process_all)/32768     24359.88     12500.91     -11858.97         -48.68%
std::any_of(vector<int>)_(process_all)/50           37.51        21.97        -15.55         -41.45%
std::any_of(vector<int>)_(process_all)/8             6.17         4.18         -1.98         -32.18%
std::any_of(vector<int>)_(process_all)/8192       6100.94      3129.34      -2971.60         -48.71%
std::none_of(deque<int>)_(process_all)/32           29.74        22.12         -7.62         -25.61%
std::none_of(deque<int>)_(process_all)/32768     27055.50     20865.08      -6190.42         -22.88%
std::none_of(deque<int>)_(process_all)/50           44.71        33.59        -11.12         -24.88%
std::none_of(deque<int>)_(process_all)/8             9.90         7.12         -2.78         -28.04%
std::none_of(deque<int>)_(process_all)/8192       6787.58      5205.15      -1582.43         -23.31%
std::none_of(list<int>)_(process_all)/32            39.75        39.32         -0.43          -1.08%
std::none_of(list<int>)_(process_all)/32768      55905.05     64281.16       8376.11          14.98%
std::none_of(list<int>)_(process_all)/50            67.24        69.18          1.94           2.88%
std::none_of(list<int>)_(process_all)/8              7.24         6.48         -0.76         -10.45%
std::none_of(list<int>)_(process_all)/8192       21037.72     26591.44       5553.72          26.40%
std::none_of(vector<int>)_(process_all)/32          24.24        14.57         -9.68         -39.92%
std::none_of(vector<int>)_(process_all)/32768    24459.43     12477.79     -11981.64         -48.99%
std::none_of(vector<int>)_(process_all)/50          37.64        21.98        -15.66         -41.60%
std::none_of(vector<int>)_(process_all)/8            6.16         4.18         -1.98         -32.17%
std::none_of(vector<int>)_(process_all)/8192      6148.77      3103.57      -3045.20         -49.53%
Geomean                                            323.10       256.46        -66.64         -20.63%

@ldionne

ldionne commented Jul 6, 2026 •

Copy link
Copy Markdown
Member Author

/libcxx-bot benchmark libcxx/test/benchmarks/algorithms/nonmodifying/any_all_none_of.bench.cpp

Running benchmarks in https://github.com/llvm/llvm-project/actions/runs/28818136460

Benchmark results for macOS 26.5 arm64:
Benchmark                                        Baseline    Candidate    Difference    % Difference
---------------------------------------------  ----------  -----------  ------------  --------------
std::all_of(deque<int>)_(process_all)/32            21.04        16.24         -4.80         -22.81%
std::all_of(deque<int>)_(process_all)/32768      21224.23     15968.46      -5255.77         -24.76%
std::all_of(deque<int>)_(process_all)/50            32.42        24.94         -7.48         -23.07%
std::all_of(deque<int>)_(process_all)/8              5.69         5.05         -0.64         -11.22%
std::all_of(deque<int>)_(process_all)/8192        5232.16      3972.50      -1259.66         -24.08%
std::all_of(list<int>)_(process_all)/32             27.78        28.06          0.28           1.02%
std::all_of(list<int>)_(process_all)/32768       41822.67     42067.64        244.97           0.59%
std::all_of(list<int>)_(process_all)/50             46.81        47.04          0.23           0.49%
std::all_of(list<int>)_(process_all)/8               5.06         4.88         -0.18          -3.55%
std::all_of(list<int>)_(process_all)/8192        11800.03     14256.41       2456.38          20.82%
std::all_of(vector<int>)_(process_all)/32           15.05        11.00         -4.05         -26.93%
std::all_of(vector<int>)_(process_all)/32768     15061.37     10472.25      -4589.12         -30.47%
std::all_of(vector<int>)_(process_all)/50           23.27        16.91         -6.36         -27.33%
std::all_of(vector<int>)_(process_all)/8             4.07         3.18         -0.89         -21.94%
std::all_of(vector<int>)_(process_all)/8192       3747.24      2642.50      -1104.74         -29.48%
std::any_of(deque<int>)_(process_all)/32            20.96        17.69         -3.27         -15.59%
std::any_of(deque<int>)_(process_all)/32768      21155.85     16051.79      -5104.06         -24.13%
std::any_of(deque<int>)_(process_all)/50            32.46        24.98         -7.48         -23.05%
std::any_of(deque<int>)_(process_all)/8              5.74         5.04         -0.70         -12.21%
std::any_of(deque<int>)_(process_all)/8192        5228.29      3955.10      -1273.19         -24.35%
std::any_of(list<int>)_(process_all)/32             27.87        28.07          0.20           0.71%
std::any_of(list<int>)_(process_all)/32768       40305.95     40449.75        143.80           0.36%
std::any_of(list<int>)_(process_all)/50             47.24        46.95         -0.29          -0.62%
std::any_of(list<int>)_(process_all)/8               4.87         4.84         -0.03          -0.58%
std::any_of(list<int>)_(process_all)/8192        13871.57     13846.85        -24.72          -0.18%
std::any_of(vector<int>)_(process_all)/32           15.00        11.14         -3.86         -25.74%
std::any_of(vector<int>)_(process_all)/32768     15039.22     10467.97      -4571.25         -30.40%
std::any_of(vector<int>)_(process_all)/50           22.99        16.98         -6.01         -26.13%
std::any_of(vector<int>)_(process_all)/8             4.08         3.48         -0.60         -14.76%
std::any_of(vector<int>)_(process_all)/8192       3745.61      2653.78      -1091.83         -29.15%
std::none_of(deque<int>)_(process_all)/32           20.77        16.29         -4.49         -21.60%
std::none_of(deque<int>)_(process_all)/32768     20916.71     15879.30      -5037.41         -24.08%
std::none_of(deque<int>)_(process_all)/50           32.25        24.90         -7.35         -22.78%
std::none_of(deque<int>)_(process_all)/8             5.67         5.05         -0.63         -11.02%
std::none_of(deque<int>)_(process_all)/8192       5255.87      3960.48      -1295.39         -24.65%
std::none_of(list<int>)_(process_all)/32            27.87        27.99          0.12           0.44%
std::none_of(list<int>)_(process_all)/32768      42206.62     42316.44        109.81           0.26%
std::none_of(list<int>)_(process_all)/50            47.03        46.86         -0.17          -0.36%
std::none_of(list<int>)_(process_all)/8              5.13         4.89         -0.24          -4.67%
std::none_of(list<int>)_(process_all)/8192       13049.71     11888.15      -1161.57          -8.90%
std::none_of(vector<int>)_(process_all)/32          14.81        11.11         -3.69         -24.94%
std::none_of(vector<int>)_(process_all)/32768    14931.59     10515.23      -4416.36         -29.58%
std::none_of(vector<int>)_(process_all)/50          22.90        16.97         -5.92         -25.87%
std::none_of(vector<int>)_(process_all)/8            4.02         3.49         -0.53         -13.31%
std::none_of(vector<int>)_(process_all)/8192      3684.01      2645.30      -1038.71         -28.20%
Geomean                                            217.70       182.52        -35.18         -16.16%

Benchmark results for Linux x86_64:
Benchmark                                        Baseline    Candidate    Difference    % Difference
---------------------------------------------  ----------  -----------  ------------  --------------
std::all_of(deque<int>)_(process_all)/32            29.07        23.61         -5.46         -18.78%
std::all_of(deque<int>)_(process_all)/32768      27059.76     20784.48      -6275.28         -23.19%
std::all_of(deque<int>)_(process_all)/50            43.98        35.11         -8.88         -20.19%
std::all_of(deque<int>)_(process_all)/8              9.26         7.18         -2.08         -22.49%
std::all_of(deque<int>)_(process_all)/8192        6814.38      5219.42      -1594.96         -23.41%
std::all_of(list<int>)_(process_all)/32             39.74        30.94         -8.79         -22.13%
std::all_of(list<int>)_(process_all)/32768       53537.25     95538.30      42001.06          78.45%
std::all_of(list<int>)_(process_all)/50             67.11        55.22        -11.89         -17.72%
std::all_of(list<int>)_(process_all)/8               7.16         5.52         -1.64         -22.90%
std::all_of(list<int>)_(process_all)/8192        21651.45     20907.23       -744.22          -3.44%
std::all_of(vector<int>)_(process_all)/32           24.20        21.22         -2.97         -12.29%
std::all_of(vector<int>)_(process_all)/32768     24394.70     20616.22      -3778.47         -15.49%
std::all_of(vector<int>)_(process_all)/50           37.46        32.49         -4.96         -13.25%
std::all_of(vector<int>)_(process_all)/8             6.21         5.34         -0.87         -14.02%
std::all_of(vector<int>)_(process_all)/8192       6100.22      5118.07       -982.15         -16.10%
std::any_of(deque<int>)_(process_all)/32            29.55        22.36         -7.19         -24.32%
std::any_of(deque<int>)_(process_all)/32768      26959.15     21075.23      -5883.92         -21.83%
std::any_of(deque<int>)_(process_all)/50            44.41        34.25        -10.16         -22.87%
std::any_of(deque<int>)_(process_all)/8              9.92         7.10         -2.82         -28.43%
std::any_of(deque<int>)_(process_all)/8192        6766.50      5259.19      -1507.31         -22.28%
std::any_of(list<int>)_(process_all)/32             39.65        39.25         -0.40          -1.01%
std::any_of(list<int>)_(process_all)/32768       58411.88     62773.88       4362.00           7.47%
std::any_of(list<int>)_(process_all)/50             67.13        71.04          3.92           5.83%
std::any_of(list<int>)_(process_all)/8               7.21         6.45         -0.76         -10.49%
std::any_of(list<int>)_(process_all)/8192        22217.13     22533.42        316.29           1.42%
std::any_of(vector<int>)_(process_all)/32           24.16        14.54         -9.61         -39.79%
std::any_of(vector<int>)_(process_all)/32768     24951.21     12498.35     -12452.86         -49.91%
std::any_of(vector<int>)_(process_all)/50           37.53        21.92        -15.61         -41.60%
std::any_of(vector<int>)_(process_all)/8             6.18         4.18         -2.00         -32.35%
std::any_of(vector<int>)_(process_all)/8192       6102.27      3109.84      -2992.43         -49.04%
std::none_of(deque<int>)_(process_all)/32           29.86        22.55         -7.31         -24.49%
std::none_of(deque<int>)_(process_all)/32768     27049.08     20882.38      -6166.70         -22.80%
std::none_of(deque<int>)_(process_all)/50           44.93        33.75        -11.18         -24.87%
std::none_of(deque<int>)_(process_all)/8             9.95         7.22         -2.73         -27.45%
std::none_of(deque<int>)_(process_all)/8192       6829.17      5208.65      -1620.53         -23.73%
std::none_of(list<int>)_(process_all)/32            39.68        39.30         -0.38          -0.97%
std::none_of(list<int>)_(process_all)/32768      57776.94     63860.73       6083.79          10.53%
std::none_of(list<int>)_(process_all)/50            67.24        69.15          1.91           2.85%
std::none_of(list<int>)_(process_all)/8              7.21         6.49         -0.73         -10.09%
std::none_of(list<int>)_(process_all)/8192       21483.84     24712.88       3229.04          15.03%
std::none_of(vector<int>)_(process_all)/32          24.15        14.56         -9.59         -39.70%
std::none_of(vector<int>)_(process_all)/32768    24402.12     12515.38     -11886.74         -48.71%
std::none_of(vector<int>)_(process_all)/50          37.45        21.92        -15.53         -41.46%
std::none_of(vector<int>)_(process_all)/8            6.18         4.17         -2.01         -32.51%
std::none_of(vector<int>)_(process_all)/8192      6097.84      3110.85      -2986.98         -48.98%
Geomean                                            324.42       257.83        -66.60         -20.53%

Comment thread libcxx/include/__algorithm/any_of.h Resolved
Comment thread libcxx/include/__algorithm/any_of.h Resolved
@ldionne

ldionne commented Jul 7, 2026 •

Copy link
Copy Markdown
Member Author

/libcxx-bot benchmark libcxx/test/benchmarks/algorithms/nonmodifying/any_all_none_of.bench.cpp

Running benchmarks in https://github.com/llvm/llvm-project/actions/runs/28887571623

Benchmark results for Linux x86_64:
Benchmark                                        Baseline    Candidate    Difference    % Difference
---------------------------------------------  ----------  -----------  ------------  --------------
std::all_of(deque<int>)_(process_all)/32            29.06        23.26         -5.81         -19.98%
std::all_of(deque<int>)_(process_all)/32768      27082.60     20800.44      -6282.16         -23.20%
std::all_of(deque<int>)_(process_all)/50            44.01        35.25         -8.76         -19.90%
std::all_of(deque<int>)_(process_all)/8              9.13         7.13         -2.00         -21.94%
std::all_of(deque<int>)_(process_all)/8192        6764.42      5207.09      -1557.33         -23.02%
std::all_of(list<int>)_(process_all)/32             39.59        30.98         -8.61         -21.75%
std::all_of(list<int>)_(process_all)/32768       53763.74     76788.80      23025.06          42.83%
std::all_of(list<int>)_(process_all)/50             67.04        54.85        -12.19         -18.19%
std::all_of(list<int>)_(process_all)/8               7.10         5.52         -1.58         -22.21%
std::all_of(list<int>)_(process_all)/8192        21431.63     21194.20       -237.44          -1.11%
std::all_of(vector<int>)_(process_all)/32           24.17        21.23         -2.93         -12.14%
std::all_of(vector<int>)_(process_all)/32768     24480.06     20496.92      -3983.14         -16.27%
std::all_of(vector<int>)_(process_all)/50           37.58        32.49         -5.08         -13.53%
std::all_of(vector<int>)_(process_all)/8             6.16         5.33         -0.83         -13.43%
std::all_of(vector<int>)_(process_all)/8192       6113.08      5133.56       -979.52         -16.02%
std::any_of(deque<int>)_(process_all)/32            29.59        22.40         -7.19         -24.29%
std::any_of(deque<int>)_(process_all)/32768      27091.80     20714.06      -6377.74         -23.54%
std::any_of(deque<int>)_(process_all)/50            44.48        34.07        -10.41         -23.41%
std::any_of(deque<int>)_(process_all)/8              9.89         7.10         -2.79         -28.21%
std::any_of(deque<int>)_(process_all)/8192        6773.41      5230.30      -1543.11         -22.78%
std::any_of(list<int>)_(process_all)/32             39.74        39.20         -0.54          -1.35%
std::any_of(list<int>)_(process_all)/32768       54594.44     58986.33       4391.89           8.04%
std::any_of(list<int>)_(process_all)/50             67.16        70.27          3.11           4.63%
std::any_of(list<int>)_(process_all)/8               7.22         6.44         -0.77         -10.73%
std::any_of(list<int>)_(process_all)/8192        21496.51     22549.49       1052.97           4.90%
std::any_of(vector<int>)_(process_all)/32           24.17        14.54         -9.63         -39.85%
std::any_of(vector<int>)_(process_all)/32768     24402.32     12463.41     -11938.91         -48.93%
std::any_of(vector<int>)_(process_all)/50           37.46        21.86        -15.60         -41.65%
std::any_of(vector<int>)_(process_all)/8             6.17         4.16         -2.01         -32.53%
std::any_of(vector<int>)_(process_all)/8192       6100.90      3117.32      -2983.58         -48.90%
std::none_of(deque<int>)_(process_all)/32           29.79        22.70         -7.08         -23.78%
std::none_of(deque<int>)_(process_all)/32768     27098.01     20711.86      -6386.15         -23.57%
std::none_of(deque<int>)_(process_all)/50           44.61        33.94        -10.67         -23.92%
std::none_of(deque<int>)_(process_all)/8             9.89         7.13         -2.76         -27.94%
std::none_of(deque<int>)_(process_all)/8192       6767.96      5212.89      -1555.08         -22.98%
std::none_of(list<int>)_(process_all)/32            39.83        39.29         -0.54          -1.36%
std::none_of(list<int>)_(process_all)/32768      54144.22     59793.24       5649.01          10.43%
std::none_of(list<int>)_(process_all)/50            67.24        69.37          2.13           3.17%
std::none_of(list<int>)_(process_all)/8              7.23         6.44         -0.79         -10.97%
std::none_of(list<int>)_(process_all)/8192       21506.79     22553.26       1046.47           4.87%
std::none_of(vector<int>)_(process_all)/32          24.22        14.58         -9.63         -39.77%
std::none_of(vector<int>)_(process_all)/32768    24477.05     12463.90     -12013.15         -49.08%
std::none_of(vector<int>)_(process_all)/50          37.44        21.97        -15.47         -41.33%
std::none_of(vector<int>)_(process_all)/8            6.17         4.17         -2.00         -32.43%
std::none_of(vector<int>)_(process_all)/8192      6096.41      3107.80      -2988.62         -49.02%
Geomean                                            322.74       254.89        -67.85         -21.02%

Benchmark results for macOS 26.5 arm64:
Benchmark                                        Baseline    Candidate    Difference    % Difference
---------------------------------------------  ----------  -----------  ------------  --------------
std::all_of(deque<int>)_(process_all)/32            20.71        16.06         -4.65         -22.44%
std::all_of(deque<int>)_(process_all)/32768      20831.54     15737.47      -5094.07         -24.45%
std::all_of(deque<int>)_(process_all)/50            31.99        24.53         -7.46         -23.32%
std::all_of(deque<int>)_(process_all)/8              5.67         4.95         -0.73         -12.80%
std::all_of(deque<int>)_(process_all)/8192        5212.67      3916.90      -1295.76         -24.86%
std::all_of(list<int>)_(process_all)/32             27.91        27.78         -0.14          -0.49%
std::all_of(list<int>)_(process_all)/32768       42740.73     43026.07        285.33           0.67%
std::all_of(list<int>)_(process_all)/50             46.76        46.98          0.22           0.47%
std::all_of(list<int>)_(process_all)/8               4.88         4.95          0.08           1.61%
std::all_of(list<int>)_(process_all)/8192        11505.78     11697.44        191.66           1.67%
std::all_of(vector<int>)_(process_all)/32           14.89        10.86         -4.03         -27.06%
std::all_of(vector<int>)_(process_all)/32768     14951.39     10347.75      -4603.64         -30.79%
std::all_of(vector<int>)_(process_all)/50           22.97        16.74         -6.23         -27.14%
std::all_of(vector<int>)_(process_all)/8             4.03         3.13         -0.90         -22.30%
std::all_of(vector<int>)_(process_all)/8192       3707.59      2597.34      -1110.25         -29.95%
std::any_of(deque<int>)_(process_all)/32            20.77        16.11         -4.66         -22.44%
std::any_of(deque<int>)_(process_all)/32768      20911.06     15845.28      -5065.78         -24.23%
std::any_of(deque<int>)_(process_all)/50            32.07        24.64         -7.43         -23.17%
std::any_of(deque<int>)_(process_all)/8              5.67         4.96         -0.71         -12.49%
std::any_of(deque<int>)_(process_all)/8192        5214.43      3938.79      -1275.64         -24.46%
std::any_of(list<int>)_(process_all)/32             28.04        28.05          0.01           0.04%
std::any_of(list<int>)_(process_all)/32768       40835.01     41441.41        606.41           1.49%
std::any_of(list<int>)_(process_all)/50             46.62        46.93          0.31           0.67%
std::any_of(list<int>)_(process_all)/8               4.97         4.65         -0.31          -6.30%
std::any_of(list<int>)_(process_all)/8192        13563.04     13140.74       -422.31          -3.11%
std::any_of(vector<int>)_(process_all)/32           14.85        11.02         -3.84         -25.83%
std::any_of(vector<int>)_(process_all)/32768     14964.17     10413.30      -4550.88         -30.41%
std::any_of(vector<int>)_(process_all)/50           22.96        16.88         -6.07         -26.45%
std::any_of(vector<int>)_(process_all)/8             4.04         3.46         -0.58         -14.25%
std::any_of(vector<int>)_(process_all)/8192       3720.91      2615.87      -1105.05         -29.70%
std::none_of(deque<int>)_(process_all)/32           20.74        17.93         -2.81         -13.54%
std::none_of(deque<int>)_(process_all)/32768     20865.24     15801.21      -5064.03         -24.27%
std::none_of(deque<int>)_(process_all)/50           32.03        24.68         -7.34         -22.93%
std::none_of(deque<int>)_(process_all)/8             5.66         5.00         -0.66         -11.63%
std::none_of(deque<int>)_(process_all)/8192       5210.70      3934.79      -1275.91         -24.49%
std::none_of(list<int>)_(process_all)/32            27.97        27.74         -0.23          -0.82%
std::none_of(list<int>)_(process_all)/32768      43055.87     43134.26         78.39           0.18%
std::none_of(list<int>)_(process_all)/50            46.83        46.94          0.11           0.23%
std::none_of(list<int>)_(process_all)/8              4.88         4.95          0.07           1.43%
std::none_of(list<int>)_(process_all)/8192       13269.05     13148.32       -120.72          -0.91%
std::none_of(vector<int>)_(process_all)/32          14.90        11.05         -3.85         -25.86%
std::none_of(vector<int>)_(process_all)/32768    14942.21     10392.90      -4549.31         -30.45%
std::none_of(vector<int>)_(process_all)/50          23.08        16.82         -6.26         -27.13%
std::none_of(vector<int>)_(process_all)/8            4.03         3.46         -0.57         -14.12%
std::none_of(vector<int>)_(process_all)/8192      3712.63      2611.67      -1100.96         -29.65%
Geomean                                            216.59       180.82        -35.76         -16.51%

@ldionne
ldionne marked this pull request as ready for review July 13, 2026 17:33
@ldionne

ldionne commented Jul 21, 2026 •

Copy link
Copy Markdown
Member Author

/libcxx-bot benchmark libcxx/test/benchmarks/algorithms/nonmodifying/any_all_none_of.bench.cpp

Running benchmarks in https://github.com/llvm/llvm-project/actions/runs/29849999856

Benchmark results for Linux x86_64:
Benchmark                                        Baseline    Candidate    Difference    % Difference   Significant?   95% C.I. of %diff
---------------------------------------------  ----------  -----------  ------------  --------------  --------------  -------------------
std::all_of(deque<int>)_(process_all)/32            21.82        22.02          0.19           0.89%                  [-1.5%, +3.8%]
std::all_of(deque<int>)_(process_all)/32768      20281.51     20270.93        -10.59          -0.05%                  [-2.1%, +1.8%]
std::all_of(deque<int>)_(process_all)/50            32.95        33.57          0.62           1.89%                  [-8.9%, +9.1%]
std::all_of(deque<int>)_(process_all)/8              6.81         6.53         -0.27          -4.03%        x         [-7.4%, -1.6%]
std::all_of(deque<int>)_(process_all)/8192        5084.58      5098.18         13.60           0.27%                  [-3.3%, +2.7%]
std::all_of(list<int>)_(process_all)/32             30.81        20.47        -10.34         -33.55%        x         [-40.8%, -22.1%]
std::all_of(list<int>)_(process_all)/32768       57303.42     46172.92     -11130.50         -19.42%        x         [-24.5%, -12.3%]
std::all_of(list<int>)_(process_all)/50             57.19        39.52        -17.67         -30.90%        x         [-34.4%, -26.4%]
std::all_of(list<int>)_(process_all)/8               5.24         3.60         -1.64         -31.33%        x         [-38.6%, -21.2%]
std::all_of(list<int>)_(process_all)/8192        21463.50     20820.65       -642.86          -3.00%                  [-35.2%, +49.6%]
std::all_of(vector<int>)_(process_all)/32           21.38        11.35        -10.03         -46.89%        x         [-50.7%, -42.8%]
std::all_of(vector<int>)_(process_all)/32768     20243.51      9927.21     -10316.30         -50.96%        x         [-52.6%, -48.1%]
std::all_of(vector<int>)_(process_all)/50           31.85        16.66        -15.19         -47.69%        x         [-52.0%, -43.2%]
std::all_of(vector<int>)_(process_all)/8             5.30         3.36         -1.94         -36.65%        x         [-38.8%, -33.9%]
std::all_of(vector<int>)_(process_all)/8192       5015.11      2523.80      -2491.32         -49.68%        x         [-50.9%, -48.0%]
std::any_of(deque<int>)_(process_all)/32            21.28        17.51         -3.77         -17.69%        x         [-21.1%, -15.3%]
std::any_of(deque<int>)_(process_all)/32768      20141.76     15208.85      -4932.91         -24.49%        x         [-25.8%, -22.9%]
std::any_of(deque<int>)_(process_all)/50            32.47        25.92         -6.55         -20.18%        x         [-23.7%, -15.9%]
std::any_of(deque<int>)_(process_all)/8              6.77         5.55         -1.22         -18.04%        x         [-20.2%, -16.4%]
std::any_of(deque<int>)_(process_all)/8192        5044.12      3810.22      -1233.90         -24.46%        x         [-25.6%, -22.7%]
std::any_of(list<int>)_(process_all)/32             30.88        20.70        -10.18         -32.97%        x         [-36.1%, -29.9%]
std::any_of(list<int>)_(process_all)/32768       55474.46     44209.76     -11264.70         -20.31%                  [-133.1%, +57.7%]
std::any_of(list<int>)_(process_all)/50             57.62        39.94        -17.67         -30.67%        x         [-33.7%, -26.3%]
std::any_of(list<int>)_(process_all)/8               5.25         3.55         -1.71         -32.47%        x         [-42.7%, -15.8%]
std::any_of(list<int>)_(process_all)/8192        15231.28     13129.58      -2101.70         -13.80%        x         [-19.7%, -8.5%]
std::any_of(vector<int>)_(process_all)/32           16.70        11.06         -5.65         -33.81%        x         [-36.4%, -31.6%]
std::any_of(vector<int>)_(process_all)/32768     19740.58     10073.17      -9667.41         -48.97%        x         [-58.5%, -37.0%]
std::any_of(vector<int>)_(process_all)/50           25.97        16.82         -9.14         -35.21%        x         [-37.1%, -33.9%]
std::any_of(vector<int>)_(process_all)/8             4.27         3.38         -0.90         -21.02%        x         [-23.4%, -17.6%]
std::any_of(vector<int>)_(process_all)/8192       4622.39      2523.43      -2098.96         -45.41%        x         [-49.2%, -40.2%]
std::none_of(deque<int>)_(process_all)/32           21.39        17.43         -3.96         -18.50%        x         [-21.6%, -15.9%]
std::none_of(deque<int>)_(process_all)/32768     20346.92     15326.46      -5020.45         -24.67%        x         [-31.0%, -14.0%]
std::none_of(deque<int>)_(process_all)/50           32.54        25.65         -6.89         -21.17%        x         [-22.4%, -20.0%]
std::none_of(deque<int>)_(process_all)/8             6.73         5.62         -1.11         -16.53%        x         [-21.2%, -13.4%]
std::none_of(deque<int>)_(process_all)/8192       5138.20      3859.83      -1278.37         -24.88%        x         [-28.0%, -21.6%]
std::none_of(list<int>)_(process_all)/32            31.42        20.34        -11.08         -35.27%        x         [-41.2%, -28.6%]
std::none_of(list<int>)_(process_all)/32768      59215.52     46852.88     -12362.64         -20.88%                  [-43.7%, +15.6%]
std::none_of(list<int>)_(process_all)/50            58.54        40.18        -18.36         -31.36%        x         [-32.4%, -30.0%]
std::none_of(list<int>)_(process_all)/8              5.50         3.53         -1.97         -35.78%        x         [-47.6%, -16.7%]
std::none_of(list<int>)_(process_all)/8192       20996.82     20298.32       -698.50          -3.33%                  [-34.0%, +43.0%]
std::none_of(vector<int>)_(process_all)/32          16.66        11.05         -5.61         -33.66%        x         [-35.8%, -32.1%]
std::none_of(vector<int>)_(process_all)/32768    19883.72     10183.21      -9700.51         -48.79%        x         [-50.9%, -46.6%]
std::none_of(vector<int>)_(process_all)/50          25.57        16.38         -9.18         -35.92%        x         [-38.7%, -32.3%]
std::none_of(vector<int>)_(process_all)/8            4.22         3.33         -0.89         -21.07%        x         [-22.9%, -18.3%]
std::none_of(vector<int>)_(process_all)/8192      4390.97      2570.94      -1820.03         -41.45%        x         [-46.3%, -36.6%]
Geomean                                            252.60       182.47        -70.13         -27.76%

Benchmark results for macOS 26.5 arm64:
Benchmark                                        Baseline    Candidate    Difference    % Difference   Significant?   95% C.I. of %diff
---------------------------------------------  ----------  -----------  ------------  --------------  --------------  -------------------
std::all_of(deque<int>)_(process_all)/32            20.69        15.72         -4.97         -24.02%        x         [-24.5%, -23.3%]
std::all_of(deque<int>)_(process_all)/32768      20755.17     15614.30      -5140.87         -24.77%        x         [-26.1%, -23.7%]
std::all_of(deque<int>)_(process_all)/50            31.98        24.20         -7.78         -24.32%        x         [-24.7%, -23.5%]
std::all_of(deque<int>)_(process_all)/8              5.65         4.69         -0.95         -16.87%        x         [-17.4%, -16.1%]
std::all_of(deque<int>)_(process_all)/8192        5184.80      3890.96      -1293.84         -24.95%        x         [-25.7%, -23.6%]
std::all_of(list<int>)_(process_all)/32             21.02        17.03         -4.00         -19.00%        x         [-19.7%, -18.1%]
std::all_of(list<int>)_(process_all)/32768       41309.69     40887.31       -422.38          -1.02%                  [-3.1%, +0.5%]
std::all_of(list<int>)_(process_all)/50             38.51        31.52         -6.99         -18.15%        x         [-18.9%, -17.5%]
std::all_of(list<int>)_(process_all)/8               5.96         3.13         -2.82         -47.40%        x         [-48.0%, -46.6%]
std::all_of(list<int>)_(process_all)/8192        13891.37     11767.11      -2124.26         -15.29%                  [-51.0%, +28.5%]
std::all_of(vector<int>)_(process_all)/32           13.78         7.19         -6.60         -47.85%        x         [-48.3%, -47.3%]
std::all_of(vector<int>)_(process_all)/32768     13798.39      6413.57      -7384.82         -53.52%        x         [-53.6%, -53.3%]
std::all_of(vector<int>)_(process_all)/50           21.37        10.94        -10.43         -48.82%        x         [-49.6%, -47.8%]
std::all_of(vector<int>)_(process_all)/8             3.77         2.81         -0.95         -25.29%        x         [-25.8%, -24.5%]
std::all_of(vector<int>)_(process_all)/8192       3432.56      1608.72      -1823.84         -53.13%        x         [-53.7%, -52.5%]
std::any_of(deque<int>)_(process_all)/32            20.70        15.78         -4.91         -23.74%        x         [-24.3%, -23.4%]
std::any_of(deque<int>)_(process_all)/32768      20816.41     15641.50      -5174.91         -24.86%        x         [-25.2%, -24.3%]
std::any_of(deque<int>)_(process_all)/50            31.99        24.35         -7.64         -23.88%        x         [-24.3%, -23.6%]
std::any_of(deque<int>)_(process_all)/8              5.65         4.46         -1.19         -21.05%        x         [-21.5%, -20.7%]
std::any_of(deque<int>)_(process_all)/8192        5195.62      3900.68      -1294.95         -24.92%        x         [-25.3%, -24.5%]
std::any_of(list<int>)_(process_all)/32             19.94        17.05         -2.88         -14.46%        x         [-15.6%, -13.5%]
std::any_of(list<int>)_(process_all)/32768       39619.81     39386.56       -233.26          -0.59%                  [-12.2%, +6.2%]
std::any_of(list<int>)_(process_all)/50             38.50        31.61         -6.89         -17.89%        x         [-20.4%, -15.1%]
std::any_of(list<int>)_(process_all)/8               4.09         3.14         -0.95         -23.25%        x         [-24.2%, -22.3%]
std::any_of(list<int>)_(process_all)/8192        11638.63     12348.37        709.74           6.10%                  [-14.7%, +18.0%]
std::any_of(vector<int>)_(process_all)/32           13.83         7.22         -6.61         -47.81%        x         [-48.6%, -47.1%]
std::any_of(vector<int>)_(process_all)/32768     13805.52      6434.74      -7370.78         -53.39%        x         [-53.6%, -53.1%]
std::any_of(vector<int>)_(process_all)/50           21.33        10.99        -10.34         -48.46%        x         [-48.7%, -48.3%]
std::any_of(vector<int>)_(process_all)/8             3.77         2.51         -1.26         -33.42%        x         [-37.3%, -30.4%]
std::any_of(vector<int>)_(process_all)/8192       3433.79      1613.17      -1820.63         -53.02%        x         [-53.2%, -52.8%]
std::none_of(deque<int>)_(process_all)/32           20.73        15.75         -4.98         -24.01%        x         [-25.0%, -23.0%]
std::none_of(deque<int>)_(process_all)/32768     20781.48     15665.69      -5115.78         -24.62%        x         [-25.0%, -24.3%]
std::none_of(deque<int>)_(process_all)/50           31.97        24.29         -7.68         -24.03%        x         [-24.5%, -23.6%]
std::none_of(deque<int>)_(process_all)/8             5.65         4.46         -1.18         -20.94%        x         [-21.5%, -20.4%]
std::none_of(deque<int>)_(process_all)/8192       5187.90      3903.22      -1284.68         -24.76%        x         [-25.2%, -24.5%]
std::none_of(list<int>)_(process_all)/32            19.91        17.04         -2.87         -14.43%        x         [-14.7%, -13.9%]
std::none_of(list<int>)_(process_all)/32768      41508.78     41097.51       -411.27          -0.99%                  [-2.6%, +0.3%]
std::none_of(list<int>)_(process_all)/50            38.53        31.53         -7.00         -18.17%        x         [-18.4%, -17.7%]
std::none_of(list<int>)_(process_all)/8              4.10         3.14         -0.96         -23.46%        x         [-23.8%, -22.8%]
std::none_of(list<int>)_(process_all)/8192       15164.08     14269.04       -895.04          -5.90%                  [-26.6%, +6.4%]
std::none_of(vector<int>)_(process_all)/32          13.79         7.24         -6.55         -47.53%        x         [-47.8%, -47.3%]
std::none_of(vector<int>)_(process_all)/32768    13796.68      6446.47      -7350.21         -53.28%        x         [-53.4%, -53.1%]
std::none_of(vector<int>)_(process_all)/50          21.35        11.01        -10.34         -48.42%        x         [-48.7%, -48.2%]
std::none_of(vector<int>)_(process_all)/8            3.76         2.52         -1.25         -33.12%        x         [-33.5%, -32.7%]
std::none_of(vector<int>)_(process_all)/8192      3431.32      1616.96      -1814.37         -52.88%        x         [-53.1%, -52.7%]
Geomean                                            203.43       142.24        -61.19         -30.08%

@philnik777 philnik777 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like the compiler is finally able to vectorize most of our loops. Yay!

@ldionne
ldionne merged commit be86221 into llvm:main Jul 23, 2026
82 checks passed
@ldionne
ldionne deleted the review/rewrite-any_of branch July 23, 2026 13:38
@vitalybuka

vitalybuka commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

This patch triggers https://lab.llvm.org/buildbot/#/builders/55/builds/30810/steps/11/logs/stdio

This is not specific to a particular sanitizer, or platform.
E.g. same with ubsan on x86_64. https://lab.llvm.org/buildbot/#/builders/25/builds/18994
Maybe will trigger even without sanitizers.

Probably just FYI.
ArrayRef<int32_t> in that code is misaligned.

vitalybuka added a commit that referenced this pull request Jul 24, 2026
… type" (#211708)

Reverts #211701
Relands #209737

The buildbot failure was misattributed to this change.
Real cause is #207274
llvm-upstreamsync Bot pushed a commit to qualcomm/cpullvm-toolchain that referenced this pull request Jul 24, 2026
…into single type" (#211708)

Reverts llvm/llvm-project#211701
Relands llvm/llvm-project#209737

The buildbot failure was misattributed to this change.
Real cause is llvm/llvm-project#207274
llvm-sync Bot pushed a commit to arm/arm-toolchain that referenced this pull request Jul 24, 2026
…into single type" (#211708)

Reverts llvm/llvm-project#211701
Relands llvm/llvm-project#209737

The buildbot failure was misattributed to this change.
Real cause is llvm/llvm-project#207274
vitalybuka added a commit that referenced this pull request Jul 24, 2026
After #207274, libc++ fails __assume_aligned assertion in
__assume_valid_range.

https://lab.llvm.org/buildbot/#/builders/25/builds/18994

`DenseArrayAttrImpl<T>::operator ArrayRef<T>()` is just a cast of
`raw.data()`. `raw` is aligned copy of range from
from BytecodeReader done by
Builtin_DenseArrayRawDataParameter allocator.
However, if range is empty, aligned copying was
omitted, leaving unaligned `ArrayRef<char>`.

The fix is to replace unaligned `ArrayRef<>` with
aligned default constructed.
@vitalybuka

Copy link
Copy Markdown
Contributor

FYI @ldionne this was failed check on unaligned empty range.
Could you please confirm that __assume_valid_range is expected to check alignment for empty ranges?

midhuncodes7 pushed a commit to midhuncodes7/llvm-project that referenced this pull request Jul 28, 2026
This way, any optimizations in find_if will be picked up by any_of.

Closes llvm#129310
midhuncodes7 pushed a commit to midhuncodes7/llvm-project that referenced this pull request Jul 28, 2026
… type" (llvm#211708)

Reverts llvm#211701
Relands llvm#209737

The buildbot failure was misattributed to this change.
Real cause is llvm#207274
midhuncodes7 pushed a commit to midhuncodes7/llvm-project that referenced this pull request Jul 28, 2026
After llvm#207274, libc++ fails __assume_aligned assertion in
__assume_valid_range.

https://lab.llvm.org/buildbot/#/builders/25/builds/18994

`DenseArrayAttrImpl<T>::operator ArrayRef<T>()` is just a cast of
`raw.data()`. `raw` is aligned copy of range from
from BytecodeReader done by
Builtin_DenseArrayRawDataParameter allocator.
However, if range is empty, aligned copying was
omitted, leaving unaligned `ArrayRef<char>`.

The fix is to replace unaligned `ArrayRef<>` with
aligned default constructed.
asudarsa-qti pushed a commit to asudarsa-qti/llvm-project that referenced this pull request Jul 29, 2026
This way, any optimizations in find_if will be picked up by any_of.

Closes llvm#129310
asudarsa-qti pushed a commit to asudarsa-qti/llvm-project that referenced this pull request Jul 29, 2026
… type" (llvm#211708)

Reverts llvm#211701
Relands llvm#209737

The buildbot failure was misattributed to this change.
Real cause is llvm#207274
asudarsa-qti pushed a commit to asudarsa-qti/llvm-project that referenced this pull request Jul 29, 2026
After llvm#207274, libc++ fails __assume_aligned assertion in
__assume_valid_range.

https://lab.llvm.org/buildbot/#/builders/25/builds/18994

`DenseArrayAttrImpl<T>::operator ArrayRef<T>()` is just a cast of
`raw.data()`. `raw` is aligned copy of range from
from BytecodeReader done by
Builtin_DenseArrayRawDataParameter allocator.
However, if range is empty, aligned copying was
omitted, leaving unaligned `ArrayRef<char>`.

The fix is to replace unaligned `ArrayRef<>` with
aligned default constructed.
nekoshirro pushed a commit to nekoshirro/Alchemist-LLVM that referenced this pull request Jul 30, 2026
… type" (#211708)

Reverts llvm/llvm-project#211701
Relands llvm/llvm-project#209737

The buildbot failure was misattributed to this change.
Real cause is llvm/llvm-project#207274
Signed-off-by: Hafidz Muzakky <[email protected]>
@kevinwkt

Copy link
Copy Markdown
Contributor

@ldionne I'm getting some failures downstream due to this in libcxx hardening assertions due to check on unaligned empty range. Same question as @vitalybuka above ^

@ldionne

ldionne commented Aug 3, 2026 •

Copy link
Copy Markdown
Member Author

FYI @ldionne this was failed check on unaligned empty range. Could you please confirm that __assume_valid_range is expected to check alignment for empty ranges?

I don't think this is something we've considered before. I think it would be reasonable not to check alignment for empty ranges, but I am somewhat worried by the impact this could have on the optimizer, since the assumptions would now be gated by a runtime check. Let's follow up in the PR.

Edit: PR for the alignment issue reported above: #213752

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.

[libc++] Consider implementing std::any_of in terms of std::find_if

4 participants