diff options
author | Andres Noetzli <andres.noetzli@gmail.com> | 2021-04-06 09:33:52 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-06 16:33:52 +0000 |
commit | cfe1431aaae7366dea1d3124742ee2b2c2a2511e (patch) | |
tree | 7c30457bef5857947102636bddc8cc3a05e9e3c5 /src/theory/arrays/theory_arrays.cpp | |
parent | e92b4504d5930234c852bf0fba8f5663ad4809e7 (diff) |
Remove template argument from `NodeBuilder` (#6290)
Currently, NodeBuilder takes a single template argument: An integer
that determines the expected number of arguments. This argument is used
to determine the size of the d_inlineNvChildSpace array. This array is
used to construct nodes inline. The advantage of this is that we don't
have to allocate a NodeValue on the heap for the node under
construction until we are sure that the node is new. While templating
the array size may save some stack space (or avoid a heap allocation if
we statically know that we a fixed number of children and that number is
greater than 10), it complicates the code and leads to longer compile
times. Thus, this commit removes the template argument and moves some of
the NodeBuilder code to a source file for faster compilation.
CPU build time before change (debug build): 2429.68s
CPU build time after change (debug build): 2228.44s
Signed-off-by: Andres Noetzli noetzli@amazon.com
Diffstat (limited to 'src/theory/arrays/theory_arrays.cpp')
-rw-r--r-- | src/theory/arrays/theory_arrays.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/theory/arrays/theory_arrays.cpp b/src/theory/arrays/theory_arrays.cpp index c51f4b98a..d0a653410 100644 --- a/src/theory/arrays/theory_arrays.cpp +++ b/src/theory/arrays/theory_arrays.cpp @@ -247,7 +247,7 @@ Node TheoryArrays::solveWrite(TNode term, bool solve1, bool solve2, bool ppCheck // (index_0 != index_1 & index_0 != index_2 & ... & index_0 != index_n) -> read(store, index_0) = v_0 TNode write_i, write_j, index_i, index_j; Node conc; - NodeBuilder<> result(kind::AND); + NodeBuilder result(kind::AND); int i, j; write_i = left; for (i = leftWrites-1; i >= 0; --i) { @@ -257,7 +257,7 @@ Node TheoryArrays::solveWrite(TNode term, bool solve1, bool solve2, bool ppCheck // ... && index_i /= index_(i+1)] -> read(store, index_i) = v_i write_j = left; { - NodeBuilder<> hyp(kind::AND); + NodeBuilder hyp(kind::AND); for (j = leftWrites - 1; j > i; --j) { index_j = write_j[1]; if (!ppCheck || !ppDisequal(index_i, index_j)) { @@ -300,7 +300,7 @@ Node TheoryArrays::solveWrite(TNode term, bool solve1, bool solve2, bool ppCheck // store(store(...),i,select(a,i)) = a && select(store(...),i)=v Node l = left; Node tmp; - NodeBuilder<> nb(kind::AND); + NodeBuilder nb(kind::AND); while (right.getKind() == kind::STORE) { tmp = nm->mkNode(kind::SELECT, l, right[1]); nb << tmp.eqNode(right[2]); @@ -328,13 +328,14 @@ TrustNode TheoryArrays::ppRewrite(TNode term, std::vector<SkolemLemma>& lems) return TrustNode::null(); } d_ppEqualityEngine.addTerm(term); + NodeManager* nm = NodeManager::currentNM(); Node ret; switch (term.getKind()) { case kind::SELECT: { // select(store(a,i,v),j) = select(a,j) // IF i != j if (term[0].getKind() == kind::STORE && ppDisequal(term[0][1], term[1])) { - ret = NodeBuilder<2>(kind::SELECT) << term[0][0] << term[1]; + ret = nm->mkNode(kind::SELECT, term[0][0], term[1]); } break; } @@ -342,8 +343,8 @@ TrustNode TheoryArrays::ppRewrite(TNode term, std::vector<SkolemLemma>& lems) // store(store(a,i,v),j,w) = store(store(a,j,w),i,v) // IF i != j and j comes before i in the ordering if (term[0].getKind() == kind::STORE && (term[1] < term[0][1]) && ppDisequal(term[1],term[0][1])) { - Node inner = NodeBuilder<3>(kind::STORE) << term[0][0] << term[1] << term[2]; - Node outer = NodeBuilder<3>(kind::STORE) << inner << term[0][1] << term[0][2]; + Node inner = nm->mkNode(kind::STORE, term[0][0], term[1], term[2]); + Node outer = nm->mkNode(kind::STORE, inner, term[0][1], term[0][2]); ret = outer; } break; @@ -1440,7 +1441,7 @@ Node TheoryArrays::mkAnd(std::vector<TNode>& conjunctions, bool invert, unsigned } } - NodeBuilder<> conjunction(invert ? kind::OR : kind::AND); + NodeBuilder conjunction(invert ? kind::OR : kind::AND); std::set<TNode>::const_iterator it = all.begin(); std::set<TNode>::const_iterator it_end = all.end(); while (it != it_end) { |