bv-to-int: avoid binarizing nodes twice (#5749)
authoryoni206 <yoni206@users.noreply.github.com>
Fri, 8 Jan 2021 15:08:05 +0000 (07:08 -0800)
committerGitHub <noreply@github.com>
Fri, 8 Jan 2021 15:08:05 +0000 (09:08 -0600)
In bv-to-int, we first binarize the applications of associative-commutative operators (like bvadd etc.).
With this PR, we first check whether we already binarized a node, and only if we didn't, we perform binarization.

src/preprocessing/passes/bv_to_int.cpp

index 47170c6076181977a61e0c6c3552d748bbc52071..04d6b7a0ca295f43438fed28ad30627522f719c6 100644 (file)
@@ -77,7 +77,13 @@ Node BVToInt::modpow2(Node n, uint64_t exponent)
  */
 Node BVToInt::makeBinary(Node n)
 {
-  for (TNode current : NodeDfsIterable(n, VisitOrder::POSTORDER))
+  for (TNode current : NodeDfsIterable(n,
+                                       VisitOrder::POSTORDER,
+                                       // skip visited nodes
+                                       [this](TNode tn) {
+                                         return d_binarizeCache.find(tn)
+                                                != d_binarizeCache.end();
+                                       }))
   {
     uint64_t numChildren = current.getNumChildren();
     /*