[llvm] [MemDep] Optimize SortNonLocalDepInfoCache sorting strategy for large caches with few unsorted entries (PR #143107)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 11 01:26:40 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp -- llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
index 8dffb3e42..f120b2f68 100644
--- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -49,9 +49,9 @@
#include "llvm/Support/Debug.h"
#include <algorithm>
#include <cassert>
+#include <cmath>
#include <iterator>
#include <utility>
-#include <cmath>
using namespace llvm;
@@ -998,16 +998,15 @@ SortNonLocalDepInfoCache(MemoryDependenceResults::NonLocalDepInfo &Cache,
auto s = Cache.size() - NumSortedEntries;
if (s < log2(Cache.size()) * ln2) {
- while (s>0) {
+ while (s > 0) {
NonLocalDepEntry Val = Cache.back();
Cache.pop_back();
MemoryDependenceResults::NonLocalDepInfo::iterator Entry =
- std::upper_bound(Cache.begin(), Cache.end() - 1, Val);
+ std::upper_bound(Cache.begin(), Cache.end() - 1, Val);
Cache.insert(Entry, Val);
s--;
}
- }
- else {
+ } else {
llvm::sort(Cache);
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/143107
More information about the llvm-commits
mailing list