diff --git a/taichi/transforms/alg_simp.cpp b/taichi/transforms/alg_simp.cpp index 637c5b3f50924..bfbdb2f504d69 100644 --- a/taichi/transforms/alg_simp.cpp +++ b/taichi/transforms/alg_simp.cpp @@ -74,6 +74,17 @@ class AlgSimp : public BasicStmtVisitor { } } + void visit(AssertStmt *stmt) override { + auto cond = stmt->cond->cast(); + if (!cond) + return; + if (!alg_is_zero(cond)) { + // this statement has no effect + stmt->parent->erase(stmt); + throw IRModified(); + } + } + void visit(WhileControlStmt *stmt) override { auto cond = stmt->cond->cast(); if (!cond)