[Mlir-commits] [mlir] [MLIR][Bufferizer][NFC] Simplify some codes. (PR #77254)

Javed Absar llvmlistbot at llvm.org
Sun Jan 7 14:16:50 PST 2024


https://github.com/javedabsar1 updated https://github.com/llvm/llvm-project/pull/77254

>From f79452f7543462eb4f95e898d841489aa70d32a7 Mon Sep 17 00:00:00 2001
From: mabsar <javed.absar at gmail.com>
Date: Sun, 7 Jan 2024 14:19:55 -0500
Subject: [PATCH 1/2] [MLIR][Bufferizer][NFC]  Simplify some codes. Some
 cleanup

---
 .../Bufferization/Transforms/BufferViewFlowAnalysis.cpp    | 2 +-
 .../Bufferization/Transforms/EmptyTensorElimination.cpp    | 7 +++----
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/mlir/lib/Dialect/Bufferization/Transforms/BufferViewFlowAnalysis.cpp b/mlir/lib/Dialect/Bufferization/Transforms/BufferViewFlowAnalysis.cpp
index 98a60a48763ab1..943d96b9d542ab 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/BufferViewFlowAnalysis.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/BufferViewFlowAnalysis.cpp
@@ -49,7 +49,7 @@ void BufferViewFlowAnalysis::rename(Value from, Value to) {
   dependencies[to] = dependencies[from];
   dependencies.erase(from);
 
-  for (auto &[key, value] : dependencies) {
+  for (auto &[ _, value] : dependencies) {
     if (value.contains(from)) {
       value.insert(to);
       value.erase(from);
diff --git a/mlir/lib/Dialect/Bufferization/Transforms/EmptyTensorElimination.cpp b/mlir/lib/Dialect/Bufferization/Transforms/EmptyTensorElimination.cpp
index 4a418a05e6ff56..78b70114fabd12 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/EmptyTensorElimination.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/EmptyTensorElimination.cpp
@@ -53,10 +53,9 @@ neededValuesDominateInsertionPoint(const DominanceInfo &domInfo,
 static bool insertionPointDominatesUses(const DominanceInfo &domInfo,
                                         Operation *insertionPoint,
                                         Operation *emptyTensorOp) {
-  for (Operation *user : emptyTensorOp->getUsers())
-    if (!domInfo.dominates(insertionPoint, user))
-      return false;
-  return true;
+  return llvm::all_of(
+      emptyTensorOp->getUsers(),
+      [&](Operation *user) { return domInfo.dominates(insertionPoint, user); });
 }
 
 /// Find a valid insertion point for a replacement of `emptyTensorOp`, assuming

>From b30d1c7489182bb8fac7db644a7a9a1700321903 Mon Sep 17 00:00:00 2001
From: mabsar <javed.absar at gmail.com>
Date: Sun, 7 Jan 2024 15:51:51 -0500
Subject: [PATCH 2/2] [mlir][bufferizer] clang-format

---
 .../Bufferization/Transforms/BufferViewFlowAnalysis.cpp     | 2 +-
 .../Bufferization/Transforms/EmptyTensorElimination.cpp     | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/mlir/lib/Dialect/Bufferization/Transforms/BufferViewFlowAnalysis.cpp b/mlir/lib/Dialect/Bufferization/Transforms/BufferViewFlowAnalysis.cpp
index 943d96b9d542ab..88ef1b639fc5ce 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/BufferViewFlowAnalysis.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/BufferViewFlowAnalysis.cpp
@@ -49,7 +49,7 @@ void BufferViewFlowAnalysis::rename(Value from, Value to) {
   dependencies[to] = dependencies[from];
   dependencies.erase(from);
 
-  for (auto &[ _, value] : dependencies) {
+  for (auto &[_, value] : dependencies) {
     if (value.contains(from)) {
       value.insert(to);
       value.erase(from);
diff --git a/mlir/lib/Dialect/Bufferization/Transforms/EmptyTensorElimination.cpp b/mlir/lib/Dialect/Bufferization/Transforms/EmptyTensorElimination.cpp
index 78b70114fabd12..eba1273b36e242 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/EmptyTensorElimination.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/EmptyTensorElimination.cpp
@@ -53,9 +53,9 @@ neededValuesDominateInsertionPoint(const DominanceInfo &domInfo,
 static bool insertionPointDominatesUses(const DominanceInfo &domInfo,
                                         Operation *insertionPoint,
                                         Operation *emptyTensorOp) {
-  return llvm::all_of(
-      emptyTensorOp->getUsers(),
-      [&](Operation *user) { return domInfo.dominates(insertionPoint, user); });
+  return llvm::all_of(emptyTensorOp->getUsers(), [&](Operation *user) {
+    return domInfo.dominates(insertionPoint, user);
+  });
 }
 
 /// Find a valid insertion point for a replacement of `emptyTensorOp`, assuming



More information about the Mlir-commits mailing list