Skip to content

Commit

Permalink
fix canonicalization bug
Browse files Browse the repository at this point in the history
  • Loading branch information
gysit committed Jan 12, 2021
1 parent c6a3e0d commit 4d8eb77
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions lib/Dialect/Stencil/StencilOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ void stencil::ApplyOp::updateArgumentTypes() {
}

bool stencil::ApplyOp::hasOnlyEmptyStores() {
bool hasOnlyEmptyStores = true;
walk([&](stencil::StoreResultOp resultOp) {
auto result = walk([&](stencil::StoreResultOp resultOp) {
if (resultOp.operands().size() != 0)
hasOnlyEmptyStores = false;
return WalkResult::interrupt();
return WalkResult::advance();
});
return hasOnlyEmptyStores;
return !result.wasInterrupted();
}

//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -221,7 +221,8 @@ stencil::StoreResultOp::getReturnOpOperands() {
currOperations.clear();
SmallVector<OpOperand *, 10> nextOperands;
for (auto &use : currOperands) {
auto result = yieldOp->getParentOp()->getResult(use->getOperandNumber());
auto result =
yieldOp->getParentOp()->getResult(use->getOperandNumber());
for (auto &use : result.getUses()) {
nextOperands.push_back(&use);
currOperations.insert(use.getOwner());
Expand Down Expand Up @@ -627,7 +628,7 @@ struct CombineOpSymmetricCleaner : public stencil::CombineOpPattern {
PatternRewriter &rewriter) const override {
// Exit if the combine has extra operands
if (combineOp.lowerext().size() > 0 || combineOp.upperext().size() > 0)
failure();
return failure();

// Compute the empty values
SmallVector<Value, 10> emptyValues;
Expand All @@ -648,9 +649,12 @@ struct CombineOpSymmetricCleaner : public stencil::CombineOpPattern {
}

// Create an empty apply
auto emptyOp = createEmptyApply(
combineOp, std::numeric_limits<int64_t>::min(),
std::numeric_limits<int64_t>::max(), emptyValues, rewriter);
ApplyOp emptyOp;
if (!emptyValues.empty()) {
emptyOp = createEmptyApply(combineOp, std::numeric_limits<int64_t>::min(),
std::numeric_limits<int64_t>::max(),
emptyValues, rewriter);
}

// Compute the replacement values
unsigned emptyCount = 0;
Expand Down

0 comments on commit 4d8eb77

Please sign in to comment.