Skip to content

Commit 4aae9fe

Browse files
committed
added check for affine.for bounds
1 parent e8894d1 commit 4aae9fe

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

mlir/lib/Dialect/Affine/IR/AffineOps.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,6 +1903,12 @@ LogicalResult AffineForOp::verifyRegions() {
19031903
getUpperBoundMap().getNumDims())))
19041904
return failure();
19051905

1906+
if (getLowerBoundMap().getNumResults() < 1)
1907+
return emitOpError("expected lower bound map to have at least one result");
1908+
1909+
if (getUpperBoundMap().getNumResults() < 1)
1910+
return emitOpError("expected upper bound map to have at least one result");
1911+
19061912
unsigned opNumResults = getNumResults();
19071913
if (opNumResults == 0)
19081914
return success();

mlir/test/Dialect/Affine/invalid.mlir

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,3 +541,25 @@ func.func @dynamic_dimension_index() {
541541
}) : () -> ()
542542
return
543543
}
544+
545+
// -----
546+
547+
#map = affine_map<() -> ()>
548+
#map1 = affine_map<() -> (1)>
549+
func.func @no_lower_bound() {
550+
// expected-error@+1 {{'affine.for' op expected lower bound map to have at least one result}}
551+
affine.for %i = max #map() to min #map1() {
552+
}
553+
return
554+
}
555+
556+
// -----
557+
558+
#map = affine_map<() -> ()>
559+
#map1 = affine_map<() -> (1)>
560+
func.func @no_upper_bound() {
561+
// expected-error@+1 {{'affine.for' op expected upper bound map to have at least one result}}
562+
affine.for %i = max #map1() to min #map() {
563+
}
564+
return
565+
}

0 commit comments

Comments
 (0)