diff options
author | yoni206 <yoni206@users.noreply.github.com> | 2020-12-08 04:51:06 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-08 06:51:06 -0600 |
commit | c23652b991f064ada72427e2ab4098a105587bef (patch) | |
tree | 509b56117d90efda6d26f0865f016da8b8723ba8 /src/preprocessing | |
parent | 384ab75e8637e872b568b6f493612d308f3f15ee (diff) |
bv-to-int: Expand definitions of bvudiv and bvurem during bv-to-int preprocessing pass (#5620)
#5544 enforces expandDefinition not to run before preprocessing.
The bv-to-int preprocessing pass used to rely on expandDefinition to replace BITVECTOR_UDIV and BITVECTOR_UREM with their _TOTAL versions.
This PR performs the replacement in the preprocessing pass itself.
A regression that timed out is now fixed and is brought back to the regressions.
Diffstat (limited to 'src/preprocessing')
-rw-r--r-- | src/preprocessing/passes/bv_to_int.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/preprocessing/passes/bv_to_int.cpp b/src/preprocessing/passes/bv_to_int.cpp index 8539e639d..47170c607 100644 --- a/src/preprocessing/passes/bv_to_int.cpp +++ b/src/preprocessing/passes/bv_to_int.cpp @@ -158,7 +158,7 @@ Node BVToInt::eliminationPass(Node n) { // current is not the elimination of any previously-visited node // current hasn't been eliminated yet. - // eliminate operators from it + // eliminate operators from it using rewrite rules Node currentEliminated = FixpointRewriteStrategy<RewriteRule<UdivZero>, RewriteRule<SdivEliminateFewerBitwiseOps>, @@ -179,6 +179,21 @@ Node BVToInt::eliminationPass(Node n) RewriteRule<SltEliminate>, RewriteRule<SgtEliminate>, RewriteRule<SgeEliminate>>::apply(current); + + // expanding definitions of udiv and urem + if (k == kind::BITVECTOR_UDIV) + { + currentEliminated = d_nm->mkNode(kind::BITVECTOR_UDIV_TOTAL, + currentEliminated[0], + currentEliminated[1]); + } + else if (k == kind::BITVECTOR_UREM) + { + currentEliminated = d_nm->mkNode(kind::BITVECTOR_UREM_TOTAL, + currentEliminated[0], + currentEliminated[1]); + } + // save in the cache d_eliminationCache[current] = currentEliminated; // also assign the eliminated now to itself to avoid revisiting. @@ -331,6 +346,10 @@ Node BVToInt::translateWithChildren(Node original, // The following variable will only be used in assertions. CVC4_UNUSED uint64_t originalNumChildren = original.getNumChildren(); Node returnNode; + // Assert that BITVECTOR_UDIV/UREM were replaced by their + // *_TOTAL versions + Assert(oldKind != kind::BITVECTOR_UDIV); + Assert(oldKind != kind::BITVECTOR_UREM); switch (oldKind) { case kind::BITVECTOR_PLUS: |