From 093024421f69476a1863c7711012166f06ac60d2 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 16 Jun 2011 09:45:17 +0200 Subject: re PR tree-optimization/49419 (gcc -O2 miscompiles gp2c) PR tree-optimization/49419 * tree-vrp.c (execute_vrp): Call init_range_assertions before estimate_numbers_of_iterations, call free_number_of_iterations_estimates before calling remove_range_assertions. * gcc.c-torture/execute/pr49419.c: New test. From-SVN: r175092 --- gcc/ChangeLog | 8 ++++++ gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gcc.c-torture/execute/pr49419.c | 38 +++++++++++++++++++++++++++ gcc/tree-vrp.c | 6 +++-- 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr49419.c (limited to 'gcc') diff --git a/gcc/ChangeLog b/gcc/ChangeLog index eb447c3..e661a44 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2011-06-16 Jakub Jelinek + + PR tree-optimization/49419 + * tree-vrp.c (execute_vrp): Call init_range_assertions + before estimate_numbers_of_iterations, call + free_number_of_iterations_estimates before calling + remove_range_assertions. + 2011-06-16 Revital Eres * modulo-sched.c (struct ps_insn): Remove row_rest_count field. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f8bce24..73d2074 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-06-16 Jakub Jelinek + + PR tree-optimization/49419 + * gcc.c-torture/execute/pr49419.c: New test. + 2011-06-16 Revital Eres * gcc.dg/sms-9.c: New file. diff --git a/gcc/testsuite/gcc.c-torture/execute/pr49419.c b/gcc/testsuite/gcc.c-torture/execute/pr49419.c new file mode 100644 index 0000000..fddc164 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr49419.c @@ -0,0 +1,38 @@ +/* PR tree-optimization/49419 */ + +extern void abort (void); + +struct S { int w, x, y; } *t; + +int +foo (int n, int f, int *s, int m) +{ + int x, i, a; + if (n == -1) + return 0; + for (x = n, i = 0; t[x].w == f && i < m; i++) + x = t[x].x; + if (i == m) + abort (); + a = i + 1; + for (x = n; i > 0; i--) + { + s[i] = t[x].y; + x = t[x].x; + } + s[0] = x; + return a; +} + +int +main (void) +{ + int s[3], i; + struct S buf[3] = { { 1, 1, 2 }, { 0, 0, 0 }, { 0, 0, 0 } }; + t = buf; + if (foo (0, 1, s, 3) != 2) + abort (); + if (s[0] != 1 || s[1] != 2) + abort (); + return 0; +} diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index d12d634..c049c5d 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -7728,14 +7728,14 @@ execute_vrp (void) rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa); scev_initialize (); + insert_range_assertions (); + /* Estimate number of iterations - but do not use undefined behavior for this. We can't do this lazily as other functions may compute this using undefined behavior. */ free_numbers_of_iterations_estimates (); estimate_numbers_of_iterations (false); - insert_range_assertions (); - to_remove_edges = VEC_alloc (edge, heap, 10); to_update_switch_stmts = VEC_alloc (switch_update, heap, 5); threadedge_initialize_values (); @@ -7744,6 +7744,8 @@ execute_vrp (void) ssa_propagate (vrp_visit_stmt, vrp_visit_phi_node); vrp_finalize (); + free_numbers_of_iterations_estimates (); + /* ASSERT_EXPRs must be removed before finalizing jump threads as finalizing jump threads calls the CFG cleanup code which does not properly handle ASSERT_EXPRs. */ -- cgit v1.1