[mlir][normalize-memrefs] NFC Follow-up D125854

NFC follow-up D125854 to reflect some remaining comments in D125854

Reviewed By: bondhugula

Differential Revision: https://reviews.llvm.org/D132200
This commit is contained in:
Tung D. Le 2022-08-20 07:30:28 +05:30 committed by Uday Bondhugula
parent 5263155d5b
commit d4284baf1e
1 changed files with 6 additions and 11 deletions

View File

@ -157,10 +157,7 @@ bool NormalizeMemRefs::areMemRefsNormalizable(func::FuncOp funcOp) {
if (funcOp
.walk([&](memref::AllocOp allocOp) -> WalkResult {
Value oldMemRef = allocOp.getResult();
if (!oldMemRef.getType()
.cast<MemRefType>()
.getLayout()
.isIdentity() &&
if (!allocOp.getType().getLayout().isIdentity() &&
!isMemRefNormalizable(oldMemRef.getUsers()))
return WalkResult::interrupt();
return WalkResult::advance();
@ -173,11 +170,9 @@ bool NormalizeMemRefs::areMemRefsNormalizable(func::FuncOp funcOp) {
for (unsigned resIndex :
llvm::seq<unsigned>(0, callOp.getNumResults())) {
Value oldMemRef = callOp.getResult(resIndex);
if (oldMemRef.getType().isa<MemRefType>())
if (!oldMemRef.getType()
.cast<MemRefType>()
.getLayout()
.isIdentity() &&
if (auto oldMemRefType =
oldMemRef.getType().dyn_cast<MemRefType>())
if (!oldMemRefType.getLayout().isIdentity() &&
!isMemRefNormalizable(oldMemRef.getUsers()))
return WalkResult::interrupt();
}
@ -188,8 +183,8 @@ bool NormalizeMemRefs::areMemRefsNormalizable(func::FuncOp funcOp) {
for (unsigned argIndex : llvm::seq<unsigned>(0, funcOp.getNumArguments())) {
BlockArgument oldMemRef = funcOp.getArgument(argIndex);
if (oldMemRef.getType().isa<MemRefType>())
if (!oldMemRef.getType().cast<MemRefType>().getLayout().isIdentity() &&
if (auto oldMemRefType = oldMemRef.getType().dyn_cast<MemRefType>())
if (!oldMemRefType.getLayout().isIdentity() &&
!isMemRefNormalizable(oldMemRef.getUsers()))
return false;
}