[Mlir-commits] [mlir] f778eaf - [IntegerRangeAnalysis] remove constraint on integer-typed results (#72007)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Nov 13 20:10:51 PST 2023


Author: Jeremy Kun
Date: 2023-11-13T22:10:47-06:00
New Revision: f778eafdd878e8b11ad76f9e0a312ce7791a7481

URL: https://github.com/llvm/llvm-project/commit/f778eafdd878e8b11ad76f9e0a312ce7791a7481
DIFF: https://github.com/llvm/llvm-project/commit/f778eafdd878e8b11ad76f9e0a312ce7791a7481.diff

LOG: [IntegerRangeAnalysis] remove constraint on integer-typed results (#72007)

Added: 
    

Modified: 
    mlir/include/mlir/Analysis/DataFlow/IntegerRangeAnalysis.h
    mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Analysis/DataFlow/IntegerRangeAnalysis.h b/mlir/include/mlir/Analysis/DataFlow/IntegerRangeAnalysis.h
index 99f620ed26a1b4b..8bd7cf880c6afb5 100644
--- a/mlir/include/mlir/Analysis/DataFlow/IntegerRangeAnalysis.h
+++ b/mlir/include/mlir/Analysis/DataFlow/IntegerRangeAnalysis.h
@@ -8,7 +8,10 @@
 //
 // This file declares the dataflow analysis class for integer range inference
 // so that it can be used in transformations over the `arith` dialect such as
-// branch elimination or signed->unsigned rewriting
+// branch elimination or signed->unsigned rewriting.
+//
+// One can also implement InferIntRangeInterface on ops in custom dialects,
+// and then use this analysis to propagate ranges with custom semantics.
 //
 //===----------------------------------------------------------------------===//
 
@@ -81,6 +84,9 @@ class IntegerValueRangeLattice : public Lattice<IntegerValueRange> {
 /// Integer range analysis determines the integer value range of SSA values
 /// using operations that define `InferIntRangeInterface` and also sets the
 /// range of iteration indices of loops with known bounds.
+///
+/// This analysis depends on DeadCodeAnalysis, and will be a silent no-op
+/// if DeadCodeAnalysis is not loaded in the same solver context.
 class IntegerRangeAnalysis
     : public SparseForwardDataFlowAnalysis<IntegerValueRangeLattice> {
 public:

diff  --git a/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp b/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp
index a43263bc11113b8..39b3a0996396ffb 100644
--- a/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp
+++ b/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp
@@ -79,22 +79,6 @@ void IntegerRangeAnalysis::visitOperation(
     return;
   }
 
-  // Ignore non-integer outputs - return early if the op has no scalar
-  // integer results
-  bool hasIntegerResult = false;
-  for (auto it : llvm::zip(results, op->getResults())) {
-    Value value = std::get<1>(it);
-    if (value.getType().isIntOrIndex()) {
-      hasIntegerResult = true;
-    } else {
-      IntegerValueRangeLattice *lattice = std::get<0>(it);
-      propagateIfChanged(lattice,
-                         lattice->join(IntegerValueRange::getMaxRange(value)));
-    }
-  }
-  if (!hasIntegerResult)
-    return;
-
   auto inferrable = dyn_cast<InferIntRangeInterface>(op);
   if (!inferrable)
     return setAllToEntryStates(results);


        


More information about the Mlir-commits mailing list