From 2c9da85bf03e2920af2dca3bb124abc745bc365b Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 26 Apr 2011 15:33:49 +0200 Subject: [PATCH] re PR tree-optimization/48734 (ICE in eliminate_redundant_comparison, at tree-ssa-reassoc.c:1321) PR tree-optimization/48734 * tree-ssa-reassoc.c (eliminate_redundant_comparison): Give up if return value from maybe_fold_*_comparsions isn't something the code is prepared to handle. * gcc.c-torture/compile/pr48734.c: New test. From-SVN: r172967 --- gcc/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gcc.c-torture/compile/pr48734.c | 11 +++++++++++ gcc/tree-ssa-reassoc.c | 17 ++++++++++++++++- 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr48734.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4d2bd987d29..0bf1088b0bb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2011-04-26 Jakub Jelinek + + PR tree-optimization/48734 + * tree-ssa-reassoc.c (eliminate_redundant_comparison): Give up + if return value from maybe_fold_*_comparsions isn't something + the code is prepared to handle. + 2011-04-26 Uros Bizjak * config/i386/predicates.md (ext_QIreg_operand): Remove extra diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 878490ae58f..c07caacb2c1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2011-04-26 Jakub Jelinek + PR tree-optimization/48734 + * gcc.c-torture/compile/pr48734.c: New test. + PR testsuite/48753 * gcc.dg/tree-prof/val-prof-2.c: Adjust for 32-bit HWI. diff --git a/gcc/testsuite/gcc.c-torture/compile/pr48734.c b/gcc/testsuite/gcc.c-torture/compile/pr48734.c new file mode 100644 index 00000000000..b20ea80fb3f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr48734.c @@ -0,0 +1,11 @@ +/* PR tree-optimization/48734 */ + +unsigned int +foo (int x, unsigned int y, unsigned int z) +{ + z &= (x == -__INT_MAX__ - 1 ? x : -x) > y; + z &= (x == -__INT_MAX__ - 1 ? x : -x) > y; + z &= (x == -__INT_MAX__ - 1 ? x : -x) > y; + z &= (x == -__INT_MAX__ - 1 ? x : -x) > y; + return z; +} diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 904fef80447..987ec650778 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -1,5 +1,6 @@ /* Reassociation for trees. - Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2005, 2007, 2008, 2009, 2010, 2011 + Free Software Foundation, Inc. Contributed by Daniel Berlin This file is part of GCC. @@ -1279,6 +1280,20 @@ eliminate_redundant_comparison (enum tree_code opcode, if (!useless_type_conversion_p (TREE_TYPE (curr->op), TREE_TYPE (t))) t = fold_convert (TREE_TYPE (curr->op), t); + if (TREE_CODE (t) != INTEGER_CST + && !operand_equal_p (t, curr->op, 0)) + { + enum tree_code subcode; + tree newop1, newop2; + if (!COMPARISON_CLASS_P (t)) + continue; + extract_ops_from_tree (t, &subcode, &newop1, &newop2); + STRIP_USELESS_TYPE_CONVERSION (newop1); + STRIP_USELESS_TYPE_CONVERSION (newop2); + if (!is_gimple_val (newop1) || !is_gimple_val (newop2)) + continue; + } + if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "Equivalence: "); -- 2.30.2