From fb00b860208a159d5fc57966d3ce600ba5b5346a Mon Sep 17 00:00:00 2001 From: Aina Niemetz Date: Mon, 15 Oct 2018 18:12:00 -0700 Subject: [PATCH] BV rewrites (mined): Rule 35: Generalized ConcatPullUp (BITVECTOR_AND) with ones (#2596). --- .../theory_bv_rewrite_rules_simplification.h | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/theory/bv/theory_bv_rewrite_rules_simplification.h b/src/theory/bv/theory_bv_rewrite_rules_simplification.h index d40bbcfad..ea298d0e1 100644 --- a/src/theory/bv/theory_bv_rewrite_rules_simplification.h +++ b/src/theory/bv/theory_bv_rewrite_rules_simplification.h @@ -499,6 +499,11 @@ Node RewriteRule::apply(TNode node) { * 0_[n-1], * x[m-my-n:m-my-n], * x[m-my-n-1:0] & z) + * + * Match: x_m & concat(y_my, ~0_n, z_mz) + * Rewrites to: concat(x[m-1:m-my] & y, + * x[m-my-1:m-my-n], + * x[m-my-n-1:0] & z) */ template <> @@ -524,7 +529,7 @@ inline bool RewriteRule::applies(TNode node) } } if (n.isNull()) return false; - return utils::isZero(n) || utils::isOne(n); + return utils::isZero(n) || utils::isOne(n) || utils::isOnes(n); } template <> @@ -556,7 +561,7 @@ inline Node RewriteRule::apply(TNode node) } x = xb.getNumChildren() > 1 ? xb.constructNode() : xb[0]; - is_const = -1; + is_const = -2; for (const TNode& child : concat) { if (c.isNull()) @@ -571,6 +576,11 @@ inline Node RewriteRule::apply(TNode node) is_const = 1; c = child; } + else if (utils::isOnes(child)) + { + is_const = -1; + c = child; + } else { yb << child; @@ -608,12 +618,16 @@ inline Node RewriteRule::apply(TNode node) { res << c; } - else + else if (is_const == 1) { - Assert(is_const == 1); if (n > 1) res << utils::mkZero(n-1); res << utils::mkExtract(x, m-my-n, m-my-n); } + else + { + Assert(is_const == -1); + res << utils::mkExtract(x, m-my-1, m-my-n); + } if (mz) { res << nm->mkNode( -- 2.30.2