[all-commits] [llvm/llvm-project] aff3cd: [libc++] Optimize std::ranges::{min, max} for type...

philnik777 via All-commits all-commits at lists.llvm.org
Sat Mar 11 07:28:39 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: aff3cdc604b01d3db1674e8d1402a5e5727fa087
      https://github.com/llvm/llvm-project/commit/aff3cdc604b01d3db1674e8d1402a5e5727fa087
  Author: Nikolas Klauser <nikolasklauser at berlin.de>
  Date:   2023-03-11 (Sat, 11 Mar 2023)

  Changed paths:
    M libcxx/benchmarks/CMakeLists.txt
    A libcxx/benchmarks/algorithms/min.bench.cpp
    M libcxx/include/__algorithm/ranges_max.h
    M libcxx/include/__algorithm/ranges_min.h
    M libcxx/include/__type_traits/is_trivially_copyable.h
    M libcxx/test/libcxx/transitive_includes/cxx2b.csv
    M libcxx/test/std/algorithms/alg.sorting/alg.min.max/ranges.max.pass.cpp
    M libcxx/test/std/algorithms/alg.sorting/alg.min.max/ranges.min.pass.cpp

  Log Message:
  -----------
  [libc++] Optimize std::ranges::{min, max} for types that are cheap to copy

Don't forward to `min_element` for small types that are trivially copyable, and instead use a naive loop that keeps track of the smallest element (as opposed to an iterator to the smallest element). This allows the compiler to vectorize the loop in some cases.

Reviewed By: #libc, ldionne

Spies: ldionne, libcxx-commits

Differential Revision: https://reviews.llvm.org/D143596




More information about the All-commits mailing list