From: Richard Biener Date: Thu, 11 Feb 2016 13:40:31 +0000 (+0000) Subject: Backport PRs 62217, 66375, 66413, 66794, 66823 X-Git-Tag: releases/gcc-4.9.4~330 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=42a2f750a3b57e723a3bd18ae8e949df97ec7b75;p=thirdparty%2Fgcc.git Backport PRs 62217, 66375, 66413, 66794, 66823 2016-02-11 Richard Biener Backport from mainline 2015-02-18 Richard Biener 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 Backport from mainline 2015-06-03 Richard Biener 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 Backport from mainline 2015-06-09 Richard Biener 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 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 PR tree-optimization/66823 * tree-if-conv.c (memrefs_read_or_written_unconditionally): Fix inverted predicate. From-SVN: r233344 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2ae4cb90f0cc..22a96ce4b876 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,41 @@ +2016-02-11 Richard Biener + + Backport from mainline + 2015-02-18 Richard Biener + + PR tree-optimization/62217 + * tree-ssa-dom.c (cprop_operand): Avoid propagating copies + into BIVs. + + 2015-06-18 Richard Biener + + Backport from mainline + 2015-06-03 Richard Biener + + 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 + + Backport from mainline + 2015-06-09 Richard Biener + + PR middle-end/66413 + * tree-inline.c (insert_init_debug_bind): Unshare value. + + 2015-07-08 Richard Biener + + PR tree-optimization/66794 + * gimple-ssa-isolate-paths.c (gimple_ssa_isolate_erroneous_paths): + Free post-dominators. + + 2015-07-10 Richard Biener + + PR tree-optimization/66823 + * tree-if-conv.c (memrefs_read_or_written_unconditionally): Fix + inverted predicate. + 2016-02-11 Jakub Jelinek Backported from mainline diff --git a/gcc/gimple-ssa-isolate-paths.c b/gcc/gimple-ssa-isolate-paths.c index 56fcfc842587..cd4d59f77166 100644 --- a/gcc/gimple-ssa-isolate-paths.c +++ b/gcc/gimple-ssa-isolate-paths.c @@ -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; } diff --git a/gcc/gimple.c b/gcc/gimple.c index 30d16530e395..67792372244f 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3eba02f66890..9a7f198a98b4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,32 @@ +2016-02-11 Richard Biener + + Backport from mainline + 2015-02-18 Richard Biener + + PR tree-optimization/62217 + * gcc.dg/tree-ssa/cunroll-11.c: New testcase. + + 2015-06-18 Richard Biener + + Backport from mainline + 2015-06-03 Richard Biener + + PR tree-optimization/66375 + * gcc.dg/torture/pr66375.c: New testcase. + + 2015-06-23 Richard Biener + + Backport from mainline + 2015-06-09 Richard Biener + + PR middle-end/66413 + * gcc.dg/torture/pr66413.c: New testcase. + + 2015-07-08 Richard Biener + + PR tree-optimization/66794 + * gcc.dg/torture/pr66794.c: New testcase. + 2016-02-11 Jakub Jelinek 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 index 000000000000..2447b43c17b6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr66375.c @@ -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 index 000000000000..0ca57d7202a2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr66413.c @@ -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 index 000000000000..03eeec732bca --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr66794.c @@ -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 index 000000000000..a26cb22d35d9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/cunroll-11.c @@ -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" } } */ diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c index 0dc340f15aab..88d2a517cc30 100644 --- a/gcc/tree-if-conv.c +++ b/gcc/tree-if-conv.c @@ -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))); diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index e2048f416979..5fd21fe0f30d 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -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) { diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index f1ddc24b1a2c..66b063f92938 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -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; } diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index 8ef0920cc779..1497e005bb5a 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -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))