bv2int : linear mult opt (#4142)
authorAhmed Irfan <43099566+ahmed-irfan@users.noreply.github.com>
Wed, 25 Mar 2020 16:37:57 +0000 (09:37 -0700)
committerGitHub <noreply@github.com>
Wed, 25 Mar 2020 16:37:57 +0000 (11:37 -0500)
src/preprocessing/passes/bv_to_int.cpp

index cb78b089705b9ba6b2a82dad4a0b70b6209da646..0e4bc41c0048f3363eac1f74ce985abf1edf664f 100644 (file)
@@ -401,7 +401,28 @@ Node BVToInt::bvToInt(Node n)
                   d_nm->mkNode(kind::MINUS, mult, multSig);
               d_rangeAssertions.insert(
                   mkRangeConstraint(d_bvToIntCache[current], bvsize));
-              d_rangeAssertions.insert(mkRangeConstraint(sigma, bvsize));
+              if (translated_children[0].isConst()
+                  || translated_children[1].isConst())
+              {
+                /*
+                 * based on equation (23), section 3.2.3 of:
+                 * Bozzano et al.
+                 * Encoding RTL Constructs for MathSAT: a Preliminary Report.
+                 */
+                // this is an optimization when one of the children is constant
+                Node c = translated_children[0].isConst()
+                             ? translated_children[0]
+                             : translated_children[1];
+                d_rangeAssertions.insert(
+                    d_nm->mkNode(kind::LEQ, d_zero, sigma));
+                // the value of sigma is bounded by (c - 1)
+                // where c is the constant multiplicand
+                d_rangeAssertions.insert(d_nm->mkNode(kind::LT, sigma, c));
+              }
+              else
+              {
+                d_rangeAssertions.insert(mkRangeConstraint(sigma, bvsize));
+              }
               break;
             }
             case kind::BITVECTOR_UDIV_TOTAL: