[all-commits] [llvm/llvm-project] 2a0675: [libc++][spaceship] Implement `lexicographical_com...
Adrian Vogelsgesang via All-commits
all-commits at lists.llvm.org
Sun Feb 12 14:51:47 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 2a06757a200cc8dd4c3aeca98509d50d75bb4a27
https://github.com/llvm/llvm-project/commit/2a06757a200cc8dd4c3aeca98509d50d75bb4a27
Author: Adrian Vogelsgesang <avogelsgesang at tableau.com>
Date: 2023-02-12 (Sun, 12 Feb 2023)
Changed paths:
M libcxx/benchmarks/CMakeLists.txt
A libcxx/benchmarks/lexicographical_compare_three_way.bench.cpp
M libcxx/docs/Status/Cxx20Issues.csv
M libcxx/docs/Status/Cxx2bIssues.csv
M libcxx/docs/Status/SpaceshipProjects.csv
M libcxx/include/CMakeLists.txt
A libcxx/include/__algorithm/lexicographical_compare_three_way.h
A libcxx/include/__algorithm/three_way_comp_ref_type.h
M libcxx/include/algorithm
M libcxx/include/module.modulemap.in
A libcxx/test/libcxx/algorithms/debug_three_way_comp.inconsistent.pass.cpp
M libcxx/test/libcxx/algorithms/robust_against_copying_comparators.pass.cpp
M libcxx/test/libcxx/algorithms/robust_against_cpp20_hostile_iterators.compile.pass.cpp
M libcxx/test/libcxx/diagnostics/nodiscard_extensions.verify.cpp
M libcxx/test/libcxx/private_headers.verify.cpp
A libcxx/test/std/algorithms/alg.sorting/alg.three.way/lexicographical_compare_three_way.pass.cpp
A libcxx/test/std/algorithms/alg.sorting/alg.three.way/lexicographical_compare_three_way_comp.pass.cpp
A libcxx/test/std/algorithms/alg.sorting/alg.three.way/lexicographical_compare_three_way_comp.verify.cpp
M libcxx/test/std/algorithms/robust_against_adl.compile.pass.cpp
M libcxx/test/std/algorithms/robust_re_difference_type.compile.pass.cpp
M libcxx/test/support/almost_satisfies_types.h
M libcxx/test/support/test_comparisons.h
Log Message:
-----------
[libc++][spaceship] Implement `lexicographical_compare_three_way`
The implementation makes use of the freedom added by LWG 3410. We have
two variants of this algorithm:
* a fast path for random access iterators: This fast path computes the
maximum number of loop iterations up-front and does not compare the
iterators against their limits on every loop iteration.
* A basic implementation for all other iterators: This implementation
compares the iterators against their limits in every loop iteration.
However, it still takes advantage of the freedom added by LWG 3410 to
avoid unnecessary additional iterator comparisons, as originally
specified by P1614R2.
https://godbolt.org/z/7xbMEen5e shows the benefit of the fast path:
The hot loop generated of `lexicographical_compare_three_way3` is
more tight than for `lexicographical_compare_three_way1`. The added
benchmark illustrates how this leads to a 30% - 50% performance
improvement on integer vectors.
Implements part of P1614R2 "The Mothership has Landed"
Fixes LWG 3410 and LWG 3350
Differential Revision: https://reviews.llvm.org/D131395
More information about the All-commits
mailing list