]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport PRs 62217, 66375, 66413, 66794, 66823
authorRichard Biener <rguenther@suse.de>
Thu, 11 Feb 2016 13:40:31 +0000 (13:40 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 11 Feb 2016 13:40:31 +0000 (13:40 +0000)
2016-02-11  Richard Biener  <rguenther@suse.de>

Backport from mainline
2015-02-18  Richard Biener  <rguenther@suse.de>

PR tree-optimization/62217
* tree-ssa-dom.c (cprop_operand): Avoid propagating copies
into BIVs.

* gcc.dg/tree-ssa/cunroll-11.c: New testcase.

2015-06-18  Richard Biener  <rguenther@suse.de>

Backport from mainline
2015-06-03  Richard Biener  <rguenther@suse.de>

PR tree-optimization/66375
* tree-scalar-evolution.c (follow_ssa_edge_binary): First
add to the evolution before following SSA edges.

* gcc.dg/torture/pr66375.c: New testcase.

2015-06-23  Richard Biener  <rguenther@suse.de>

Backport from mainline
2015-06-09  Richard Biener  <rguenther@suse.de>

PR middle-end/66413
* tree-inline.c (insert_init_debug_bind): Unshare value.

* gcc.dg/torture/pr66413.c: New testcase.

2015-07-08  Richard Biener  <rguenther@suse.de>

PR tree-optimization/66794
* gimple-ssa-isolate-paths.c (gimple_ssa_isolate_erroneous_paths):
Free post-dominators.

* gcc.dg/torture/pr66794.c: New testcase.

2015-07-10  Richard Biener  <rguenther@suse.de>

PR tree-optimization/66823
* tree-if-conv.c (memrefs_read_or_written_unconditionally): Fix
inverted predicate.

From-SVN: r233344

12 files changed:
gcc/ChangeLog
gcc/gimple-ssa-isolate-paths.c
gcc/gimple.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr66375.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr66413.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr66794.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/cunroll-11.c [new file with mode: 0644]
gcc/tree-if-conv.c
gcc/tree-inline.c
gcc/tree-scalar-evolution.c
gcc/tree-ssa-dom.c

index 2ae4cb90f0cc256a5bdf8d964295bc98ba21799b..22a96ce4b876e8a5180d43ad3caadf6b63fcfc3d 100644 (file)
@@ -1,3 +1,41 @@
+2016-02-11  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2015-02-18  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/62217
+       * tree-ssa-dom.c (cprop_operand): Avoid propagating copies
+       into BIVs.
+
+       2015-06-18  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2015-06-03  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/66375
+       * tree-scalar-evolution.c (follow_ssa_edge_binary): First
+       add to the evolution before following SSA edges.
+
+       2015-06-23  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2015-06-09  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/66413
+       * tree-inline.c (insert_init_debug_bind): Unshare value.
+
+       2015-07-08  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/66794
+       * gimple-ssa-isolate-paths.c (gimple_ssa_isolate_erroneous_paths):
+       Free post-dominators.
+
+       2015-07-10  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/66823
+       * tree-if-conv.c (memrefs_read_or_written_unconditionally): Fix
+       inverted predicate.
+
 2016-02-11  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
index 56fcfc842587c32bf06823cb14ca560740fec69c..cd4d59f7716678fd9eda445aa0fe1c09e1529c32 100644 (file)
@@ -404,10 +404,10 @@ gimple_ssa_isolate_erroneous_paths (void)
   /* We scramble the CFG and loop structures a bit, clean up
      appropriately.  We really should incrementally update the
      loop structures, in theory it shouldn't be that hard.  */
+  free_dominance_info (CDI_POST_DOMINATORS);
   if (cfg_altered)
     {
       free_dominance_info (CDI_DOMINATORS);
-      free_dominance_info (CDI_POST_DOMINATORS);
       loops_state_set (LOOPS_NEED_FIXUP);
       return TODO_cleanup_cfg | TODO_update_ssa;
     }
index 30d16530e39531e065fd508d58b8734d55ac0aed..67792372244fd2478c8909c565070e0f9751a4de 100644 (file)
@@ -1854,6 +1854,11 @@ gimple_could_trap_p_1 (gimple s, bool include_mem, bool include_stores)
                                       && TYPE_OVERFLOW_TRAPS (t)),
                                      div));
 
+    case GIMPLE_COND:
+      t = TREE_TYPE (gimple_cond_lhs (s));
+      return operation_could_trap_p (gimple_cond_code (s),
+                                    FLOAT_TYPE_P (t), false, NULL_TREE);
+
     default:
       break;
     }
index 3eba02f66890a8edcab533a15b173a029287aa05..9a7f198a98b4506538104ea131dc82639e2192f3 100644 (file)
@@ -1,3 +1,32 @@
+2016-02-11  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2015-02-18  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/62217
+       * gcc.dg/tree-ssa/cunroll-11.c: New testcase.
+
+       2015-06-18  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2015-06-03  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/66375
+       * gcc.dg/torture/pr66375.c: New testcase.
+
+       2015-06-23  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2015-06-09  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/66413
+       * gcc.dg/torture/pr66413.c: New testcase.
+
+       2015-07-08  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/66794
+       * gcc.dg/torture/pr66794.c: New testcase.
+
 2016-02-11  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
diff --git a/gcc/testsuite/gcc.dg/torture/pr66375.c b/gcc/testsuite/gcc.dg/torture/pr66375.c
new file mode 100644 (file)
index 0000000..2447b43
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do run } */
+
+int a;
+extern void abort (void);
+int main ()
+{
+  int c = 0;
+  for (; a < 13; ++a)
+    c = (signed char)c - 11;
+  if (c != 113)
+    abort ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr66413.c b/gcc/testsuite/gcc.dg/torture/pr66413.c
new file mode 100644 (file)
index 0000000..0ca57d7
--- /dev/null
@@ -0,0 +1,61 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-g" } */
+
+int a, b, c, d, i, j, q, *e, *h, *k, *r, **p = &e;
+const int *f, **n = &f;
+static int g;
+
+void
+fn1 (int p1)
+{
+  c = p1;
+}
+
+static int *
+fn2 (int *p1, const int *p2)
+{
+  if (g)
+    n = &p2;
+  *n = p2;
+  int o[245];
+  fn1 (o != p2);
+  return p1;
+}
+
+static int *
+fn3 ()
+{
+  int s[54], *t = &s[0], u = 0, v = 1;
+  h = &v;
+  q = 1;
+  for (; q; q++)
+    {
+      int *w[] = { &u };
+      for (; v;)
+       return *p;
+    }
+  *r = *t + b >= 0;
+  return *p;
+}
+
+static int
+fn4 (int *p1)
+{
+  int *l[2], **m[7];
+  for (; i < 1; i++)
+    for (; j < 1; j++)
+      m[i * 70] = &l[0];
+  k = fn3 ();
+  fn2 (0, p1);
+  if ((m[0] == 0) & a)
+    for (;;)
+      ;
+  return 0;
+}
+
+int
+main ()
+{
+  fn4 (&d);
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr66794.c b/gcc/testsuite/gcc.dg/torture/pr66794.c
new file mode 100644 (file)
index 0000000..03eeec7
--- /dev/null
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-w" } */
+
+int a, *b, e;
+static int **c = &b;
+
+struct
+{
+  int f0;
+} d;
+
+int *
+fn1 ()
+{
+  int f, **g = &b;
+  e = a;
+  for (; a;)
+    for (; d.f0; d.f0++)
+      ;
+  *g = &f;
+  return *c;
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/cunroll-11.c b/gcc/testsuite/gcc.dg/tree-ssa/cunroll-11.c
new file mode 100644 (file)
index 0000000..a26cb22
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -Warray-bounds -fdump-tree-cunroll-details" } */
+
+typedef struct { unsigned data; } s1;
+s1 g_x[4];
+
+extern void foo (s1 *x1, s1 *x2, int a, int b)
+{
+  int i;
+  for(i = 0; i < a; i++)
+    if(i == b)
+      g_x[i] = *x1;
+    else
+      g_x[i] = *x2;
+}
+
+/* { dg-final { scan-tree-dump "Loop 1 iterates at most 3 times" "cunroll" } } */
+/* { dg-final { cleanup-tree-dump "cunroll" } } */
index 0dc340f15aab9336db5c18920b3b657db69458b1..88d2a517cc30216e10289a135116576819d65113 100644 (file)
@@ -593,7 +593,7 @@ memrefs_read_or_written_unconditionally (gimple stmt,
                    || TREE_CODE (ref_base_b) == REALPART_EXPR)
               ref_base_b = TREE_OPERAND (ref_base_b, 0);
 
-           if (!operand_equal_p (ref_base_a, ref_base_b, 0))
+           if (operand_equal_p (ref_base_a, ref_base_b, 0))
              {
                tree cb = bb_predicate (gimple_bb (DR_STMT (b)));
 
index e2048f41697904cacb2707f54ccce538e4f492de..5fd21fe0f30df4802c13b4899ca903f326b6fcef 100644 (file)
@@ -2789,7 +2789,7 @@ insert_init_debug_bind (copy_body_data *id,
        base_stmt = gsi_stmt (gsi);
     }
 
-  note = gimple_build_debug_bind (tracked_var, value, base_stmt);
+  note = gimple_build_debug_bind (tracked_var, unshare_expr (value), base_stmt);
 
   if (bb)
     {
index f1ddc24b1a2c654ac09909d28a9114dd6faba79f..66b063f92938d7d2496af1a0132fc1e29d2184b7 100644 (file)
@@ -935,27 +935,25 @@ follow_ssa_edge_binary (struct loop *loop, gimple at_stmt,
              limit++;
 
              evol = *evolution_of_loop;
-             res = follow_ssa_edge
-               (loop, SSA_NAME_DEF_STMT (rhs0), halting_phi, &evol, limit);
-
-             if (res == t_true)
-               *evolution_of_loop = add_to_evolution
+             evol = add_to_evolution
                  (loop->num,
                   chrec_convert (type, evol, at_stmt),
                   code, rhs1, at_stmt);
-
+             res = follow_ssa_edge
+               (loop, SSA_NAME_DEF_STMT (rhs0), halting_phi, &evol, limit);
+             if (res == t_true)
+               *evolution_of_loop = evol;
              else if (res == t_false)
                {
+                 *evolution_of_loop = add_to_evolution
+                     (loop->num,
+                      chrec_convert (type, *evolution_of_loop, at_stmt),
+                      code, rhs0, at_stmt);
                  res = follow_ssa_edge
                    (loop, SSA_NAME_DEF_STMT (rhs1), halting_phi,
                     evolution_of_loop, limit);
-
                  if (res == t_true)
-                   *evolution_of_loop = add_to_evolution
-                     (loop->num,
-                      chrec_convert (type, *evolution_of_loop, at_stmt),
-                      code, rhs0, at_stmt);
-
+                   ;
                  else if (res == t_dont_know)
                    *evolution_of_loop = chrec_dont_know;
                }
@@ -968,15 +966,15 @@ follow_ssa_edge_binary (struct loop *loop, gimple at_stmt,
            {
              /* Match an assignment under the form:
                 "a = b + ...".  */
+             *evolution_of_loop = add_to_evolution
+                 (loop->num, chrec_convert (type, *evolution_of_loop,
+                                            at_stmt),
+                  code, rhs1, at_stmt);
              res = follow_ssa_edge
                (loop, SSA_NAME_DEF_STMT (rhs0), halting_phi,
                 evolution_of_loop, limit);
              if (res == t_true)
-               *evolution_of_loop = add_to_evolution
-                 (loop->num, chrec_convert (type, *evolution_of_loop,
-                                            at_stmt),
-                  code, rhs1, at_stmt);
-
+               ;       
              else if (res == t_dont_know)
                *evolution_of_loop = chrec_dont_know;
            }
@@ -986,15 +984,15 @@ follow_ssa_edge_binary (struct loop *loop, gimple at_stmt,
        {
          /* Match an assignment under the form:
             "a = ... + c".  */
+         *evolution_of_loop = add_to_evolution
+             (loop->num, chrec_convert (type, *evolution_of_loop,
+                                        at_stmt),
+              code, rhs0, at_stmt);
          res = follow_ssa_edge
            (loop, SSA_NAME_DEF_STMT (rhs1), halting_phi,
             evolution_of_loop, limit);
          if (res == t_true)
-           *evolution_of_loop = add_to_evolution
-             (loop->num, chrec_convert (type, *evolution_of_loop,
-                                        at_stmt),
-              code, rhs0, at_stmt);
-
+           ;
          else if (res == t_dont_know)
            *evolution_of_loop = chrec_dont_know;
        }
@@ -1019,13 +1017,13 @@ follow_ssa_edge_binary (struct loop *loop, gimple at_stmt,
          if (TREE_CODE (rhs1) == SSA_NAME)
            limit++;
 
+         *evolution_of_loop = add_to_evolution
+             (loop->num, chrec_convert (type, *evolution_of_loop, at_stmt),
+              MINUS_EXPR, rhs1, at_stmt);
          res = follow_ssa_edge (loop, SSA_NAME_DEF_STMT (rhs0), halting_phi,
                                 evolution_of_loop, limit);
          if (res == t_true)
-           *evolution_of_loop = add_to_evolution
-             (loop->num, chrec_convert (type, *evolution_of_loop, at_stmt),
-              MINUS_EXPR, rhs1, at_stmt);
-
+           ;
          else if (res == t_dont_know)
            *evolution_of_loop = chrec_dont_know;
        }
index 8ef0920cc7793a95b3edf830db7247184b76de6a..1497e005bb5a844bbf34331af92eb6d73b6eee71 100644 (file)
@@ -2261,11 +2261,16 @@ cprop_operand (gimple stmt, use_operand_p op_p)
       if (loop_depth_of_name (val) > loop_depth_of_name (op))
        return;
 
-      /* Do not propagate copies into simple IV increment statements.
-         See PR23821 for how this can disturb IV analysis.  */
-      if (TREE_CODE (val) != INTEGER_CST
-         && simple_iv_increment_p (stmt))
-       return;
+      /* Do not propagate copies into BIVs.
+         See PR23821 and PR62217 for how this can disturb IV and
+        number of iteration analysis.  */
+      if (TREE_CODE (val) != INTEGER_CST)
+       {
+         gimple def = SSA_NAME_DEF_STMT (op);
+         if (gimple_code (def) == GIMPLE_PHI
+             && gimple_bb (def)->loop_father->header == gimple_bb (def))
+           return;
+       }
 
       /* Dump details.  */
       if (dump_file && (dump_flags & TDF_DETAILS))