[PATCH] Improve FSM threader to handle compiler temporaries too
authorJeff Law <law@redhat.com>
Mon, 12 Oct 2015 16:26:09 +0000 (10:26 -0600)
committerJeff Law <law@gcc.gnu.org>
Mon, 12 Oct 2015 16:26:09 +0000 (10:26 -0600)
* tree-ssa-threadbackward.c (fsm_find_thread_path): Remove
restriction that traced SSA_NAME is a user variable.

* gcc.dg/tree-ssa/ssa-dom-thread-11.c: New test.

From-SVN: r228727

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-11.c [new file with mode: 0644]
gcc/tree-ssa-threadbackward.c

index c34e0840c58ace39c3755dc61e62360f42496ac9..32ec554fb9120f7b1df458e9723b3cb214c5b1f3 100644 (file)
@@ -1,3 +1,8 @@
+2015-10-12  Jeff Law  <law@redhat.com>
+
+       * tree-ssa-threadbackward.c (fsm_find_thread_path): Remove
+       restriction that traced SSA_NAME is a user variable.
+
 2015-10-12  Tom de Vries  <tom@codesourcery.com>
 
        PR tree-optimization/67476
index f4b7d26d92065e71212f0b7274349fbe6b406a55..89f33632865815b41f9d212ec61e8c0196a848e3 100644 (file)
@@ -1,3 +1,7 @@
+2015-10-12  Jeff Law  <law@redhat.com>
+
+       * gcc.dg/tree-ssa/ssa-dom-thread-11.c: New test.
+
 2015-10-12  Ville Voutilainen  <ville.voutilainen@gmail.com>
 
        PR c++/58566
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-11.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-11.c
new file mode 100644 (file)
index 0000000..03d0334
--- /dev/null
@@ -0,0 +1,49 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-vrp2-details" } */
+/* { dg-final { scan-tree-dump "FSM" "vrp2" } } */
+
+void abort (void);
+typedef struct bitmap_head_def *bitmap;
+typedef const struct bitmap_head_def *const_bitmap;
+typedef struct bitmap_obstack
+{
+  struct bitmap_obstack *next;
+  unsigned int indx;
+}
+bitmap_element;
+typedef struct bitmap_head_def
+{
+  bitmap_element *first;
+}
+bitmap_head;
+static __inline__ unsigned char
+bitmap_elt_ior (bitmap dst, bitmap_element * dst_elt,
+               bitmap_element * dst_prev, const bitmap_element * a_elt,
+               const bitmap_element * b_elt)
+{
+  ((void) (!(a_elt || b_elt) ? abort (), 0 : 0));
+}
+
+unsigned char
+bitmap_ior_and_compl (bitmap dst, const_bitmap a, const_bitmap b,
+                     const_bitmap kill)
+{
+  bitmap_element *dst_elt = dst->first;
+  const bitmap_element *a_elt = a->first;
+  const bitmap_element *b_elt = b->first;
+  const bitmap_element *kill_elt = kill->first;
+  bitmap_element *dst_prev = ((void *) 0);
+  while (a_elt || b_elt)
+    {
+      if (b_elt && kill_elt && kill_elt->indx == b_elt->indx
+         && (!a_elt || a_elt->indx >= b_elt->indx));
+      else
+       {
+         bitmap_elt_ior (dst, dst_elt, dst_prev, a_elt, b_elt);
+         if (a_elt && b_elt && a_elt->indx == b_elt->indx)
+           ;
+         else if (a_elt && (!b_elt || a_elt->indx <= b_elt->indx))
+           a_elt = a_elt->next;
+       }
+    }
+}
index 0012aa39180b55206b099b2eaefbcb1de1a929fb..ff6481c95475d48df86e1fd5b15ed9a42a60334a 100644 (file)
@@ -70,7 +70,7 @@ fsm_find_thread_path (basic_block start_bb, basic_block end_bb,
   return false;
 }
 
-/* We trace the value of the variable EXPR back through any phi nodes looking
+/* We trace the value of the SSA_NAME EXPR back through any phi nodes looking
    for places where it gets a constant value and save the path.  Stop after
    having recorded MAX_PATHS jump threading paths.  */
 
@@ -80,11 +80,10 @@ fsm_find_control_statement_thread_paths (tree expr,
                                         vec<basic_block, va_gc> *&path,
                                         bool seen_loop_phi)
 {
-  tree var = SSA_NAME_VAR (expr);
   gimple *def_stmt = SSA_NAME_DEF_STMT (expr);
   basic_block var_bb = gimple_bb (def_stmt);
 
-  if (var == NULL || var_bb == NULL)
+  if (var_bb == NULL)
     return;
 
   /* For the moment we assume that an SSA chain only contains phi nodes, and