From: Richard Biener Date: Thu, 17 Aug 2017 07:16:30 +0000 (+0000) Subject: tree-vrp.c (vrp_int_const_binop): Do not set *overflow_p to true when overflow is... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=344be1fd47d7d64ea85c159b14745ba107ce71ae;p=gcc.git tree-vrp.c (vrp_int_const_binop): Do not set *overflow_p to true when overflow is undefined and we saturated the... 2017-08-17 Richard Biener * tree-vrp.c (vrp_int_const_binop): Do not set *overflow_p to true when overflow is undefined and we saturated the result. * gcc.dg/tree-ssa/vrp117.c: New testcase. From-SVN: r251141 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 658a8e28588..bed451652a7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-08-17 Richard Biener + + * tree-vrp.c (vrp_int_const_binop): Do not set *overflow_p + to true when overflow is undefined and we saturated the + result. + 2017-08-17 Alan Modra PR target/80938 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c6f729aecf6..2b2183fa576 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-08-17 Richard Biener + + * gcc.dg/tree-ssa/vrp117.c: New testcase. + 2017-08-16 Uros Bizjak * c-c++-common/patchable_function_entry-decl.c (dg-final): Adapt diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp117.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp117.c new file mode 100644 index 00000000000..d07a6722cd7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp117.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-evrp" } */ + +void link_error (void); + +void foo (int i) +{ + if (i > __INT_MAX__ - 10) + { + int j = i * 10; + if (j < i) + link_error (); + } +} + +/* { dg-final { scan-tree-dump-not "link_error" "evrp" } } */ diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 657a8d186c8..e3735ff4023 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -1614,6 +1614,8 @@ vrp_int_const_binop (enum tree_code code, tree val1, tree val2, signop sign = TYPE_SIGN (TREE_TYPE (val1)); wide_int res; + *overflow_p = false; + switch (code) { case RSHIFT_EXPR: @@ -1685,8 +1687,6 @@ vrp_int_const_binop (enum tree_code code, tree val1, tree val2, gcc_unreachable (); } - *overflow_p = overflow; - if (overflow && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (val1))) { @@ -1730,6 +1730,8 @@ vrp_int_const_binop (enum tree_code code, tree val1, tree val2, TYPE_SIGN (TREE_TYPE (val1))); } + *overflow_p = overflow; + return res; }