}
template<> inline
bool RewriteRule<EvalUdiv>::applies(TNode node) {
- return (node.getKind() == kind::BITVECTOR_UDIV_TOTAL &&
- utils::isBVGroundTerm(node));
+ return (utils::isBVGroundTerm(node) &&
+ (node.getKind() == kind::BITVECTOR_UDIV_TOTAL ||
+ (node.getKind() == kind::BITVECTOR_UDIV && node[1].isConst())));
}
template<> inline
}
template<> inline
bool RewriteRule<EvalUrem>::applies(TNode node) {
- return (node.getKind() == kind::BITVECTOR_UREM_TOTAL &&
- utils::isBVGroundTerm(node));
+ return (utils::isBVGroundTerm(node) &&
+ (node.getKind() == kind::BITVECTOR_UREM_TOTAL ||
+ (node.getKind() == kind::BITVECTOR_UREM && node[1].isConst())));
}
template<> inline
return RewriteResponse(REWRITE_DONE, resultNode);
}
+RewriteResponse TheoryBVRewriter::RewriteUdiv(TNode node, bool prerewrite){
+ Node resultNode = node;
+
+ if(node[1].isConst() && node[1].getConst<BitVector>().getValue() != 0) {
+ return RewriteUdivTotal(node, prerewrite);
+ }
+
+ return RewriteResponse(REWRITE_DONE, resultNode);
+}
+
+RewriteResponse TheoryBVRewriter::RewriteUrem(TNode node, bool prerewrite){
+ Node resultNode = node;
+
+ if(node[1].isConst() && node[1].getConst<BitVector>().getValue() != 0) {
+ return RewriteUremTotal(node, prerewrite);
+ }
+
+ return RewriteResponse(REWRITE_DONE, resultNode);
+}
RewriteResponse TheoryBVRewriter::RewriteUdivTotal(TNode node, bool prerewrite){
Node resultNode = node;
d_rewriteTable [ kind::BITVECTOR_PLUS ] = RewritePlus;
d_rewriteTable [ kind::BITVECTOR_SUB ] = RewriteSub;
d_rewriteTable [ kind::BITVECTOR_NEG ] = RewriteNeg;
- // d_rewriteTable [ kind::BITVECTOR_UDIV ] = RewriteUdiv;
- // d_rewriteTable [ kind::BITVECTOR_UREM ] = RewriteUrem;
+ d_rewriteTable [ kind::BITVECTOR_UDIV ] = RewriteUdiv;
+ d_rewriteTable [ kind::BITVECTOR_UREM ] = RewriteUrem;
d_rewriteTable [ kind::BITVECTOR_UDIV_TOTAL ] = RewriteUdivTotal;
d_rewriteTable [ kind::BITVECTOR_UREM_TOTAL ] = RewriteUremTotal;
d_rewriteTable [ kind::BITVECTOR_SMOD ] = RewriteSmod;