diff --git a/mlir/lib/Dialect/Affine/Utils/Utils.cpp b/mlir/lib/Dialect/Affine/Utils/Utils.cpp --- a/mlir/lib/Dialect/Affine/Utils/Utils.cpp +++ b/mlir/lib/Dialect/Affine/Utils/Utils.cpp @@ -622,6 +622,10 @@ newUbExprs, opBuilder.getContext()); canonicalizeMapAndOperands(&newUbMap, &ubOperands); + SmallVector lbOperands(lb.getOperands().begin(), + lb.getOperands().begin() + + lb.getMap().getNumDims()); + // Normalize the loop. op.setUpperBound(ubOperands, newUbMap); op.setLowerBound({}, opBuilder.getConstantAffineMap(0)); @@ -630,9 +634,6 @@ // Calculate the Value of new loopIV. Create affine.apply for the value of // the loopIV in normalized loop. opBuilder.setInsertionPointToStart(op.getBody()); - SmallVector lbOperands(lb.getOperands().begin(), - lb.getOperands().begin() + - lb.getMap().getNumDims()); // Add an extra dim operand for loopIV. lbOperands.push_back(op.getInductionVar()); // Add symbol operands from lower bound.