forked from OSchip/llvm-project
[MLIR] Remove dead affine.applys while generating pointwise copies
This makes no impact on the test cases because affine-data-copy-generate runs whole function canonicalization at its end; however, the latter will be removed in a pending revision. It is thus useful to clean up these affine.applys right here, and eventually, not even generate these (when the right API to compose by construction is in place). Differential Revision: https://reviews.llvm.org/D78055
This commit is contained in:
parent
2f60fbce6c
commit
ac047d9fce
|
@ -1492,6 +1492,7 @@ generatePointWiseCopy(Location loc, Value memref, Value fastMemRef,
|
||||||
SmallVector<AffineExpr, 4> fastBufExprs;
|
SmallVector<AffineExpr, 4> fastBufExprs;
|
||||||
SmallVector<Value, 4> fastBufMapOperands;
|
SmallVector<Value, 4> fastBufMapOperands;
|
||||||
AffineForOp copyNestRoot;
|
AffineForOp copyNestRoot;
|
||||||
|
SmallVector<AffineApplyOp, 4> mayBeDeadApplys;
|
||||||
for (unsigned d = 0; d < rank; ++d) {
|
for (unsigned d = 0; d < rank; ++d) {
|
||||||
auto forOp = createCanonicalizedAffineForOp(b, loc, lbOperands, lbMaps[d],
|
auto forOp = createCanonicalizedAffineForOp(b, loc, lbOperands, lbMaps[d],
|
||||||
ubOperands, ubMaps[d]);
|
ubOperands, ubMaps[d]);
|
||||||
|
@ -1510,6 +1511,7 @@ generatePointWiseCopy(Location loc, Value memref, Value fastMemRef,
|
||||||
b.getAffineDimExpr(2 * d));
|
b.getAffineDimExpr(2 * d));
|
||||||
fastBufMapOperands.push_back(offset);
|
fastBufMapOperands.push_back(offset);
|
||||||
fastBufMapOperands.push_back(forOp.getInductionVar());
|
fastBufMapOperands.push_back(forOp.getInductionVar());
|
||||||
|
mayBeDeadApplys.push_back(offset);
|
||||||
|
|
||||||
// Subscript for the slow memref being copied.
|
// Subscript for the slow memref being copied.
|
||||||
memIndices.push_back(forOp.getInductionVar());
|
memIndices.push_back(forOp.getInductionVar());
|
||||||
|
@ -1520,6 +1522,11 @@ generatePointWiseCopy(Location loc, Value memref, Value fastMemRef,
|
||||||
fastBufMap = simplifyAffineMap(fastBufMap);
|
fastBufMap = simplifyAffineMap(fastBufMap);
|
||||||
canonicalizeMapAndOperands(&fastBufMap, &fastBufMapOperands);
|
canonicalizeMapAndOperands(&fastBufMap, &fastBufMapOperands);
|
||||||
|
|
||||||
|
// Drop any dead affine.applys.
|
||||||
|
for (auto applyOp : mayBeDeadApplys)
|
||||||
|
if (applyOp.use_empty())
|
||||||
|
applyOp.erase();
|
||||||
|
|
||||||
if (!isCopyOut) {
|
if (!isCopyOut) {
|
||||||
// Copy in.
|
// Copy in.
|
||||||
auto load = b.create<AffineLoadOp>(loc, memref, memIndices);
|
auto load = b.create<AffineLoadOp>(loc, memref, memIndices);
|
||||||
|
|
Loading…
Reference in New Issue