From 11c1e63c90eb3540da0b7524a2d7571916102dfe Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 28 Nov 2017 09:40:36 +0100 Subject: [PATCH] re PR tree-optimization/80788 (ICE in set_value_range, at tree-vrp.c:252) PR tree-optimization/80788 * match.pd (X +- C1 CMP C2 -> X CMP C2 -+ C1): If res has TREE_OVERFLOW set, call drop_tree_overflow. * gcc.dg/pr80788.c: New test. From-SVN: r255191 --- gcc/ChangeLog | 6 ++++++ gcc/match.pd | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr80788.c | 13 +++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr80788.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7f5e6cb4573..fd378bd5267 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-11-28 Jakub Jelinek + + PR tree-optimization/80788 + * match.pd (X +- C1 CMP C2 -> X CMP C2 -+ C1): If res + has TREE_OVERFLOW set, call drop_tree_overflow. + 2017-11-28 Richard Biener PR tree-optimization/83158 diff --git a/gcc/match.pd b/gcc/match.pd index 9db48bda047..53f8b86b7d5 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -4393,7 +4393,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0))) { constant_boolean_node (cmp == NE_EXPR, type); } (if (single_use (@3)) - (cmp @0 { res; })))))))) + (cmp @0 { TREE_OVERFLOW (res) + ? drop_tree_overflow (res) : res; })))))))) (for cmp (lt le gt ge) (for op (plus minus) rop (minus plus) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ab587a0d83f..fd6475f31b3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-11-28 Jakub Jelinek + + PR tree-optimization/80788 + * gcc.dg/pr80788.c: New test. + 2017-11-27 Martin Sebor PR c++/83058 diff --git a/gcc/testsuite/gcc.dg/pr80788.c b/gcc/testsuite/gcc.dg/pr80788.c new file mode 100644 index 00000000000..b14d371009d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr80788.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/80788 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fwrapv" } */ + +void +foo (signed char x) +{ + signed char a = (x + 1) ^ 128; + x &= !!a; + if (x != 0) + for (;;) + ; +} -- 2.30.2