[PATCH] Fix PR43661
Richard Guenther
rguenther@suse.de
Tue Apr 6 09:25:00 GMT 2010
This fixes an ICE when folding an unfolded tree by explicitly handling
the case we didn't expect to encounter.
Bootstrap and regtest running on x86_64-unknown-linux-gnu.
Richard.
2010-04-06 Richard Guenther <rguenther@suse.de>
PR middle-end/43661
* fold-const.c (fold_comparison): Handle X * 0 CMP 0.
* gcc.c-torture/compile/pr43661.c: New testcase.
Index: gcc/fold-const.c
===================================================================
*** gcc/fold-const.c (revision 157983)
--- gcc/fold-const.c (working copy)
*************** fold_comparison (location_t loc, enum tr
*** 9576,9582 ****
tree variable1 = TREE_OPERAND (arg0, 0);
enum tree_code cmp_code = code;
! gcc_assert (!integer_zerop (const1));
fold_overflow_warning (("assuming signed overflow does not occur when "
"eliminating multiplication in comparison "
--- 9576,9584 ----
tree variable1 = TREE_OPERAND (arg0, 0);
enum tree_code cmp_code = code;
! /* Handle unfolded multiplication by zero. */
! if (integer_zerop (const1))
! return fold_build2_loc (loc, cmp_code, type, const1, const2);
fold_overflow_warning (("assuming signed overflow does not occur when "
"eliminating multiplication in comparison "
Index: gcc/testsuite/gcc.c-torture/compile/pr43661.c
===================================================================
*** gcc/testsuite/gcc.c-torture/compile/pr43661.c (revision 0)
--- gcc/testsuite/gcc.c-torture/compile/pr43661.c (revision 0)
***************
*** 0 ****
--- 1,5 ----
+ int
+ func (int x)
+ {
+ return 0 ? (unsigned short) (0 ? : 1 * (signed char) (x ^ x) >= 0) : 1;
+ }
More information about the Gcc-patches
mailing list