From 7bec30e1097eacc991e358cc7a97b6b22f611a31 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Tue, 22 Mar 2011 12:40:09 +0000 Subject: [PATCH] re PR tree-optimization/48228 (incorrect signed overflow warning when only 0 and 1 are used) 2011-03-22 Richard Guenther PR tree-optimization/48228 * tree-vrp.c (vrp_visit_phi_node): Do not stop propagating for single-arg PHIs. * gcc.dg/Wstrict-overflow-23.c: New testcase. From-SVN: r171287 --- gcc/ChangeLog | 6 +++++ gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gcc.dg/Wstrict-overflow-23.c | 31 ++++++++++++++++++++++ gcc/tree-vrp.c | 1 + 4 files changed, 43 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/Wstrict-overflow-23.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6d318e05952..512e46d93e9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-03-22 Richard Guenther + + PR tree-optimization/48228 + * tree-vrp.c (vrp_visit_phi_node): Do not stop propagating + for single-arg PHIs. + 2011-03-22 Andrey Belevantsev PR rtl-optimization/48143 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2ce6bb73ec7..a5d78c94cca 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-03-22 Richard Guenther + + PR tree-optimization/48228 + * gcc.dg/Wstrict-overflow-23.c: New testcase. + 2011-03-21 Jack Howarth * lib/prune.exp (prune_gcc_output): Prune "could not create diff --git a/gcc/testsuite/gcc.dg/Wstrict-overflow-23.c b/gcc/testsuite/gcc.dg/Wstrict-overflow-23.c new file mode 100644 index 00000000000..16014bb15c5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wstrict-overflow-23.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wstrict-overflow" } */ + +unsigned int +do_scrolling (unsigned int window_size, unsigned int writecost) +{ + unsigned int i = window_size; + + int terminal_window_p = 0; + unsigned int queue = 0; + + for (i = window_size; i; i--) + { + if (writecost < i) + ++queue; + else if (writecost & 1) + terminal_window_p = 1; + } + + if (queue > 0) + { + if (!terminal_window_p) + { + terminal_window_p = 1; + } + } + + if (terminal_window_p) + return 100; + return 0; +} diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index d2e6551d992..42ea9104e12 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -6619,6 +6619,7 @@ vrp_visit_phi_node (gimple phi) edge; this helps us avoid an overflow infinity for conditionals which are not in a loop. */ if (edges > 0 + && gimple_phi_num_args (phi) > 1 && edges == old_edges) { int cmp_min = compare_values (lhs_vr->min, vr_result.min); -- 2.30.2