From: Marek Polacek Date: Thu, 1 Oct 2015 14:25:42 +0000 (+0000) Subject: re PR tree-optimization/67769 (VRP pass does wrong optimization) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9edaabf3d2cee4597f83227656ac50ed03bc669a;p=gcc.git re PR tree-optimization/67769 (VRP pass does wrong optimization) PR tree-optimization/67769 * tree-ssa-phiopt.c (conditional_replacement): Call reset_flow_sensitive_info_in_bb. (minmax_replacement): Likewise. (abs_replacement): Likewise. * gcc.dg/torture/pr67769.c: New test. From-SVN: r228341 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 06c9a298153..c9f987ea815 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2015-10-01 Marek Polacek + + PR tree-optimization/67769 + * tree-ssa-phiopt.c (conditional_replacement): Call + reset_flow_sensitive_info_in_bb. + (minmax_replacement): Likewise. + (abs_replacement): Likewise. + 2015-10-01 Nathan Sidwell * builtins.c: Don't include gomp-constants.h. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4b5d14761a3..1d4713d6799 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-10-01 Marek Polacek + + PR tree-optimization/67769 + * gcc.dg/torture/pr67769.c: New test. + 2015-10-01 Uros Bizjak * gcc.dg/lto/pr55113_0.c: Skip on all x86 targets. diff --git a/gcc/testsuite/gcc.dg/torture/pr67769.c b/gcc/testsuite/gcc.dg/torture/pr67769.c new file mode 100644 index 00000000000..c1d17c3f3db --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr67769.c @@ -0,0 +1,23 @@ +/* { dg-do run } */ + +static int +clamp (int x, int lo, int hi) +{ + return (x < lo) ? lo : ((x > hi) ? hi : x); +} + +__attribute__ ((noinline)) +short +foo (int N) +{ + short value = clamp (N, 0, 16); + return value; +} + +int +main () +{ + if (foo (-5) != 0) + __builtin_abort (); + return 0; +} diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index 37fdf28d31b..697836a3c14 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -646,6 +646,7 @@ conditional_replacement (basic_block cond_bb, basic_block middle_bb, } replace_phi_edge_with_variable (cond_bb, e1, phi, new_var); + reset_flow_sensitive_info_in_bb (cond_bb); /* Note that we optimized this PHI. */ return true; @@ -1284,6 +1285,8 @@ minmax_replacement (basic_block cond_bb, basic_block middle_bb, gsi_insert_before (&gsi, new_stmt, GSI_NEW_STMT); replace_phi_edge_with_variable (cond_bb, e1, phi, result); + reset_flow_sensitive_info_in_bb (cond_bb); + return true; } @@ -1402,6 +1405,7 @@ abs_replacement (basic_block cond_bb, basic_block middle_bb, } replace_phi_edge_with_variable (cond_bb, e1, phi, result); + reset_flow_sensitive_info_in_bb (cond_bb); /* Note that we optimized this PHI. */ return true;