forked from OSchip/llvm-project
[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
This commit is contained in:
parent
f92908cc74
commit
320624784c
|
@ -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",
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue