/// all of these rules decrease formula size
BvIteConstCond,
BvIteChildren,
+ BvIteConstChildren,
BvComp,
ShlByConst,
LshrByConst,
case EvalNeg : out << "EvalNeg"; return out;
case BvIteConstCond : out << "BvIteConstCond"; return out;
case BvIteChildren : out << "BvIteChildren"; return out;
+ case BvIteConstChildren : out << "BvIteConstChildren"; return out;
case BvComp : out << "BvComp"; return out;
case ShlByConst : out << "ShlByConst"; return out;
case LshrByConst : out << "LshrByConst"; return out;
RewriteRule<BvComp> rule130;
RewriteRule<BvIteConstCond> rule131;
RewriteRule<BvIteChildren> rule132;
+ RewriteRule<BvIteConstChildren> rule133;
};
template<> inline
return node[1];
}
+/**
+ * BvIteConstChildren
+ *
+ * BITVECTOR_ITE with constant children of size one
+ */
+template <>
+inline bool RewriteRule<BvIteConstChildren>::applies(TNode node)
+{
+ return (node.getKind() == kind::BITVECTOR_ITE
+ && utils::getSize(node[1]) == 1
+ && node[1].isConst() && node[2].isConst());
+}
+
+template <>
+inline Node RewriteRule<BvIteConstChildren>::apply(TNode node)
+{
+ Debug("bv-rewrite") << "RewriteRule<BvIteConstChildren>(" << node << ")"
+ << std::endl;
+ if (utils::isOne(node[1]) && utils::isZero(node[2]))
+ {
+ return node[0];
+ }
+ Assert(utils::isZero(node[1]) && utils::isOne(node[2]));
+ return NodeManager::currentNM()->mkNode(kind::BITVECTOR_NOT, node[0]);
+}
+
/**
* BvComp
*
Node resultNode =
LinearRewriteStrategy<RewriteRule<EvalITEBv>,
RewriteRule<BvIteConstCond>,
- RewriteRule<BvIteChildren> >::apply(node);
-
+ RewriteRule<BvIteChildren>,
+ RewriteRule<BvIteConstChildren> >::apply(node);
return RewriteResponse(REWRITE_DONE, resultNode);
}
return node == mkZero(getSize(node));
}
+bool isOne(TNode node)
+{
+ if (!node.isConst()) return false;
+ return node == mkOne(getSize(node));
+}
+
unsigned isPow2Const(TNode node, bool& isNeg)
{
if (node.getKind() != kind::CONST_BITVECTOR)
/* Returns true if given node represents a zero bit-vector. */
bool isZero(TNode node);
+/* Returns true if given node represents a one bit-vector. */
+bool isOne(TNode node);
+
/* If node is a constant of the form 2^c or -2^c, then this function returns
* c+1. Otherwise, this function returns 0. The flag isNeg is updated to
* indicate whether node is negative. */