Node RewriteRule<ShlByConst>::apply(TNode node) {
Debug("bv-rewrite") << "RewriteRule<ShlByConst>(" << node << ")" << std::endl;
Integer amount = node[1].getConst<BitVector>().toInteger();
-
+ if (amount == 0) {
+ return node[0];
+ }
Node a = node[0];
uint32_t size = utils::getSize(a);
Assert(amount < Integer(1).multiplyByPow2(32));
uint32_t uint32_amount = amount.toUnsignedInt();
+
Node left = utils::mkExtract(a, size - 1 - uint32_amount, 0);
Node right = utils::mkConst(BitVector(uint32_amount, Integer(0)));
return utils::mkConcat(left, right);
Node RewriteRule<LshrByConst>::apply(TNode node) {
Debug("bv-rewrite") << "RewriteRule<LshrByConst>(" << node << ")" << std::endl;
Integer amount = node[1].getConst<BitVector>().toInteger();
+ if (amount == 0) {
+ return node[0];
+ }
Node a = node[0];
uint32_t size = utils::getSize(a);
Node RewriteRule<AshrByConst>::apply(TNode node) {
Debug("bv-rewrite") << "RewriteRule<AshrByConst>(" << node << ")" << std::endl;
Integer amount = node[1].getConst<BitVector>().toInteger();
-
+ if (amount == 0) {
+ return node[0];
+ }
+
Node a = node[0];
uint32_t size = utils::getSize(a);
Node sign_bit = utils::mkExtract(a, size-1, size-1);
Debug("bv-rewrite") << "RewriteRule<UdivPow2>(" << node << ")" << std::endl;
Node a = node[0];
unsigned power = utils::isPow2Const(node[1]) -1;
-
+ if (power == 0) {
+ return a;
+ }
Node extract = utils::mkExtract(a, utils::getSize(node) - 1, power);
Node zeros = utils::mkConst(power, 0);
public:
inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check)
throw (TypeCheckingExceptionPrivate, AssertionException) {
+ if (check) {
+ if (n.getConst<BitVector>().getSize() == 0) {
+ throw TypeCheckingExceptionPrivate(n, "constant of size 0");
+ }
+ }
return nodeManager->mkBitVectorType(n.getConst<BitVector>().getSize());
}
};