[llvm] [AArch64] ConditionOptimizer: replace per-block DenseMap with ScopedHashTable traversal (PR #196746)
via llvm-commits
llvm-commits at lists.llvm.org
Sat May 9 12:48:08 PDT 2026
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 origin/main HEAD --extensions cpp -- llvm/lib/Target/AArch64/AArch64ConditionOptimizer.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Target/AArch64/AArch64ConditionOptimizer.cpp b/llvm/lib/Target/AArch64/AArch64ConditionOptimizer.cpp
index f0076f917..9e110629e 100644
--- a/llvm/lib/Target/AArch64/AArch64ConditionOptimizer.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ConditionOptimizer.cpp
@@ -9,22 +9,24 @@
// This pass tries to make consecutive comparisons of values use the same
// operands to allow the CSE pass to remove duplicate instructions.
//
-// For two producer-consumer pairs P1 = (v, N1, CC1) and P2 = (v, N2, CC2) over F
-// where:
+// For two producer-consumer pairs P1 = (v, N1, CC1) and P2 = (v, N2, CC2) over
+// F where:
// - v is a shared operand
// - Nx are the immediates being compared such that 1 <= |N1 - N2| <= 2
// - CCx are ordered conditions tested by the consumers (GT/LT/GE/LE)
// - (Nx, CCx) are predicates over v
-// - F is a flag register, implicitly defined by the producers and tested by the consumers
+// - F is a flag register, implicitly defined by the producers and tested by the
+// consumers
// - No instruction between P1 and P2 reads or writes F
-//
+//
// Apply the following transformation:
// 1. Find an immediate N' reachable from N1 and N2 via +-1 adjustment
-// 2. Derive CC1' and CC2' such that P1' = (v, N', CC1') and P2' = (v, N', CC2') are
+// 2. Derive CC1' and CC2' such that P1' = (v, N', CC1') and P2' = (v, N', CC2')
+// are
// semantically equivalent to the originals
// 3. Modify the producers to compare against N'
// 4. Modify the consumers to test CC1' and CC2', respectively
-//
+//
// This enables CSE to eliminate one of the compares.
//
// Consider the following example in C:
@@ -434,8 +436,7 @@ bool AArch64ConditionOptimizerImpl::commitPendingPair(
Register Key = Reg.isVirtual() ? TRI->lookThruCopyLike(Reg, MRI) : Reg;
CmpCondPair Prior = BlockPairs.lookup(Key);
- bool Changed =
- Prior.CmpMI && tryOptimizePair(Prior, *PendingPair);
+ bool Changed = Prior.CmpMI && tryOptimizePair(Prior, *PendingPair);
BlockPairs.insert(Key, *PendingPair);
PendingPair = std::nullopt;
``````````
</details>
https://github.com/llvm/llvm-project/pull/196746
More information about the llvm-commits
mailing list