From: Richard Biener Date: Thu, 19 Feb 2015 14:13:16 +0000 (+0000) Subject: Backport PRs 56273, 59124, 64199, 64277, 64365, 64493, 64495 X-Git-Tag: releases/gcc-4.9.3~344 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f7c7543a7aa1ab5109b35e7e0fe2208ed33a9791;p=thirdparty%2Fgcc.git Backport PRs 56273, 59124, 64199, 64277, 64365, 64493, 64495 2015-02-19 Richard Biener Backport from mainline 2014-12-09 Richard Biener 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 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 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 Backport from mainline 2015-01-15 Richard Biener 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 88ed21d8f516..54506807fd51 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,36 @@ +2015-02-19 Richard Biener + + Backport from mainline + 2014-12-09 Richard Biener + + PR middle-end/64199 + * fold-const.c (fold_binary_loc): Use TREE_OVERFLOW_P. + + 2015-01-14 Richard Biener + + 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 + + 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 + + Backport from mainline + 2015-01-15 Richard Biener + + 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 Backported from mainline diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 58df92d328b5..901204f3ea5b 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d12c2d1791a3..8615487aeb82 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,35 @@ +2015-02-19 Richard Biener + + Backport from mainline + 2014-12-09 Richard Biener + + PR middle-end/64199 + * gcc.dg/torture/pr64199.c: New testcase. + + 2015-01-14 Richard Biener + + 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 + + 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 + + Backport from mainline + 2015-01-15 Richard Biener + + PR middle-end/64365 + * gcc.dg/torture/pr64365.c: New testcase. + 2015-02-19 Maxim Kuvyrkov 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 index 000000000000..f2e5f2f597aa --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Warray-bounds-6.C @@ -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 index 000000000000..ef26c6596bf5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Warray-bounds-12.c @@ -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 index 000000000000..7b40a83887de --- /dev/null +++ b/gcc/testsuite/gcc.dg/Warray-bounds-13.c @@ -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 index 000000000000..e3f1002f1bd4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr64199.c @@ -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 index 000000000000..169993e6df07 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr64365.c @@ -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 index 000000000000..a7dee4d66eb5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr64493.c @@ -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 index 000000000000..aad87526ee54 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr64495.c @@ -0,0 +1,35 @@ +/* { dg-do run } */ + +#include +#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" } } */ diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index 64ac4e99a612..0099f5ed2859 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -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 diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 1fbb7b977e9d..59512fea651d 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -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) diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 2f93c7e95930..fb3e05d85c20 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -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