]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport PRs 56273, 59124, 64199, 64277, 64365, 64493, 64495
authorRichard Biener <rguenther@suse.de>
Thu, 19 Feb 2015 14:13:16 +0000 (14:13 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 19 Feb 2015 14:13:16 +0000 (14:13 +0000)
2015-02-19  Richard Biener  <rguenther@suse.de>

Backport from mainline
2014-12-09  Richard Biener  <rguenther@suse.de>

PR middle-end/64199
* fold-const.c (fold_binary_loc): Use TREE_OVERFLOW_P.

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

2015-01-14  Richard Biener  <rguenther@suse.de>

PR tree-optimization/64493
PR tree-optimization/64495
* tree-vect-loop.c (vect_finalize_reduction): For double-reductions
assign the proper vectorized PHI to the inner loop exit PHIs.

* gcc.dg/vect/pr64493.c: New testcase.
* gcc.dg/vect/pr64495.c: Likewise.

2015-01-27  Richard Biener  <rguenther@suse.de>

PR tree-optimization/56273
PR tree-optimization/59124
PR tree-optimization/64277
* tree-vrp.c (vrp_finalize): Emit array-bound warnings only
from the first VRP pass.

* g++.dg/warn/Warray-bounds-6.C: New testcase.
* gcc.dg/Warray-bounds-12.c: Likewise.
* gcc.dg/Warray-bounds-13.c: Likewise.

2015-02-19  Richard Biener  <rguenther@suse.de>

Backport from mainline
2015-01-15  Richard Biener  <rguenther@suse.de>

PR middle-end/64365
* tree-data-ref.c (dr_analyze_indices): Make sure that accesses
for MEM_REF access functions with the same base can never partially
overlap.

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

From-SVN: r220815

13 files changed:
gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Warray-bounds-6.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/Warray-bounds-12.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Warray-bounds-13.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr64199.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr64365.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/pr64493.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/pr64495.c [new file with mode: 0644]
gcc/tree-data-ref.c
gcc/tree-vect-loop.c
gcc/tree-vrp.c

index 88ed21d8f5165edae6ce601069147ee792ade6ff..54506807fd51365cd2255f66b6ccfe0d2a502fc3 100644 (file)
@@ -1,3 +1,36 @@
+2015-02-19  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2014-12-09  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/64199
+       * fold-const.c (fold_binary_loc): Use TREE_OVERFLOW_P.
+
+       2015-01-14  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/64493
+       PR tree-optimization/64495
+       * tree-vect-loop.c (vect_finalize_reduction): For double-reductions
+       assign the proper vectorized PHI to the inner loop exit PHIs.
+
+       2015-01-27  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/56273
+       PR tree-optimization/59124
+       PR tree-optimization/64277
+       * tree-vrp.c (vrp_finalize): Emit array-bound warnings only
+       from the first VRP pass.
+
+       2015-02-19  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2015-01-15  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/64365
+       * tree-data-ref.c (dr_analyze_indices): Make sure that accesses
+       for MEM_REF access functions with the same base can never partially
+       overlap.
+
 2015-02-17  Ilya Tocar  <ilya.tocar@intel.com>
 
        Backported from mainline
index 58df92d328b59739831d1dcfe6b94a4a52c8ede5..901204f3ea5bf5aa1e559f6947fa47113071174b 100644 (file)
@@ -10811,8 +10811,8 @@ fold_binary_loc (location_t loc,
 
              /* Don't introduce overflows through reassociation.  */
              if (!any_overflows
-                 && ((lit0 && TREE_OVERFLOW (lit0))
-                     || (minus_lit0 && TREE_OVERFLOW (minus_lit0))))
+                 && ((lit0 && TREE_OVERFLOW_P (lit0))
+                     || (minus_lit0 && TREE_OVERFLOW_P (minus_lit0))))
                return NULL_TREE;
 
              if (minus_lit0)
index d12c2d1791a3b1bd688565d7b34c803306ca145c..8615487aeb8217a023929818a9e9f28a24f23dc8 100644 (file)
@@ -1,3 +1,35 @@
+2015-02-19  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2014-12-09  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/64199
+       * gcc.dg/torture/pr64199.c: New testcase.
+
+       2015-01-14  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/64493
+       PR tree-optimization/64495
+       * gcc.dg/vect/pr64493.c: New testcase.
+       * gcc.dg/vect/pr64495.c: Likewise.
+
+       2015-01-27  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/56273
+       PR tree-optimization/59124
+       PR tree-optimization/64277
+       * g++.dg/warn/Warray-bounds-6.C: New testcase.
+       * gcc.dg/Warray-bounds-12.c: Likewise.
+       * gcc.dg/Warray-bounds-13.c: Likewise.
+
+       2015-02-19  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2015-01-15  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/64365
+       * gcc.dg/torture/pr64365.c: New testcase.
+
 2015-02-19  Maxim Kuvyrkov  <maxim.kuvyrkov@linaro.org>
 
        Revert:
diff --git a/gcc/testsuite/g++.dg/warn/Warray-bounds-6.C b/gcc/testsuite/g++.dg/warn/Warray-bounds-6.C
new file mode 100644 (file)
index 0000000..f2e5f2f
--- /dev/null
@@ -0,0 +1,26 @@
+// { dg-do compile }
+// { dg-options "-O3 -Warray-bounds" }
+
+struct type {
+    bool a, b;
+    bool get_b() { return b; }
+};
+
+type stuff[9u];
+
+void bar();
+
+void foo()
+{
+  for(unsigned i = 0u; i < 9u; i++)
+    {
+      if(!stuff[i].a)
+       continue;
+
+      bar();
+
+      for(unsigned j = i + 1u; j < 9u; j++)
+       if(stuff[j].a && stuff[j].get_b()) // { dg-bogus "above array bounds" }
+         return;
+    }
+}
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-12.c b/gcc/testsuite/gcc.dg/Warray-bounds-12.c
new file mode 100644 (file)
index 0000000..ef26c65
--- /dev/null
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -Warray-bounds" } */
+/* { dg-additional-options "-mssse3" { target x86_64-*-* i?86-*-* } } */
+
+void foo(short a[], short m)
+{
+  int i, j;
+  int f1[10];
+  short nc;
+
+  nc = m + 1;
+  if (nc > 3)
+    {
+      for (i = 0; i <= nc; i++)
+       {
+         f1[i] = f1[i] + 1;
+       }
+    }
+
+  for (i = 0, j = m; i < nc; i++, j--)
+    {
+      a[i] = f1[i]; /* { dg-bogus "above array bounds" } */
+      a[j] = i;
+    }
+  return;
+}
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-13.c b/gcc/testsuite/gcc.dg/Warray-bounds-13.c
new file mode 100644 (file)
index 0000000..7b40a83
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -Warray-bounds" } */
+
+extern char *bar[17];
+
+int foo(int argc, char **argv)
+{
+  int i;
+  int n = 0;
+
+  for (i = 0; i < argc; i++)
+    n++;
+
+  for (i = 0; i < argc; i++)
+    argv[i] = bar[i + n]; /* { dg-bogus "above array bounds" } */
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr64199.c b/gcc/testsuite/gcc.dg/torture/pr64199.c
new file mode 100644 (file)
index 0000000..e3f1002
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-ffast-math -frounding-math" } */
+
+float
+foo (void)
+{
+  return 1.1f + 2.2f + 2.2f;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr64365.c b/gcc/testsuite/gcc.dg/torture/pr64365.c
new file mode 100644 (file)
index 0000000..169993e
--- /dev/null
@@ -0,0 +1,37 @@
+/* { dg-do run } */
+/* { dg-require-effective-target int32plus } */
+
+extern void abort (void);
+extern int memcmp (const void * , const void *, __SIZE_TYPE__);
+
+void __attribute__((noinline,noclone))
+foo(int *in)
+{
+  int i;
+  for (i = 62; i >= 10; i--)
+    {
+      in[i - 8] -= in[i];
+      in[i - 5] += in[i] * 2;
+      in[i - 4] += in[i];
+    }
+}
+
+int main()
+{
+  int x[64];
+  int y[64] = { 0, 1, -2380134, -1065336, -1026376, 3264240, 3113534, 2328130, 3632054, 3839634, 2380136, 1065339, 1026380, 1496037, 1397286, 789976, 386408, 450984, 597112, 497464, 262008, 149184, 194768, 231519, 173984, 87753, 60712, 82042, 87502, 60014, 30050, 25550, 33570, 32386, 20464, 10675, 10868, 13329, 11794, 6892, 3988, 4564, 5148, 4228, 2284, 1568, 1848, 1943, 1472, 741, 628, 702, 714, 474, 230, 234, 238, 242, 120, 59, 60, 61, 62, 63 };
+  int i;
+
+  for (i = 0; i < 64; ++i)
+    {
+      x[i] = i;
+      __asm__ volatile ("");
+    }
+
+  foo (x);
+
+  if (memcmp (x, y, sizeof (x)) != 0)
+    abort ();
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/vect/pr64493.c b/gcc/testsuite/gcc.dg/vect/pr64493.c
new file mode 100644 (file)
index 0000000..a7dee4d
--- /dev/null
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+
+#include "tree-vect.h"
+
+int a, b, c, d, e, f, g, h;
+
+int
+main ()
+{
+  check_vect ();
+
+  for (; a; a--)
+    for (d = 1; d <= 0; d++)
+      for (; d;)
+       if (h)
+         {
+           if (!g) __builtin_abort ();
+           if (!0) __builtin_abort ();
+         }
+
+  for (f = 4; f; f--)
+    {
+      for (b = 0; b < 2; b++)
+       c |= 1;
+      e |= c;
+    }
+
+  return 0;
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr64495.c b/gcc/testsuite/gcc.dg/vect/pr64495.c
new file mode 100644 (file)
index 0000000..aad8752
--- /dev/null
@@ -0,0 +1,35 @@
+/* { dg-do run } */
+
+#include <assert.h>
+#include "tree-vect.h"
+
+int a, b, c, d, e, f, g, i, j;
+static int *h = &e;
+
+int
+main ()
+{
+  check_vect ();
+
+  for (; a;)
+    for (; g; g++)
+      for (; f; f++)
+       if (j)
+         {
+           assert(b); 
+           assert(0);
+         }
+  for (i = 24; i; i--)
+    {
+      for (c = 0; c < 6; c++)
+       d |= 1;
+      *h |= d;
+    }
+
+  if (e != 1) 
+    __builtin_abort (); 
+
+  return 0;
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
index 64ac4e99a61260dc08215496da9c61a96219c103..0099f5ed2859fe4a61cc01164c36020cef0d2b21 100644 (file)
@@ -973,6 +973,24 @@ dr_analyze_indices (struct data_reference *dr, loop_p nest, loop_p loop)
                                fold_convert (ssizetype, memoff));
              memoff = build_int_cst (TREE_TYPE (memoff), 0);
            }
+         /* Adjust the offset so it is a multiple of the access type
+            size and thus we separate bases that can possibly be used
+            to produce partial overlaps (which the access_fn machinery
+            cannot handle).  */
+         double_int rem;
+         if (TYPE_SIZE_UNIT (TREE_TYPE (ref))
+             && TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (ref))) == INTEGER_CST
+             && !integer_zerop (TYPE_SIZE_UNIT (TREE_TYPE (ref))))
+           rem = tree_to_double_int (off).mod
+               (tree_to_double_int (TYPE_SIZE_UNIT (TREE_TYPE (ref))), false,
+                TRUNC_MOD_EXPR);
+         else
+           /* If we can't compute the remainder simply force the initial
+              condition to zero.  */
+           rem = tree_to_double_int (off);
+         off = double_int_to_tree (ssizetype, tree_to_double_int (off) - rem);
+         memoff = double_int_to_tree (TREE_TYPE (memoff), rem);
+         /* And finally replace the initial condition.  */
          access_fn = chrec_replace_initial_condition
              (access_fn, fold_convert (orig_type, off));
          /* ???  This is still not a suitable base object for
index 1fbb7b977e9dd4104936fd889bd55ea90c8424bb..59512fea651df71156e6fd8303033fd228d8645e 100644 (file)
@@ -4521,7 +4521,10 @@ vect_finalize_reduction:
                            && !STMT_VINFO_LIVE_P (exit_phi_vinfo))
                           || double_reduc);
 
-              STMT_VINFO_VEC_STMT (exit_phi_vinfo) = epilog_stmt;
+             if (double_reduc)
+               STMT_VINFO_VEC_STMT (exit_phi_vinfo) = inner_phi;
+             else
+               STMT_VINFO_VEC_STMT (exit_phi_vinfo) = epilog_stmt;
               if (!double_reduc
                   || STMT_VINFO_DEF_TYPE (exit_phi_vinfo)
                       != vect_double_reduction_def)
index 2f93c7e959303ebf34972eb30e6cd1a8d338605d..fb3e05d85c203199c9874f49276f86ef25a9a4aa 100644 (file)
@@ -9730,7 +9730,7 @@ vrp_finalize (void)
   substitute_and_fold (op_with_constant_singleton_value_range,
                       vrp_fold_stmt, false);
 
-  if (warn_array_bounds)
+  if (warn_array_bounds && first_pass_instance)
     check_all_array_refs ();
 
   /* We must identify jump threading opportunities before we release