diff --git a/mlir/include/mlir/Dialect/Affine/Passes.td b/mlir/include/mlir/Dialect/Affine/Passes.td --- a/mlir/include/mlir/Dialect/Affine/Passes.td +++ b/mlir/include/mlir/Dialect/Affine/Passes.td @@ -71,8 +71,8 @@ let options = [ Option<"unrollFactor", "unroll-factor", "unsigned", /*default=*/"4", "Use this unroll factor for all loops being unrolled">, - Option<"unrollUpToFactor", "unroll-up-to-factor", "bool", /*default=*/"false", - "Allow unroling up to the factor specicied">, + Option<"unrollUpToFactor", "unroll-up-to-factor", "bool", + /*default=*/"false", "Allow unrolling up to the factor specified">, Option<"unrollFull", "unroll-full", "bool", /*default=*/"false", "Fully unroll loops">, Option<"numRepetitions", "unroll-num-reps", "unsigned", /*default=*/"1", diff --git a/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp --- a/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp @@ -127,9 +127,8 @@ if (unrollFull) return loopUnrollFull(forOp); // Otherwise, unroll by the given unroll factor. - if (unrollUpToFactor) { + if (unrollUpToFactor) return loopUnrollUpToFactor(forOp, unrollFactor); - } return loopUnrollByFactor(forOp, unrollFactor); } diff --git a/mlir/test/Dialect/SCF/loop-unroll.mlir b/mlir/test/Dialect/SCF/loop-unroll.mlir --- a/mlir/test/Dialect/SCF/loop-unroll.mlir +++ b/mlir/test/Dialect/SCF/loop-unroll.mlir @@ -250,23 +250,23 @@ // UNROLL-BY-3-NEXT: store %{{.*}}, %[[MEM]][%[[C9]]] : memref // UNROLL-BY-3-NEXT: return - // Test unroll-up-to functionality. func @static_loop_unroll_up_to_factor(%arg0 : memref) { %0 = constant 7.0 : f32 %lb = constant 0 : index %ub = constant 2 : index affine.for %i0 = %lb to %ub { - store %0, %arg0[%i0] : memref + affine.store %0, %arg0[%i0] : memref } return } // UNROLL-UP-TO-LABEL: func @static_loop_unroll_up_to_factor // UNROLL-UP-TO-SAME: %[[MEM:.*0]]: memref -// UNROLL-UP-TO-DAG: %[[C0:.*]] = constant 0 : index -// UNROLL-UP-TO-DAG: %[[C2:.*]] = constant 2 : index -// UNROLL-UP-TO-NEXT: %[[V0:.*]] = affine.apply {{.*}} -// UNROLL-UP-TO-NEXT: store %{{.*}}, %[[MEM]][%[[V0]]] : memref -// UNROLL-UP-TO-NEXT: %[[V1:.*]] = affine.apply {{.*}} -// UNROLL-UP-TO-NEXT: tore %{{.*}}, %[[MEM]][%[[V1]]] : memref -// UNROLL-UP-TO-NEXT: return +// +// UNROLL-UP-TO-DAG: %[[C0:.*]] = constant 0 : index +// UNROLL-UP-TO-DAG: %[[C2:.*]] = constant 2 : index +// UNROLL-UP-TO-NEXT: %[[V0:.*]] = affine.apply {{.*}} +// UNROLL-UP-TO-NEXT: store %{{.*}}, %[[MEM]][%[[V0]]] : memref +// UNROLL-UP-TO-NEXT: %[[V1:.*]] = affine.apply {{.*}} +// UNROLL-UP-TO-NEXT: affine.store %{{.*}}, %[[MEM]][%[[V1]]] : memref +// UNROLL-UP-TO-NEXT: return \ No newline at end of file