]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport PRs 77436, 77450, 77605, 77855, 78047, 78185, 78333
authorRichard Biener <rguenther@suse.de>
Tue, 24 Jan 2017 08:06:29 +0000 (08:06 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 24 Jan 2017 08:06:29 +0000 (08:06 +0000)
2017-01-24  Richard Biener  <rguenther@suse.de>

Backport from mainline
2016-10-06  Richard Biener  <rguenther@suse.de>

PR tree-optimization/77855
* tree-ssa-pre.c (prune_clobbered_mems): Queue exprs to remove
instead of removing the current item while iterating over the set
which is not safe.

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

2016-09-01  Richard Biener  <rguenther@suse.de>

PR middle-end/77436
* tree-chrec.c (tree_fold_binomial): Use widest_int, properly
check whether the result fits the desired result type.

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

2016-09-06  Richard Biener  <rguenther@suse.de>

PR c/77450
c-family/
* c-common.c (c_common_mark_addressable_vec): Handle
COMPOUND_LITERAL_EXPR.

* c-c++-common/vector-subscript-7.c: Adjust.
* gcc.dg/pr77450.c: New testcase.

2016-09-19  Richard Biener  <rguenther@suse.de>

PR middle-end/77605
* tree-data-ref.c (analyze_subscript_affine_affine): Use the
proper niter to bound the loops.

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

2016-11-02  Richard Biener  <rguenther@suse.de>

PR tree-optimization/78047
* tree-ssa-structalias.c (push_fields_onto_fieldstack): Initialize
fake field at offset zero conservatively regarding to may_have_pointers.

2016-11-02  Richard Biener  <rguenther@suse.de>

PR middle-end/78185
* loop-invariant.c (find_invariant_insn): Never hoist trapping or
faulting instructions.
* tree-ssa-loop-im.c: Include tree-ssa-loop-niter.h.
(fill_always_executed_in_1): Honor infinite child loops.

* gcc.dg/pr78185.c: New testcase.

2016-11-16  Richard Biener  <rguenther@suse.de>

PR middle-end/78333
* gimplify.c (gimplify_function_tree): Do not instrument
GNU extern inline functions.

* gcc.dg/pr78333.c: New testcase.

From-SVN: r244853

16 files changed:
gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/gimplify.c
gcc/loop-invariant.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr77450.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr78185.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr78333.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr77436.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr77605.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr77855.c [new file with mode: 0644]
gcc/tree-chrec.c
gcc/tree-data-ref.c
gcc/tree-ssa-loop-im.c
gcc/tree-ssa-pre.c
gcc/tree-ssa-structalias.c

index 048884f452b128b86179049b8ec095d21cf8021a..a132be1c9b8c3eee5fe5bff6ef3a70852242b552 100644 (file)
@@ -1,3 +1,45 @@
+2017-01-24  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2016-10-06  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/77855
+       * tree-ssa-pre.c (prune_clobbered_mems): Queue exprs to remove
+       instead of removing the current item while iterating over the set
+       which is not safe.
+
+       2016-09-01  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/77436
+       * tree-chrec.c (tree_fold_binomial): Use widest_int, properly
+       check whether the result fits the desired result type.
+
+       2016-09-19  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/77605
+       * tree-data-ref.c (analyze_subscript_affine_affine): Use the
+       proper niter to bound the loops.
+
+       2016-11-02  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/78047
+       * tree-ssa-structalias.c (push_fields_onto_fieldstack): Initialize
+       fake field at offset zero conservatively regarding to may_have_pointers.
+
+       2016-11-02  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/78185
+       * loop-invariant.c (find_invariant_insn): Never hoist trapping or
+       faulting instructions.
+       * tree-ssa-loop-im.c: Include tree-ssa-loop-niter.h.
+       (fill_always_executed_in_1): Honor infinite child loops.
+
+       2016-11-16  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/78333
+       * gimplify.c (gimplify_function_tree): Do not instrument
+       GNU extern inline functions.
+
 2017-01-23  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
index 2dce6058d6f9fcacbe4b69f2b517cef67ef22e76..5052e572a72257dfb294efb06befe7029bb21db6 100644 (file)
@@ -1,3 +1,12 @@
+2017-01-24  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2016-09-06  Richard Biener  <rguenther@suse.de>
+
+       PR c/77450
+       * c-common.c (c_common_mark_addressable_vec): Handle
+       COMPOUND_LITERAL_EXPR.
+
 2017-01-10  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
index c571c66775a47b8142a8ad13506fa79f081bc0fe..b7aa11d67fcd851699486447b34f09ca070aef6c 100644 (file)
@@ -9428,6 +9428,10 @@ gimplify_function_tree (tree fndecl)
   /* ??? Add some way to ignore exceptions for this TFE.  */
   if (flag_instrument_function_entry_exit
       && !DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (fndecl)
+      /* Do not instrument extern inline functions.  */
+      && !(DECL_DECLARED_INLINE_P (fndecl)
+          && DECL_EXTERNAL (fndecl)
+          && DECL_DISREGARD_INLINE_LIMITS (fndecl))
       && !flag_instrument_functions_exclude_p (fndecl))
     {
       tree x;
index f79b497ea7f73481de939746dee25e9a2b5c1002..d2564684319b23663a962f57a915e6853c71d5f3 100644 (file)
@@ -624,13 +624,17 @@ find_exits (struct loop *loop, basic_block *body,
 
          FOR_EACH_EDGE (e, ei, body[i]->succs)
            {
-             if (flow_bb_inside_loop_p (loop, e->dest))
-               continue;
-
-             bitmap_set_bit (may_exit, i);
-             bitmap_set_bit (has_exit, i);
-             outermost_exit = find_common_loop (outermost_exit,
-                                                e->dest->loop_father);
+             if (! flow_bb_inside_loop_p (loop, e->dest))
+               {
+                 bitmap_set_bit (may_exit, i);
+                 bitmap_set_bit (has_exit, i);
+                 outermost_exit = find_common_loop (outermost_exit,
+                                                    e->dest->loop_father);
+               }
+             /* If we enter a subloop that might never terminate treat
+                it like a possible exit.  */
+             if (flow_loop_nested_p (loop, e->dest->loop_father))
+               bitmap_set_bit (may_exit, i);
            }
          continue;
        }
@@ -913,7 +917,7 @@ pre_check_invariant_p (bool simple, rtx dest)
    unless the program ends due to a function call.  */
 
 static void
-find_invariant_insn (rtx_insn *insn, bool always_reached, bool always_executed)
+find_invariant_insn (rtx_insn *insn, bool, bool always_executed)
 {
   df_ref ref;
   struct def *def;
@@ -947,8 +951,8 @@ find_invariant_insn (rtx_insn *insn, bool always_reached, bool always_executed)
   if (can_throw_internal (insn))
     return;
 
-  /* We cannot make trapping insn executed, unless it was executed before.  */
-  if (may_trap_or_fault_p (PATTERN (insn)) && !always_reached)
+  /* We cannot make trapping insn executed.  */
+  if (may_trap_or_fault_p (PATTERN (insn)))
     return;
 
   depends_on = BITMAP_ALLOC (NULL);
index c663aef22aa3e939c244a53474312f942404cca3..25255d437c5e5ddd83d9e6557f0f0c22aa8e3410 100644 (file)
@@ -1,3 +1,36 @@
+2017-01-24  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2016-10-06  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/77855
+       * gcc.dg/torture/pr77855.c: New testcase.
+
+       2016-09-01  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/77436
+       * gcc.dg/torture/pr77436.c: New testcase.
+
+       2016-09-06  Richard Biener  <rguenther@suse.de>
+
+       PR c/77450
+       * gcc.dg/pr77450.c: New testcase.
+
+       2016-09-19  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/77605
+       * gcc.dg/torture/pr77605.c: New testcase.
+
+       2016-11-02  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/78185
+       * gcc.dg/pr78185.c: New testcase.
+
+       2016-11-16  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/78333
+       * gcc.dg/pr78333.c: New testcase.
+
 2017-01-23  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
diff --git a/gcc/testsuite/gcc.dg/pr77450.c b/gcc/testsuite/gcc.dg/pr77450.c
new file mode 100644 (file)
index 0000000..7c19e86
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu90" } */
+
+typedef int V __attribute__((vector_size(4)));
+
+void
+foo(void)
+{
+  (V){ 0 }[0] = 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pr78185.c b/gcc/testsuite/gcc.dg/pr78185.c
new file mode 100644 (file)
index 0000000..405f748
--- /dev/null
@@ -0,0 +1,28 @@
+/* { dg-do run { target *-*-linux* *-*-gnu* } } */
+/* { dg-options "-O" } */
+
+#include <unistd.h>
+#include <signal.h>
+#include <stdlib.h>
+
+static char var1 = 0L;
+static char *var2 = &var1;
+
+void do_exit (int i)
+{
+  exit (0);
+}
+
+int main(void)
+{
+  struct sigaction s;
+  sigemptyset (&s.sa_mask);
+  s.sa_handler = do_exit;
+  s.sa_flags = 0;
+  sigaction (SIGALRM, &s, NULL);
+  alarm (1);
+  /* The following loop is infinite, the division by zero should not
+     be hoisted out of it.  */
+  for (; (var1 == 0 ? 0 : (100 / var1)) == *var2; );
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pr78333.c b/gcc/testsuite/gcc.dg/pr78333.c
new file mode 100644 (file)
index 0000000..ca037e5
--- /dev/null
@@ -0,0 +1,22 @@
+/* { dg-do link } */
+/* { dg-options "-finstrument-functions" } */
+
+/* Add empty implementations of __cyg_profile_func_enter() and
+   __cyg_profile_func_exit() to avoid problems on non-glibc
+   systems.  */
+void __attribute__((no_instrument_function))
+__cyg_profile_func_enter(void *this_fn, void *call_site)
+{
+}
+
+void __attribute__((no_instrument_function))
+__cyg_profile_func_exit(void *this_fn, void *call_site)
+{
+}
+
+extern inline __attribute__((gnu_inline, always_inline)) int foo () { }
+int main()
+{
+  foo ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr77436.c b/gcc/testsuite/gcc.dg/torture/pr77436.c
new file mode 100644 (file)
index 0000000..513867d
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-do run } */
+
+int main()
+{
+  unsigned short sum = 0;
+  for (short x = -(__SHRT_MAX__ -1); x <= (__SHRT_MAX__ -1); x++)
+    sum += x;
+  if (sum != 0)
+    __builtin_abort ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr77605.c b/gcc/testsuite/gcc.dg/torture/pr77605.c
new file mode 100644 (file)
index 0000000..3f1a26b
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do run } */
+
+int a, b, c[2][8];
+
+int main ()
+{
+  for (a = 0; a < 8; a++)
+    for (b = 0; b < 2; b++)
+      c[b][a] = c[b][b + 6] ^ 1;
+
+  if (c[0][7] != 0) 
+    __builtin_abort ();
+
+  return 0; 
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr77855.c b/gcc/testsuite/gcc.dg/torture/pr77855.c
new file mode 100644 (file)
index 0000000..bec5af3
--- /dev/null
@@ -0,0 +1,48 @@
+/* { dg-do run } */
+
+int a, b = 1, c, e, f, g, k, m, n, o;
+char d, h, i, j, l; 
+char res[2];
+
+void __attribute__ ((noinline,noclone)) fn2 ()
+{
+  d = 2;
+}
+
+void fn3 ()
+{
+  for (;;)
+    {
+      for (; b; b--)
+       {
+         fn2 ();  
+         if (e)
+           j = 1;
+         if (f)
+           L1:
+               k = j | (a & l);
+         for (;;)
+           {
+             __builtin_snprintf (res, 2, "%d\n", d);
+             if (d)
+               break;
+             for (; o; o--)
+               for (; n;)
+                 for (; m; m++)
+                   ;
+             goto L1;
+           }
+       }
+      g = h;
+      c = i;
+      break;
+    }
+}
+
+int main ()
+{
+  fn3 ();
+  if (res[0] != '2')
+    __builtin_abort ();
+  return 0; 
+}
index 1d7bc47192ab1df6d6f39fefec28cb123f7db092..b4a8d821c56564a94b731bec9c7bdc65072f18fd 100644 (file)
@@ -502,7 +502,6 @@ tree_fold_binomial (tree type, tree n, unsigned int k)
 {
   bool overflow;
   unsigned int i;
-  tree res;
 
   /* Handle the most frequent cases.  */
   if (k == 0)
@@ -510,18 +509,20 @@ tree_fold_binomial (tree type, tree n, unsigned int k)
   if (k == 1)
     return fold_convert (type, n);
 
+  widest_int num = wi::to_widest (n);
+
   /* Check that k <= n.  */
-  if (wi::ltu_p (n, k))
+  if (wi::ltu_p (num, k))
     return NULL_TREE;
 
   /* Denominator = 2.  */
-  wide_int denom = wi::two (TYPE_PRECISION (TREE_TYPE (n)));
+  widest_int denom = 2;
 
   /* Index = Numerator-1.  */
-  wide_int idx = wi::sub (n, 1);
+  widest_int idx = num - 1;
 
   /* Numerator = Numerator*Index = n*(n-1).  */
-  wide_int num = wi::smul (n, idx, &overflow);
+  num = wi::smul (num, idx, &overflow);
   if (overflow)
     return NULL_TREE;
 
@@ -540,9 +541,10 @@ tree_fold_binomial (tree type, tree n, unsigned int k)
     }
 
   /* Result = Numerator / Denominator.  */
-  wide_int di_res = wi::udiv_trunc (num, denom);
-  res = wide_int_to_tree (type, di_res);
-  return int_fits_type_p (res, type) ? res : NULL_TREE;
+  num = wi::udiv_trunc (num, denom);
+  if (! wi::fits_to_tree_p (num, type))
+    return NULL_TREE;
+  return wide_int_to_tree (type, num);
 }
 
 /* Helper function.  Use the Newton's interpolating formula for
index 410fd53a277f752f6d269a7af95f319a0066aac3..dc80d60870f5ace7ee5f26ce75ac598c04092349 100644 (file)
@@ -2717,13 +2717,13 @@ analyze_subscript_affine_affine (tree chrec_a,
 
              if (niter > 0)
                {
-                 HOST_WIDE_INT tau2 = MIN (FLOOR_DIV (niter - i0, i1),
-                                           FLOOR_DIV (niter - j0, j1));
+                 HOST_WIDE_INT tau2 = MIN (FLOOR_DIV (niter_a - i0, i1),
+                                           FLOOR_DIV (niter_b - j0, j1));
                  HOST_WIDE_INT last_conflict = tau2 - (x1 - i0)/i1;
 
                  /* If the overlap occurs outside of the bounds of the
                     loop, there is no dependence.  */
-                 if (x1 >= niter || y1 >= niter)
+                 if (x1 >= niter_a || y1 >= niter_b)
                    {
                      *overlaps_a = conflict_fn_no_dependence ();
                      *overlaps_b = conflict_fn_no_dependence ();
index 16bc1ab31ef3494cb9ddbe5dd954a0d3ad279b07..dc7b5fd3dd379929ace975c6f702f422de627e3e 100644 (file)
@@ -70,6 +70,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-ssa-propagate.h"
 #include "trans-mem.h"
 #include "gimple-fold.h"
+#include "tree-ssa-loop-niter.h"
 
 /* TODO:  Support for predicated code motion.  I.e.
 
@@ -2406,8 +2407,16 @@ fill_always_executed_in_1 (struct loop *loop, sbitmap contains_call)
            break;
 
          FOR_EACH_EDGE (e, ei, bb->succs)
-           if (!flow_bb_inside_loop_p (loop, e->dest))
-             break;
+           {
+             /* If there is an exit from this BB.  */
+             if (!flow_bb_inside_loop_p (loop, e->dest))
+               break;
+             /* Or we enter a possibly non-finite loop.  */
+             if (flow_loop_nested_p (bb->loop_father,
+                                     e->dest->loop_father)
+                 && ! finite_loop_p (e->dest->loop_father))
+               break;
+           }
          if (e)
            break;
 
index c5c06ca4b14da1e02b9e2f639a58adced6a8ba4a..459d8e3cf5f02275f96c616e86ff2e7394c3ee35 100644 (file)
@@ -2077,9 +2077,17 @@ prune_clobbered_mems (bitmap_set_t set, basic_block block)
 {
   bitmap_iterator bi;
   unsigned i;
+  pre_expr to_remove = NULL;
 
   FOR_EACH_EXPR_ID_IN_SET (set, i, bi)
     {
+      /* Remove queued expr.  */
+      if (to_remove)
+       {
+         bitmap_remove_from_set (set, to_remove);
+         to_remove = NULL;
+       }
+
       pre_expr expr = expression_for_id (i);
       if (expr->kind == REFERENCE)
        {
@@ -2093,7 +2101,7 @@ prune_clobbered_mems (bitmap_set_t set, basic_block block)
                                           block, gimple_bb (def_stmt)))
                      || (gimple_bb (def_stmt) == block
                          && value_dies_in_block_x (expr, block))))
-               bitmap_remove_from_set (set, expr);
+               to_remove = expr;
            }
        }
       else if (expr->kind == NARY)
@@ -2105,9 +2113,13 @@ prune_clobbered_mems (bitmap_set_t set, basic_block block)
             as the available expression might be after the exit point.  */
          if (BB_MAY_NOTRETURN (block)
              && vn_nary_may_trap (nary))
-           bitmap_remove_from_set (set, expr);
+           to_remove = expr;
        }
     }
+
+  /* Remove queued expr.  */
+  if (to_remove)
+    bitmap_remove_from_set (set, to_remove);
 }
 
 static sbitmap has_abnormal_preds;
index c12128a923b0e8f8384d066f58a8627cab0636d6..bf1b989d83732025e44ff285337eb0e17d005b46 100644 (file)
@@ -5371,7 +5371,7 @@ push_fields_onto_fieldstack (tree type, vec<fieldoff_s> *fieldstack,
            if (!pair
                && offset + foff != 0)
              {
-               fieldoff_s e = {0, offset + foff, false, false, false, false};
+               fieldoff_s e = {0, offset + foff, false, false, true, false};
                pair = fieldstack->safe_push (e);
              }