Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/Operation.h"
#include "mlir/IR/OperationSupport.h"
#include "mlir/IR/TypeUtilities.h"
#include "mlir/IR/Value.h"
#include "mlir/Interfaces/ControlFlowInterfaces.h"
Expand All @@ -28,6 +30,7 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/DebugLog.h"
#include <cassert>
#include <optional>
#include <utility>
Expand Down Expand Up @@ -87,7 +90,8 @@ LogicalResult IntegerRangeAnalysis::visitOperation(
return success();
}

LLVM_DEBUG(llvm::dbgs() << "Inferring ranges for " << *op << "\n");
LDBG() << "Inferring ranges for "
<< OpWithFlags(op, OpPrintingFlags().skipRegions());
auto argRanges = llvm::map_to_vector(
operands, [](const IntegerValueRangeLattice *lattice) {
return lattice->getValue();
Expand All @@ -99,7 +103,7 @@ LogicalResult IntegerRangeAnalysis::visitOperation(
return;
assert(llvm::is_contained(op->getResults(), result));

LLVM_DEBUG(llvm::dbgs() << "Inferred range " << attrs << "\n");
LDBG() << "Inferred range " << attrs;
IntegerValueRangeLattice *lattice = results[result.getResultNumber()];
IntegerValueRange oldRange = lattice->getValue();

Expand All @@ -114,7 +118,7 @@ LogicalResult IntegerRangeAnalysis::visitOperation(
});
if (isYieldedResult && !oldRange.isUninitialized() &&
!(lattice->getValue() == oldRange)) {
LLVM_DEBUG(llvm::dbgs() << "Loop variant loop result detected\n");
LDBG() << "Loop variant loop result detected";
changed |= lattice->join(IntegerValueRange::getMaxRange(v));
}
propagateIfChanged(lattice, changed);
Expand All @@ -128,7 +132,8 @@ void IntegerRangeAnalysis::visitNonControlFlowArguments(
Operation *op, const RegionSuccessor &successor,
ArrayRef<IntegerValueRangeLattice *> argLattices, unsigned firstIndex) {
if (auto inferrable = dyn_cast<InferIntRangeInterface>(op)) {
LLVM_DEBUG(llvm::dbgs() << "Inferring ranges for " << *op << "\n");
LDBG() << "Inferring ranges for "
<< OpWithFlags(op, OpPrintingFlags().skipRegions());

auto argRanges = llvm::map_to_vector(op->getOperands(), [&](Value value) {
return getLatticeElementFor(getProgramPointAfter(op), value)->getValue();
Expand All @@ -141,7 +146,7 @@ void IntegerRangeAnalysis::visitNonControlFlowArguments(
if (!llvm::is_contained(successor.getSuccessor()->getArguments(), arg))
return;

LLVM_DEBUG(llvm::dbgs() << "Inferred range " << attrs << "\n");
LDBG() << "Inferred range " << attrs;
IntegerValueRangeLattice *lattice = argLattices[arg.getArgNumber()];
IntegerValueRange oldRange = lattice->getValue();

Expand All @@ -156,7 +161,7 @@ void IntegerRangeAnalysis::visitNonControlFlowArguments(
});
if (isYieldedValue && !oldRange.isUninitialized() &&
!(lattice->getValue() == oldRange)) {
LLVM_DEBUG(llvm::dbgs() << "Loop variant loop result detected\n");
LDBG() << "Loop variant loop result detected";
changed |= lattice->join(IntegerValueRange::getMaxRange(v));
}
propagateIfChanged(lattice, changed);
Expand Down