Skip to content

Commit

Permalink
Remove redundant code; switch to `OperationEquivalence::isEquivalentT…
Browse files Browse the repository at this point in the history
…o` (#1981)
  • Loading branch information
erwei-xilinx authored Dec 16, 2024
1 parent a40a674 commit 4e02468
Showing 1 changed file with 6 additions and 34 deletions.
40 changes: 6 additions & 34 deletions lib/Dialect/AIE/IR/AIEDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1949,38 +1949,7 @@ static LogicalResult FoldDMAStartOp(DMAStartOp op, PatternRewriter &rewriter) {
return failure();

// Check for identical bds.
auto areIdenticalUseLocks = [](UseLockOp op1, UseLockOp op2) {
if (!op1 || !op2)
return false;
if (op1.getLock() != op2.getLock())
return false;
if (op1.getAction() != op2.getAction())
return false;
if (op1.getValue() != op2.getValue())
return false;
return true;
};
auto areIdenticalDmaBDOps = [](DMABDOp op1, DMABDOp op2) {
if (!op1 || !op2)
return false;
if (op1.getBuffer() != op2.getBuffer())
return false;
if (op1.getOffset() != op2.getOffset())
return false;
if (op1.getLen() != op2.getLen())
return false;
if (op1.getDimensions() != op2.getDimensions())
return false;
if (op1.getPadDimensions() != op2.getPadDimensions())
return false;
if (op1.getPadValue() != op2.getPadValue())
return false;
if (op1.getPacket() != op2.getPacket())
return false;
return true;
};
auto areIdenticalBDs = [areIdenticalUseLocks,
areIdenticalDmaBDOps](Block *b1, Block *b2) {
auto areIdenticalBDs = [](Block *b1, Block *b2) {
auto b1OpRange = b1->without_terminator();
auto b2OpRange = b2->without_terminator();
if (llvm::range_size(b1OpRange) != llvm::range_size(b2OpRange))
Expand All @@ -1993,11 +1962,14 @@ static LogicalResult FoldDMAStartOp(DMAStartOp op, PatternRewriter &rewriter) {

if (auto b1UseLockOp = dyn_cast<UseLockOp>(*b1It)) {
auto b2UseLockOp = dyn_cast<UseLockOp>(*b2It);
if (!areIdenticalUseLocks(b1UseLockOp, b2UseLockOp))
if (!OperationEquivalence::isEquivalentTo(
b1UseLockOp, b2UseLockOp,
OperationEquivalence::IgnoreLocations))
return false;
} else if (auto b1DMABDOp = dyn_cast<DMABDOp>(*b1It)) {
auto b2DMABDOp = dyn_cast<DMABDOp>(*b2It);
if (!areIdenticalDmaBDOps(b1DMABDOp, b2DMABDOp))
if (!OperationEquivalence::isEquivalentTo(
b1DMABDOp, b2DMABDOp, OperationEquivalence::IgnoreLocations))
return false;
}

Expand Down

0 comments on commit 4e02468

Please sign in to comment.