]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
Do equivalency removal before violet's implementablity check.
authorAlex Coyte <a.coyte@intel.com>
Tue, 18 Jul 2017 02:49:32 +0000 (12:49 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Mon, 21 Aug 2017 01:18:30 +0000 (11:18 +1000)
This is helpful as removing/restoring literals may introduce redundancy in the
graphs. Also improve the implementation by caching known good holders.

src/nfagraph/ng_violet.cpp

index 6742fec910c031c9137efc59bc114f681af48965..e19a6211fbcbfada4edd2ea0a2ef419ed03e26b1 100644 (file)
@@ -1759,7 +1759,6 @@ void removeRedundantLiteralsFromInfixes(RoseInGraph &g,
     }
 }
 
-
 static
 void removeRedundantLiterals(RoseInGraph &g, const CompileContext &cc) {
     removeRedundantLiteralsFromPrefixes(g, cc);
@@ -2886,6 +2885,7 @@ bool ensureImplementable(RoseBuild &rose, RoseInGraph &vg, bool allow_changes,
     bool changed = false;
     bool need_to_recalc = false;
     u32 added_count = 0;
+    unordered_set<NGHolder *> good; /* known to be implementable */
     do {
         changed = false;
         DEBUG_PRINTF("added %u\n", added_count);
@@ -2901,13 +2901,19 @@ bool ensureImplementable(RoseBuild &rose, RoseInGraph &vg, bool allow_changes,
             }
         }
         for (NGHolder *h : graphs) {
+            if (contains(good, h)) {
+                continue;
+            }
+            reduceGraphEquivalences(*h, cc);
             if (isImplementableNFA(*h, &rm, cc)) {
+                good.insert(h);
                 continue;
             }
 
             if (tryForEarlyDfa(*h, cc)
                 && doEarlyDfa(rose, vg, *h, edges_by_graph[h], final_chance, rm,
                               cc)) {
+                good.insert(h);
                 continue;
             }
 
@@ -2923,6 +2929,7 @@ bool ensureImplementable(RoseBuild &rose, RoseInGraph &vg, bool allow_changes,
                     return false;
                 }
                 changed = true;
+                good.insert(h);
                 continue;
             }