From 8699e35c0985e7a92b7a4fdaa9c59ad9f9b6443e Mon Sep 17 00:00:00 2001 From: Alex Coyte Date: Thu, 23 Jun 2016 14:01:55 +1000 Subject: [PATCH] prevent merging the e and f tables if the ftable is squashable --- src/rose/rose_build_compile.cpp | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/rose/rose_build_compile.cpp b/src/rose/rose_build_compile.cpp index a6868ff8..d59d4d4f 100644 --- a/src/rose/rose_build_compile.cpp +++ b/src/rose/rose_build_compile.cpp @@ -537,6 +537,45 @@ bool RoseBuildImpl::isDirectReport(u32 id) const { return true; } + +/* If we have prefixes that can squash all the floating roots, we can have a + * somewhat-conditional floating table. As we can't yet look at squash_masks, we + * have to make some guess as to if we are in this case but the win for not + * running a floating table over a large portion of the stream is significantly + * larger than avoiding running an eod table over the last N bytes. */ +static +bool checkFloatingKillableByPrefixes(const RoseBuildImpl &tbi) { + for (auto v : vertices_range(tbi.g)) { + if (!tbi.isRootSuccessor(v)) { + continue; + } + + if (!tbi.isFloating(v)) { + continue; + } + + if (!tbi.g[v].left) { + DEBUG_PRINTF("unguarded floating root\n"); + return false; + } + + if (tbi.g[v].left.graph) { + const NGHolder &h = *tbi.g[v].left.graph; + if (proper_out_degree(h.startDs, h)) { + DEBUG_PRINTF("floating nfa prefix, won't die\n"); + return false; + } + } else if (tbi.g[v].left.dfa) { + if (tbi.g[v].left.dfa->start_floating != DEAD_STATE) { + DEBUG_PRINTF("floating dfa prefix, won't die\n"); + return false; + } + } + } + + return true; +} + static bool checkEodStealFloating(const RoseBuildImpl &tbi, const vector &eodLiteralsForFloating, @@ -558,6 +597,11 @@ bool checkEodStealFloating(const RoseBuildImpl &tbi, return false; } + if (checkFloatingKillableByPrefixes(tbi)) { + DEBUG_PRINTF("skipping as prefixes may make ftable conditional\n"); + return false; + } + DEBUG_PRINTF("%zu are eod literals, %u floating; floating len=%zu\n", eodLiteralsForFloating.size(), numFloatingLiterals, shortestFloatingLen);