This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Improve FSM threader to handle compiler temporaries too
- From: Jeff Law <law at redhat dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 12 Oct 2015 10:26:54 -0600
- Subject: [PATCH] Improve FSM threader to handle compiler temporaries too
- Authentication-results: sourceware.org; auth=none
The FSM jump threader currently will not handle threading for compiler
generated temporaries.
I discovered this when looking at what tests regress if I remove the
ability of the old threader to thread across backedges and why the FSM
threader doesn't handle them.
bitmap.c has a multitude of codes that the FSM bits can now optimize. I
took one and let multidelta loose on it resulting in the included testcase.
I wouldn't be surprised if the testcase ultimately turns out to be
dependent on BRANCH_COST. I'll keep an eye on gcc-testresults to see if
the test needs adjustment for other targets.
Bootstrapped & regression tested on x86_64-linux-gnu. Installed on the
trunk.
Jeff
commit 97d71bc09d2198072bed76ba36e988584f857bb1
Author: Jeff Law <law@redhat.com>
Date: Mon Oct 12 10:24:45 2015 -0600
[PATCH] Improve FSM threader to handle compiler temporaries too
* 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.
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c34e084..32ec554 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f4b7d26..89f3363 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..03d0334
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-11.c
@@ -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;
+ }
+ }
+}
diff --git a/gcc/tree-ssa-threadbackward.c b/gcc/tree-ssa-threadbackward.c
index 0012aa3..ff6481c 100644
--- a/gcc/tree-ssa-threadbackward.c
+++ b/gcc/tree-ssa-threadbackward.c
@@ -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