forked from OSchip/llvm-project
[MLIR] Fix affine loop unroll corner case for full unroll
Fix affine loop unroll for zero trip count loops. Add missing check. Differential Revision: https://reviews.llvm.org/D111375
This commit is contained in:
parent
c59ebe4c4c
commit
b2217b36fe
|
@ -1052,6 +1052,8 @@ LogicalResult mlir::loopUnrollFull(AffineForOp forOp) {
|
|||
Optional<uint64_t> mayBeConstantTripCount = getConstantTripCount(forOp);
|
||||
if (mayBeConstantTripCount.hasValue()) {
|
||||
uint64_t tripCount = mayBeConstantTripCount.getValue();
|
||||
if (tripCount == 0)
|
||||
return success();
|
||||
if (tripCount == 1)
|
||||
return promoteIfSingleIteration(forOp);
|
||||
return loopUnrollByFactor(forOp, tripCount);
|
||||
|
|
|
@ -641,3 +641,11 @@ func @unroll_with_iter_args_and_promotion(%arg0 : f32, %arg1 : f32) -> f32 {
|
|||
// UNROLL-BY-4-NEXT: return %[[RES]]
|
||||
return %sum : f32
|
||||
}
|
||||
|
||||
// UNROLL-FULL: func @unroll_zero_trip_count_case
|
||||
func @unroll_zero_trip_count_case() {
|
||||
// CHECK-NEXT: affine.for %{{.*}} = 0 to 0
|
||||
affine.for %i = 0 to 0 {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue