diff options
author | Richard Biener <rguenther@suse.de> | 2014-10-28 11:42:43 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2014-10-28 11:42:43 +0000 |
commit | 9ccaac1188959d2b35cfa820c46277ebef5f75e0 (patch) | |
tree | dfad2841958e84ccd1eaf6859b533ff386a916aa | |
parent | e29dfbf07d93e89e92d8b95bef247fc95a8024ef (diff) | |
download | gcc-9ccaac1188959d2b35cfa820c46277ebef5f75e0.zip gcc-9ccaac1188959d2b35cfa820c46277ebef5f75e0.tar.gz gcc-9ccaac1188959d2b35cfa820c46277ebef5f75e0.tar.bz2 |
re PR tree-optimization/63665 (wrong code with signed overflow even with -fwrapv)
2014-10-28 Richard Biener <rguenther@suse.de>
PR middle-end/63665
* fold-const.c (fold_comparison): Properly guard simplifying
against INT_MAX/INT_MIN with !TYPE_OVERFLOW_WRAPS.
* gcc.dg/pr63665.c: New testcase.
From-SVN: r216781
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fold-const.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr63665.c | 18 |
4 files changed, 31 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 536a000..1f3a0fb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-10-28 Richard Biener <rguenther@suse.de> + + PR middle-end/63665 + * fold-const.c (fold_comparison): Properly guard simplifying + against INT_MAX/INT_MIN with !TYPE_OVERFLOW_WRAPS. + 2014-10-28 Alan Lawrence <alan.lawrence@arm.com> * expr.c (expand_expr_real_2): Remove code handling VEC_LSHIFT_EXPR. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 8166070..218afa0 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -8749,7 +8749,8 @@ fold_comparison (location_t loc, enum tree_code code, tree type, /* If the constant operation overflowed this can be simplified as a comparison against INT_MAX/INT_MIN. */ - if (TREE_OVERFLOW (new_const)) + if (TREE_OVERFLOW (new_const) + && !TYPE_OVERFLOW_WRAPS (TREE_TYPE (arg0))) { int const1_sgn = tree_int_cst_sgn (const1); enum tree_code code2 = code; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e0759c3..d08d102 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-10-28 Richard Biener <rguenther@suse.de> + + PR middle-end/63665 + * gcc.dg/pr63665.c: New testcase. + 2014-10-28 Yury Gribov <y.gribov@samsung.com> * c-c++-common/asan/kasan-recover-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/pr63665.c b/gcc/testsuite/gcc.dg/pr63665.c new file mode 100644 index 0000000..046ecae --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr63665.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ +/* { dg-require-effective-target int32plus } */ +/* { dg-options "-O -fno-tree-ccp -fno-tree-fre -fno-tree-copy-prop -fwrapv" } */ + +static inline int +test5 (int x) +{ + int y = 0x80000000; + return x + y; +} + +int +main () +{ + if (test5 (0x80000000) != 0) + __builtin_abort (); + return 0; +} |