[Mlir-commits] [mlir] 3206247 - [NFC] Follow up on D87111 - Add an option for unrolling loops up to a factor - CR issues addressed.

Lubomir Litchev llvmlistbot at llvm.org
Fri Sep 11 08:12:53 PDT 2020


Author: Lubomir Litchev
Date: 2020-09-11T08:12:44-07:00
New Revision: 320624784c49ccaa0fb6dc5147a9c94d9170afb7

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

LOG: [NFC] Follow up on D87111 - Add an option for unrolling loops up to a factor - CR issues addressed.

Addressed some CR issues pointed out in D87111. Formatting and other nits.
The original Diff D87111 - Add an option for unrolling loops up to a factor.

Reviewed By: bondhugula

Differential Revision: https://reviews.llvm.org/D87313

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/Affine/Passes.td
    mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp
    mlir/test/Dialect/SCF/loop-unroll.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Affine/Passes.td b/mlir/include/mlir/Dialect/Affine/Passes.td
index 7515dbaa33d8..4359ea0fa0a2 100644
--- a/mlir/include/mlir/Dialect/Affine/Passes.td
+++ b/mlir/include/mlir/Dialect/Affine/Passes.td
@@ -71,8 +71,8 @@ def AffineLoopUnroll : FunctionPass<"affine-loop-unroll"> {
   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
index 3dc236f3c068..26669967ff32 100644
--- a/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/LoopUnroll.cpp
@@ -127,9 +127,8 @@ LogicalResult LoopUnroll::runOnAffineForOp(AffineForOp forOp) {
   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
index 134daa303ed8..0b6e178ed0aa 100644
--- a/mlir/test/Dialect/SCF/loop-unroll.mlir
+++ b/mlir/test/Dialect/SCF/loop-unroll.mlir
@@ -250,23 +250,23 @@ func @static_loop_unroll_by_3_promote_epilogue(%arg0 : memref<?xf32>) {
 //  UNROLL-BY-3-NEXT:  store %{{.*}}, %[[MEM]][%[[C9]]] : memref<?xf32>
 //  UNROLL-BY-3-NEXT:  return
 
-
 // Test unroll-up-to functionality.
 func @static_loop_unroll_up_to_factor(%arg0 : memref<?xf32>) {
   %0 = constant 7.0 : f32
   %lb = constant 0 : index
   %ub = constant 2 : index
   affine.for %i0 = %lb to %ub {
-    store %0, %arg0[%i0] : memref<?xf32>
+    affine.store %0, %arg0[%i0] : memref<?xf32>
   }
   return
 }
 // UNROLL-UP-TO-LABEL: func @static_loop_unroll_up_to_factor
 //  UNROLL-UP-TO-SAME:  %[[MEM:.*0]]: memref<?xf32>
-//  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<?xf32>
-//  UNROLL-UP-TO-NEXT: %[[V1:.*]] = affine.apply {{.*}}
-//  UNROLL-UP-TO-NEXT: tore %{{.*}}, %[[MEM]][%[[V1]]] : memref<?xf32>
-//  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<?xf32>
+//   UNROLL-UP-TO-NEXT: %[[V1:.*]] = affine.apply {{.*}}
+//   UNROLL-UP-TO-NEXT: affine.store %{{.*}}, %[[MEM]][%[[V1]]] : memref<?xf32>
+//   UNROLL-UP-TO-NEXT: return
\ No newline at end of file


        


More information about the Mlir-commits mailing list