forked from OSchip/llvm-project
Fix 0-d memref corner case for getMemRefRegion()
- fix crash on test/Transforms/canonicalize.mlir with -memref-bound-check PiperOrigin-RevId: 228268486
This commit is contained in:
parent
c449e46ceb
commit
e94ba6815a
|
@ -134,6 +134,15 @@ bool mlir::getMemRefRegion(OperationInst *opInst, unsigned loopDepth,
|
|||
// Build the constraints for this region.
|
||||
FlatAffineConstraints *regionCst = region->getConstraints();
|
||||
|
||||
if (rank == 0) {
|
||||
// A rank 0 memref has a 0-d region.
|
||||
SmallVector<ForInst *, 4> ivs;
|
||||
getLoopIVs(*opInst, &ivs);
|
||||
SmallVector<Value *, 4> regionSymbols(ivs.begin(), ivs.end());
|
||||
regionCst->reset(0, loopDepth, 0, regionSymbols);
|
||||
return true;
|
||||
}
|
||||
|
||||
FuncBuilder b(opInst);
|
||||
auto idMap = b.getMultiDimIdentityMap(rank);
|
||||
|
||||
|
|
|
@ -160,3 +160,11 @@ func @delinearize_mod_floordiv() {
|
|||
}
|
||||
return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: func @zero_d_memref
|
||||
func @zero_d_memref(%arg0: memref<i32>) {
|
||||
%c0 = constant 0 : i32
|
||||
// A 0-d memref always has in-bound accesses!
|
||||
store %c0, %arg0[] : memref<i32>
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue