summaryrefslogtreecommitdiff
path: root/src/theory
diff options
context:
space:
mode:
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>2018-02-06 16:13:41 -0600
committerGitHub <noreply@github.com>2018-02-06 16:13:41 -0600
commitaf20fc43b48217ebc402ad0def388e7a21b49c47 (patch)
treef06ed9bdbd02fb7e73301910ecd9051291e868e1 /src/theory
parentd951eec4de366f1cc954dbaf6ffbd651fc6c383c (diff)
Fix two multiply-by-constant corner cases for bv rewriter (#1562)
Diffstat (limited to 'src/theory')
-rw-r--r--src/theory/bv/theory_bv_rewrite_rules_normalization.h22
-rw-r--r--src/theory/bv/theory_bv_rewrite_rules_simplification.h10
2 files changed, 21 insertions, 11 deletions
diff --git a/src/theory/bv/theory_bv_rewrite_rules_normalization.h b/src/theory/bv/theory_bv_rewrite_rules_normalization.h
index d17f20152..ad5b37a2d 100644
--- a/src/theory/bv/theory_bv_rewrite_rules_normalization.h
+++ b/src/theory/bv/theory_bv_rewrite_rules_normalization.h
@@ -394,19 +394,22 @@ Node RewriteRule<MultSimplify>::apply(TNode node) {
std::vector<Node> children;
for (const TNode& current : node)
{
- if (current.getKind() == kind::CONST_BITVECTOR) {
- BitVector value = current.getConst<BitVector>();
+ Node c = current;
+ if (c.getKind() == kind::BITVECTOR_NEG)
+ {
+ isNeg = !isNeg;
+ c = c[0];
+ }
+
+ if (c.getKind() == kind::CONST_BITVECTOR)
+ {
+ BitVector value = c.getConst<BitVector>();
constant = constant * value;
if(constant == BitVector(size, (unsigned) 0)) {
return utils::mkConst(size, 0);
}
- }
- else if (current.getKind() == kind::BITVECTOR_NEG)
- {
- isNeg = !isNeg;
- children.push_back(current[0]);
} else {
- children.push_back(current);
+ children.push_back(c);
}
}
BitVector oValue = BitVector(size, static_cast<unsigned>(1));
@@ -414,8 +417,7 @@ Node RewriteRule<MultSimplify>::apply(TNode node) {
if (children.empty())
{
- Assert(!isNeg);
- return utils::mkConst(constant);
+ return utils::mkConst(isNeg ? -constant : constant);
}
std::sort(children.begin(), children.end());
diff --git a/src/theory/bv/theory_bv_rewrite_rules_simplification.h b/src/theory/bv/theory_bv_rewrite_rules_simplification.h
index 067440ee2..fb083c568 100644
--- a/src/theory/bv/theory_bv_rewrite_rules_simplification.h
+++ b/src/theory/bv/theory_bv_rewrite_rules_simplification.h
@@ -790,7 +790,15 @@ inline Node RewriteRule<MultPow2>::apply(TNode node)
}
}
- Node a = utils::mkNode(kind::BITVECTOR_MULT, children);
+ Node a;
+ if (children.empty())
+ {
+ a = utils::mkOne(size);
+ }
+ else
+ {
+ a = utils::mkNode(kind::BITVECTOR_MULT, children);
+ }
if (isNeg && size > 1)
{
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback