forked from OSchip/llvm-project
[MLIR] Fix memref region compute for 0-d memref accesses
Fix memref region compute for 0-d memref accesses in certain cases (when there are loops surrounding such 0-d accesses). Differential Revision: https://reviews.llvm.org/D81792
This commit is contained in:
parent
e00dcf61a2
commit
7965dd79a3
|
|
@ -208,13 +208,17 @@ LogicalResult MemRefRegion::compute(Operation *op, unsigned loopDepth,
|
|||
LLVM_DEBUG(llvm::dbgs() << "MemRefRegion::compute: " << *op
|
||||
<< "depth: " << loopDepth << "\n";);
|
||||
|
||||
// 0-d memrefs.
|
||||
if (rank == 0) {
|
||||
SmallVector<AffineForOp, 4> ivs;
|
||||
getLoopIVs(*op, &ivs);
|
||||
SmallVector<Value, 8> regionSymbols;
|
||||
assert(loopDepth <= ivs.size() && "invalid 'loopDepth'");
|
||||
// The first 'loopDepth' IVs are symbols for this region.
|
||||
ivs.resize(loopDepth);
|
||||
SmallVector<Value, 4> regionSymbols;
|
||||
extractForInductionVars(ivs, ®ionSymbols);
|
||||
// A rank 0 memref has a 0-d region.
|
||||
cst.reset(rank, loopDepth, 0, regionSymbols);
|
||||
// A 0-d memref has a 0-d region.
|
||||
cst.reset(rank, loopDepth, /*numLocals=*/0, regionSymbols);
|
||||
return success();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -284,3 +284,12 @@ func @non_composed_bound_operand(%arg0: memref<1024xf32>) {
|
|||
}
|
||||
return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: func @zero_d_memref
|
||||
func @zero_d_memref() {
|
||||
%Z = alloc() : memref<f32>
|
||||
affine.for %i = 0 to 100 {
|
||||
affine.load %Z[] : memref<f32>
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue