]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/37221 (Missed early loop-unroll optimization - causes 40% degradatio...
authorRichard Guenther <rguenther@suse.de>
Thu, 2 Apr 2009 09:10:53 +0000 (09:10 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 2 Apr 2009 09:10:53 +0000 (09:10 +0000)
2009-04-02  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/37221
* tree-flow.h (degenerate_phi_result): Declare.
* tree-ssa-dom.c (degenerate_phi_result): Export.
* tree-scalar-evolution.c (analyze_initial_condition): If
the initial condition is defined by a degenerate PHI node
use the degenerate value.

* gcc.c-torture/compile/20090331-1.c: New testcase.

From-SVN: r145439

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20090331-1.c [new file with mode: 0644]
gcc/tree-flow.h
gcc/tree-scalar-evolution.c
gcc/tree-ssa-dom.c

index b3b7d78dc804522ea83dc5ff9b1105246154c148..8305ab11a5574bcfdfdd7c08d15b5422b82d19b7 100644 (file)
@@ -1,3 +1,12 @@
+2009-04-02  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/37221
+       * tree-flow.h (degenerate_phi_result): Declare.
+       * tree-ssa-dom.c (degenerate_phi_result): Export.
+       * tree-scalar-evolution.c (analyze_initial_condition): If
+       the initial condition is defined by a degenerate PHI node
+       use the degenerate value.
+
 2009-04-01  Eric Botcazou  <ebotcazou@adacore.com>
 
        PR rtl-optimization/39588
index b61f69a82cd2f66e8243a38a86f80eed9914b838..48b2e9d3f650714dab8a47c16442396388bf555e 100644 (file)
@@ -1,3 +1,8 @@
+2009-04-02  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/37221
+       * gcc.c-torture/compile/20090331-1.c: New testcase.
+
 2009-04-01  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc.c-torture/compile/20090401-1.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/compile/20090331-1.c b/gcc/testsuite/gcc.c-torture/compile/20090331-1.c
new file mode 100644 (file)
index 0000000..2db2ee7
--- /dev/null
@@ -0,0 +1,26 @@
+struct re_pattern_buffer {
+    unsigned char *buffer;
+    unsigned long int allocated;
+};
+void byte_regex_compile (struct re_pattern_buffer *bufp,
+                        unsigned char *begalt, unsigned char *b)
+{
+  unsigned char *pfrom;
+  unsigned char *pto;
+
+  while ((unsigned long) (b - bufp->buffer + 3) > bufp->allocated)
+    {
+      unsigned char *old_buffer = bufp->buffer;
+      bufp->allocated <<= 1;
+      if (old_buffer != bufp->buffer)
+       {
+         int incr = bufp->buffer - old_buffer;
+         b += incr;
+       }
+    }
+  pfrom = b;
+  pto = b + 3;
+  while (pfrom != begalt)
+    *--pto = *--pfrom;
+}
+
index 07fb9be31e8b5d0b00ff2a43cef9af306d62b4f4..868b762a85ccc79fc51407447957e8aa5142a130 100644 (file)
@@ -919,6 +919,7 @@ bool simplify_stmt_using_ranges (gimple_stmt_iterator *);
 extern void dump_dominator_optimization_stats (FILE *);
 extern void debug_dominator_optimization_stats (void);
 int loop_depth_of_name (tree);
+tree degenerate_phi_result (gimple);
 
 /* In tree-ssa-copy.c  */
 extern void merge_alias_info (tree, tree);
index 8e12c2b32abe3437758878213c83c4fe6ee5c27b..af959b75a3da566a6d1a8bf907973c5b92e5a772 100644 (file)
@@ -1577,6 +1577,20 @@ analyze_initial_condition (gimple loop_phi_node)
   if (init_cond == chrec_not_analyzed_yet)
     init_cond = chrec_dont_know;
 
+  /* During early loop unrolling we do not have fully constant propagated IL.
+     Handle degenerate PHIs here to not miss important unrollings.  */
+  if (TREE_CODE (init_cond) == SSA_NAME)
+    {
+      gimple def = SSA_NAME_DEF_STMT (init_cond);
+      tree res;
+      if (gimple_code (def) == GIMPLE_PHI
+         && (res = degenerate_phi_result (def)) != NULL_TREE
+         /* Only allow invariants here, otherwise we may break
+            loop-closed SSA form.  */
+         && is_gimple_min_invariant (res))
+       init_cond = res;
+    }
+
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
       fprintf (dump_file, "  (init_cond = ");
index 6d6d02bc30574d89284ff55d5fd47e07206e8587..c252a7257c429668efead9d40fd8fbeaa3deac39 100644 (file)
@@ -2475,7 +2475,7 @@ avail_expr_eq (const void *p1, const void *p2)
 /* Given PHI, return its RHS if the PHI is a degenerate, otherwise return
    NULL.  */
 
-static tree
+tree
 degenerate_phi_result (gimple phi)
 {
   tree lhs = gimple_phi_result (phi);