Skip to content

Commit 3a10c4d

Browse files
authored
[Arith] Restore loop extent>0 constraint and propagate is_assume to Z3 prover (#51)
1 parent 1ecfcc2 commit 3a10c4d

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎src/arith/analyzer.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ std::function<void()> Analyzer::EnterConstraint(const PrimExpr& constraint, bool
403403
recovery_functions.push_back(this->rewrite_simplify.EnterConstraint(constraint, is_assume));
404404
recovery_functions.push_back(this->int_set.EnterConstraint(constraint));
405405
recovery_functions.push_back(this->transitive_comparisons.EnterConstraint(constraint));
406-
recovery_functions.push_back(this->z3_prover.EnterConstraint(constraint));
406+
recovery_functions.push_back(this->z3_prover.EnterConstraint(constraint, is_assume));
407407

408408
return [recovery_functions]() mutable {
409409
// Exiting the scope.

‎src/arith/ir_mutator_with_analyzer.cc‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Stmt IRMutatorWithAnalyzer::VisitStmt_(const ForNode* op) {
6767
Range dom = Range::FromMinExtent(op->min, op->extent);
6868
analyzer_->Bind(op->loop_var, dom);
6969
iter_vars_.Set(op->loop_var, dom);
70+
constraint_scope_.Current().Emplace(analyzer_, op->extent > 0);
7071
return StmtExprMutator::VisitStmt_(op);
7172
});
7273
}
@@ -148,7 +149,7 @@ Stmt IRMutatorWithAnalyzer::VisitStmt_(const AttrStmtNode* op) {
148149
iter_vars_.Set(iv->var, dom);
149150
} else if (op->attr_key == tirx::attr::tilelang_assume) {
150151
auto condition = Downcast<PrimExpr>(op->node);
151-
constraint_scope_.Current().Emplace(analyzer_, condition);
152+
constraint_scope_.Current().Emplace(analyzer_, condition, /*is_assume=*/true);
152153
}
153154
return StmtExprMutator::VisitStmt_(op);
154155
});

‎src/arith/ir_visitor_with_analyzer.cc‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ using namespace tirx;
3535
void IRVisitorWithAnalyzer::VisitStmt_(const ForNode* op) {
3636
constraint_scope_.WithNewScope([&]() {
3737
analyzer_.Bind(op->loop_var, Range::FromMinExtent(op->min, op->extent));
38+
constraint_scope_.Current().Emplace(&analyzer_, op->extent > 0);
3839
StmtExprVisitor::VisitStmt_(op);
3940
});
4041
}
@@ -81,7 +82,7 @@ void IRVisitorWithAnalyzer::VisitStmt_(const AttrStmtNode* op) {
8182
analyzer_.Bind(iv->var, Range::FromMinExtent(IntImm(op->value->dtype, 0), op->value));
8283
} else if (op->attr_key == tirx::attr::tilelang_assume) {
8384
auto condition = Downcast<PrimExpr>(op->node);
84-
constraint_scope_.Current().Emplace(&analyzer_, condition);
85+
constraint_scope_.Current().Emplace(&analyzer_, condition, /*is_assume=*/true);
8586
}
8687
StmtExprVisitor::VisitStmt_(op);
8788
});

0 commit comments

Comments
 (0)