From cb460086e1601d7ed22a2d911adede51c945c66f Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 19 May 2014 12:32:15 +0000 Subject: [PATCH] re PR tree-optimization/61184 (wrong code (that hangs) by LTO on x86_64-linux-gnu) 2014-05-19 Richard Biener PR tree-optimization/61184 * tree-vrp.c (is_negative_overflow_infinity): Use TREE_OVERFLOW_P and do that check first. (is_positive_overflow_infinity): Likewise. (is_overflow_infinity): Likewise. (vrp_operand_equal_p): Properly treat operands with differing overflow as not equal. * c-c++-common/torture/pr61184.c: New testcase. From-SVN: r210611 --- gcc/ChangeLog | 10 ++++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/c-c++-common/torture/pr61184.c | 18 ++++++++++++++++++ gcc/tree-vrp.c | 19 +++++++------------ 4 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 gcc/testsuite/c-c++-common/torture/pr61184.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 57dbd0faa692..c69a30cff516 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2014-05-19 Richard Biener + + PR tree-optimization/61184 + * tree-vrp.c (is_negative_overflow_infinity): Use + TREE_OVERFLOW_P and do that check first. + (is_positive_overflow_infinity): Likewise. + (is_overflow_infinity): Likewise. + (vrp_operand_equal_p): Properly treat operands with + differing overflow as not equal. + 2014-05-19 Bernd Schmidt * simplify-rtx.c (simplify_unary_operation_1): Use CONST_INT_P in diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 846ad6d446c6..d731eb91da3a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-05-19 Richard Biener + + PR tree-optimization/61184 + * c-c++-common/torture/pr61184.c: New testcase. + 2014-05-19 Christian Bruel PR target/61195 diff --git a/gcc/testsuite/c-c++-common/torture/pr61184.c b/gcc/testsuite/c-c++-common/torture/pr61184.c new file mode 100644 index 000000000000..83117b9cfb09 --- /dev/null +++ b/gcc/testsuite/c-c++-common/torture/pr61184.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ +/* { dg-additional-options "-fno-strict-overflow" } */ + +short a; + +void +foo (void) +{ + for (a = 0; a >= 0; a++) + ; +} + +int +main () +{ + foo (); + return 0; +} diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 633c329030f6..7f0489f3c255 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -293,9 +293,8 @@ positive_overflow_infinity (tree type) static inline bool is_negative_overflow_infinity (const_tree val) { - return (needs_overflow_infinity (TREE_TYPE (val)) - && CONSTANT_CLASS_P (val) - && TREE_OVERFLOW (val) + return (TREE_OVERFLOW_P (val) + && needs_overflow_infinity (TREE_TYPE (val)) && vrp_val_is_min (val)); } @@ -304,9 +303,8 @@ is_negative_overflow_infinity (const_tree val) static inline bool is_positive_overflow_infinity (const_tree val) { - return (needs_overflow_infinity (TREE_TYPE (val)) - && CONSTANT_CLASS_P (val) - && TREE_OVERFLOW (val) + return (TREE_OVERFLOW_P (val) + && needs_overflow_infinity (TREE_TYPE (val)) && vrp_val_is_max (val)); } @@ -315,9 +313,8 @@ is_positive_overflow_infinity (const_tree val) static inline bool is_overflow_infinity (const_tree val) { - return (needs_overflow_infinity (TREE_TYPE (val)) - && CONSTANT_CLASS_P (val) - && TREE_OVERFLOW (val) + return (TREE_OVERFLOW_P (val) + && needs_overflow_infinity (TREE_TYPE (val)) && (vrp_val_is_min (val) || vrp_val_is_max (val))); } @@ -791,9 +788,7 @@ vrp_operand_equal_p (const_tree val1, const_tree val2) return true; if (!val1 || !val2 || !operand_equal_p (val1, val2, 0)) return false; - if (is_overflow_infinity (val1)) - return is_overflow_infinity (val2); - return true; + return is_overflow_infinity (val1) == is_overflow_infinity (val2); } /* Return true, if the bitmaps B1 and B2 are equal. */ -- 2.47.3