res = Rewriter::rewrite(result);
}
+ if( res.getKind() == kind::EQUAL &&
+ ((res[0].getKind() == kind::BITVECTOR_PLUS &&
+ RewriteRule<ConcatToMult>::applies(res[1])) ||
+ res[1].getKind() == kind::BITVECTOR_PLUS &&
+ RewriteRule<ConcatToMult>::applies(res[0]))) {
+ Node mult = RewriteRule<ConcatToMult>::applies(res[0])?
+ RewriteRule<ConcatToMult>::run<false>(res[0]) :
+ RewriteRule<ConcatToMult>::run<true>(res[1]);
+ Node factor = mult[0];
+ Node sum = RewriteRule<ConcatToMult>::applies(res[0])? res[1] : res[0];
+ Node new_eq =utils::mkNode(kind::EQUAL, sum, mult);
+ Node rewr_eq = RewriteRule<SolveEq>::run<true>(new_eq);
+ if (rewr_eq[0].isVar() || rewr_eq[1].isVar()){
+ res = Rewriter::rewrite(rewr_eq);
+ } else {
+ res = t;
+ }
+ }
+
+
// if(t.getKind() == kind::EQUAL &&
// ((t[0].getKind() == kind::BITVECTOR_MULT && t[1].getKind() == kind::BITVECTOR_PLUS) ||
// (t[1].getKind() == kind::BITVECTOR_MULT && t[0].getKind() == kind::BITVECTOR_PLUS))) {
BitwiseSlicing,
// rules to simplify bitblasting
BBPlusNeg,
- UltPlusOne
+ UltPlusOne,
+ ConcatToMult
};
case ExtractSignExtend : out << "ExtractSignExtend"; return out;
case MultDistrib: out << "MultDistrib"; return out;
case UltPlusOne: out << "UltPlusOne"; return out;
+ case ConcatToMult: out << "ConcatToMult"; return out;
default:
Unreachable();
}
RewriteRule<IntToBVEliminate> rule117;
RewriteRule<MultDistrib> rule118;
RewriteRule<UltPlusOne> rule119;
+ RewriteRule<ConcatToMult> rule120;
};
template<> inline
return utils::mkNode(sum.getKind(), children);
}
+template<> inline
+bool RewriteRule<ConcatToMult>::applies(TNode node) {
+ if (node.getKind() != kind::BITVECTOR_CONCAT) return false;
+ if (node.getNumChildren() != 2) return false;
+ if (node[0].getKind()!= kind::BITVECTOR_EXTRACT) return false;
+ if (!node[1].isConst()) return false;
+ TNode extract = node[0];
+ TNode c = node[1];
+ unsigned ammount = utils::getSize(c);
+
+ if (utils::getSize(node) != utils::getSize(extract[0])) return false;
+ if (c != utils::mkConst(ammount, 0)) return false;
+
+ unsigned low = utils::getExtractLow(extract);
+ if (low != 0) return false;
+ unsigned high = utils::getExtractHigh(extract);
+ if (high + ammount + 1 != utils::getSize(node)) return false;
+ return true;
+}
+
+template<> inline
+Node RewriteRule<ConcatToMult>::apply(TNode node) {
+ Debug("bv-rewrite") << "RewriteRule<ConcatToMult>(" << node << ")" << std::endl;
+ unsigned size = utils::getSize(node);
+ Node factor = node[0][0];
+ Assert(utils::getSize(factor) == utils::getSize(node));
+ BitVector ammount = BitVector(size, utils::getSize(node[1]));
+ Node coef = utils::mkConst(BitVector(size, 1u).leftShift(ammount));
+ return utils::mkNode(kind::BITVECTOR_MULT, factor, coef);
+}
+
+
template<> inline
bool RewriteRule<SolveEq>::applies(TNode node) {
y1[1].getKind() != kind::CONST_BITVECTOR)
return false;
+ if (y1[0].getKind() == kind::CONST_BITVECTOR &&
+ y1[1].getKind() == kind::CONST_BITVECTOR)
+ return false;
+
if (y1.getNumChildren() != 2)
return false;