[Mlir-commits] [mlir] Amortize cost of block op index lookups (PR #156027)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Aug 29 07:11:23 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 origin/main HEAD --extensions cpp -- mlir/lib/Dialect/Affine/Analysis/Utils.cpp
``````````
: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/mlir/lib/Dialect/Affine/Analysis/Utils.cpp b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp
index dbb02015f..c9e1ef978 100644
--- a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp
+++ b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp
@@ -1442,12 +1442,14 @@ template LogicalResult
mlir::affine::boundCheckLoadOrStoreOp(AffineWriteOpInterface storeOp,
bool emitError);
-static inline unsigned getIndexInBlock(Operation *op, llvm::DenseMap<Block*, llvm::DenseMap<Operation*, unsigned>> &cache) {
+static inline unsigned getIndexInBlock(
+ Operation *op,
+ llvm::DenseMap<Block *, llvm::DenseMap<Operation *, unsigned>> &cache) {
Block *block = op->getBlock();
auto &blockMap = cache[block];
- if(blockMap.empty()) {
+ if (blockMap.empty()) {
unsigned idx = 0;
- for (Operation &it: *block)
+ for (Operation &it : *block)
blockMap[&it] = idx++;
}
return blockMap.lookup(op);
@@ -1457,7 +1459,7 @@ static inline unsigned getIndexInBlock(Operation *op, llvm::DenseMap<Block*, llv
// Block from the Block containing operation, stopping at 'limitBlock'.
static void findInstPosition(Operation *op, Block *limitBlock,
SmallVectorImpl<unsigned> *positions) {
- llvm::DenseMap<Block*, llvm::DenseMap<Operation*, unsigned>> indexCache;
+ llvm::DenseMap<Block *, llvm::DenseMap<Operation *, unsigned>> indexCache;
Block *block = op->getBlock();
while (block != limitBlock) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/156027
More information about the Mlir-commits
mailing list