[Mlir-commits] [mlir] [mlir][dataflow] Fix for integer range analysis propagation bug (PR #93199)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu May 23 15:57:32 PDT 2024


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 bdbf927a838e1b23982987febc0945a9f9a3acf0 2f5a4030cc54ebf6e0e23afe940cd47bbf3ca35d -- mlir/include/mlir/Analysis/DataFlow/IntegerRangeAnalysis.h mlir/include/mlir/Interfaces/InferIntRangeInterface.h mlir/include/mlir/Interfaces/Utils/InferIntRangeCommon.h mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp mlir/lib/Dialect/Arith/IR/InferIntRangeInterfaceImpls.cpp mlir/lib/Dialect/GPU/IR/InferIntRangeInterfaceImpls.cpp mlir/lib/Dialect/Index/IR/InferIntRangeInterfaceImpls.cpp mlir/lib/Interfaces/Utils/InferIntRangeCommon.cpp mlir/test/lib/Dialect/Test/TestOpDefs.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp b/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp
index 96be36bb4b..87106dac5e 100644
--- a/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp
+++ b/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp
@@ -44,7 +44,8 @@ OptionalIntRanges getOptionalRange(const IntegerValueRange &range) {
   return range.getValue();
 }
 
-OptionalIntRanges getOptionalRangeFromLattice(const IntegerValueRangeLattice* lattice) {
+OptionalIntRanges
+getOptionalRangeFromLattice(const IntegerValueRangeLattice *lattice) {
   return getOptionalRange(lattice->getValue());
 }
 
@@ -93,8 +94,8 @@ void IntegerRangeAnalysis::visitOperation(
     return setAllToEntryStates(results);
 
   LLVM_DEBUG(llvm::dbgs() << "Inferring ranges for " << *op << "\n");
-  SmallVector<OptionalIntRanges> argRanges(llvm::map_range(
-      operands, getOptionalRangeFromLattice));
+  SmallVector<OptionalIntRanges> argRanges(
+      llvm::map_range(operands, getOptionalRangeFromLattice));
 
   auto joinCallback = [&](Value v, const OptionalIntRanges &attrs) {
     auto result = dyn_cast<OpResult>(v);
diff --git a/mlir/lib/Interfaces/Utils/InferIntRangeCommon.cpp b/mlir/lib/Interfaces/Utils/InferIntRangeCommon.cpp
index 0c5ce2b021..42b483a188 100644
--- a/mlir/lib/Interfaces/Utils/InferIntRangeCommon.cpp
+++ b/mlir/lib/Interfaces/Utils/InferIntRangeCommon.cpp
@@ -38,18 +38,19 @@ using ConstArithFn =
 
 std::function<OptionalIntRanges(llvm::ArrayRef<OptionalIntRanges>)>
 mlir::intrange::inferFromOptionals(intrange::InferRangeFn inferFn) {
-  return [inferFn](llvm::ArrayRef<OptionalIntRanges> args) -> OptionalIntRanges {
-    llvm::SmallVector<ConstantIntRanges> unpacked;
-    unpacked.reserve(args.size());
-
-    for (const OptionalIntRanges &arg : args) {
-      if (!arg)
-        return std::nullopt;
-      unpacked.push_back(*arg);
-    }
+  return
+      [inferFn](llvm::ArrayRef<OptionalIntRanges> args) -> OptionalIntRanges {
+        llvm::SmallVector<ConstantIntRanges> unpacked;
+        unpacked.reserve(args.size());
+
+        for (const OptionalIntRanges &arg : args) {
+          if (!arg)
+            return std::nullopt;
+          unpacked.push_back(*arg);
+        }
 
-    return inferFn(unpacked);
-  };
+        return inferFn(unpacked);
+      };
 }
 
 /// Compute op(minLeft, minRight) and op(maxLeft, maxRight) if possible,

``````````

</details>


https://github.com/llvm/llvm-project/pull/93199


More information about the Mlir-commits mailing list