From 5fd79ce459a33a62883a263cd15a119dd8df7d41 Mon Sep 17 00:00:00 2001 From: xumingkuan Date: Tue, 29 Dec 2020 13:20:01 +0800 Subject: [PATCH] [opt] Algebraic simplification for bit_and with 0 --- taichi/transforms/alg_simp.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/taichi/transforms/alg_simp.cpp b/taichi/transforms/alg_simp.cpp index bf7ba3e28ee6f..f0d95e9f619f0 100644 --- a/taichi/transforms/alg_simp.cpp +++ b/taichi/transforms/alg_simp.cpp @@ -220,6 +220,9 @@ class AlgSimp : public BasicStmtVisitor { // -1 & a -> a stmt->replace_with(stmt->rhs); modifier.erase(stmt); + } else if (alg_is_zero(lhs) || alg_is_zero(rhs)) { + // 0 & a -> 0, a & 0 -> 0 + replace_with_zero(stmt); } else if (irpass::analysis::same_value(stmt->lhs, stmt->rhs)) { // a & a -> a stmt->replace_with(stmt->lhs);