[all-commits] [llvm/llvm-project] 6e3a87: [SetVector] Improve performance for small sizes
Dhruv Chawla via All-commits
all-commits at lists.llvm.org
Sat Jun 10 00:07:07 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 6e3a8720474528f8f752d0afbc6b8b9efab96325
https://github.com/llvm/llvm-project/commit/6e3a8720474528f8f752d0afbc6b8b9efab96325
Author: Dhruv Chawla <44582521+dc03 at users.noreply.github.com>
Date: 2023-06-10 (Sat, 10 Jun 2023)
Changed paths:
M flang/lib/Lower/Bridge.cpp
M llvm/include/llvm/ADT/SetVector.h
M mlir/include/mlir/Support/LLVM.h
Log Message:
-----------
[SetVector] Improve performance for small sizes
SmallSetVector has an inefficiency where it does set insertions
regardless of the number of elements present within it. This contrasts
with other "Small-" containers where they use linear scan up to a
certain size "N", after which they switch to another strategy.
This patch implements this functionality in SetVector, adding a template
parameter "N" which specifies the number of elements upto which the
SetVector follows the "small" strategy. Due to the use of "if
constexpr", there is no "small" code emitted when N is 0 which makes
this a zero overhead change for users using the default behaviour.
This change also allows having SmallSetVector use DenseSet instead of
SmallDenseSet by default, which helps a little with performance.
The reason for implementing this functionality in SetVector instead of
SmallSetVector is that it allows reusing all the code that is already
there and it is just augmented with the "isSmall" checks.
This change gives a good speedup (0.4%):
https://llvm-compile-time-tracker.com/compare.php?from=086601eac266ec253bf313c746390ff3e5656132&to=acd0a72a4d3ee840f7b455d1b35d82b11ffdb3c0&stat=instructions%3Au
Differential Revision: https://reviews.llvm.org/D152497
Commit: 8e580b7edd15e3a7fcf5951be14fb3fed519349a
https://github.com/llvm/llvm-project/commit/8e580b7edd15e3a7fcf5951be14fb3fed519349a
Author: Dhruv Chawla <44582521+dc03 at users.noreply.github.com>
Date: 2023-06-10 (Sat, 10 Jun 2023)
Changed paths:
M clang/include/clang/Sema/Sema.h
M clang/lib/Sema/SemaOverload.cpp
M clang/lib/Sema/SemaStmt.cpp
M llvm/include/llvm/ADT/GenericCycleInfo.h
M llvm/include/llvm/CodeGen/LiveRangeEdit.h
M llvm/include/llvm/Transforms/Scalar/SROA.h
M llvm/lib/Analysis/InlineCost.cpp
M llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
Log Message:
-----------
[NFC][SetVector] Update some usages of SetVector to SmallSetVector
This patch is a continuation of D152497. It updates usages of SetVector
that were found in llvm/ and clang/ which were originally specifying either
SmallPtrSet or SmallVector to just using SmallSetVector, as the overhead
of SetVector is reduced with D152497.
This also helps clean up the code a fair bit, and gives a decent speed
boost at -O0 (~0.2%):
https://llvm-compile-time-tracker.com/compare.php?from=9ffdabecabcddde298ff313f5353f9e06590af62&to=97f1c0cde42ba85eaa67cbe89bec8fe45b801f21&stat=instructions%3Au
Differential Revision: https://reviews.llvm.org/D152522
Compare: https://github.com/llvm/llvm-project/compare/8e44b849da1c...8e580b7edd15
More information about the All-commits
mailing list