diff --git a/mlir/lib/Analysis/LoopAnalysis.cpp b/mlir/lib/Analysis/LoopAnalysis.cpp --- a/mlir/lib/Analysis/LoopAnalysis.cpp +++ b/mlir/lib/Analysis/LoopAnalysis.cpp @@ -35,18 +35,16 @@ void mlir::buildTripCountMapAndOperands( AffineForOp forOp, AffineMap *tripCountMap, SmallVectorImpl *tripCountOperands) { - int64_t loopSpan; - + MLIRContext *context = forOp.getContext(); int64_t step = forOp.getStep(); - OpBuilder b(forOp.getOperation()); - + int64_t loopSpan; if (forOp.hasConstantBounds()) { int64_t lb = forOp.getConstantLowerBound(); int64_t ub = forOp.getConstantUpperBound(); loopSpan = ub - lb; if (loopSpan < 0) loopSpan = 0; - *tripCountMap = b.getConstantAffineMap(ceilDiv(loopSpan, step)); + *tripCountMap = AffineMap::getConstantMap(ceilDiv(loopSpan, step), context); tripCountOperands->clear(); return; } @@ -65,7 +63,7 @@ SmallVector lbSplatExpr(ubValueMap.getNumResults(), lbMap.getResult(0)); auto lbMapSplat = AffineMap::get(lbMap.getNumDims(), lbMap.getNumSymbols(), - lbSplatExpr, b.getContext()); + lbSplatExpr, context); AffineValueMap lbSplatValueMap(lbMapSplat, forOp.getLowerBoundOperands()); AffineValueMap tripCountValueMap;