File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -2075,7 +2075,8 @@ struct SimplifyDimOfAllocOp : public OpRewritePattern<memref::DimOp> {
2075
2075
return failure ();
2076
2076
2077
2077
auto memrefType = llvm::dyn_cast<MemRefType>(dimOp.getSource ().getType ());
2078
- if (!memrefType || !memrefType.isDynamicDim (index.value ()))
2078
+ if (!memrefType || index.value () >= memrefType.getRank () ||
2079
+ !memrefType.isDynamicDim (index.value ()))
2079
2080
return failure ();
2080
2081
2081
2082
auto alloc = dimOp.getSource ().getDefiningOp <AllocOp>();
Original file line number Diff line number Diff line change @@ -152,6 +152,17 @@ func.func @gpu_dim_of_alloc(%size: index) -> index {
152
152
153
153
// -----
154
154
155
+ // CHECK-LABEL: func @out_of_bound_memref.dim
156
+ // CHECK: %[[MEMREF:.[a-z0-9A-Z_]+]] = memref.dim
157
+ // CHECK: return %[[MEMREF]] : index
158
+ func.func @out_of_bound_memref.dim (%arg : memref <?xi8 >, %size: index ) -> index {
159
+ %c2 = arith.constant 2 : index
160
+ %1 = memref.dim %arg , %c2 : memref <?xi8 >
161
+ return %1 : index
162
+ }
163
+
164
+ // -----
165
+
155
166
// CHECK-LABEL: func @simplify_gpu_launch
156
167
func.func @simplify_gpu_launch () attributes {llvm.emit_c_interface } {
157
168
%cst = arith.constant 0.000000e+00 : f32
You can’t perform that action at this time.
0 commit comments