From 8a87e7abcb28cc53fb1be10b453d030a039de15e Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 30 Mar 2011 14:36:18 +0200 Subject: [PATCH] re PR c/48305 (ice at -O0: verify_gimple failed) PR c/48305 * fold-const.c (fold_binary_loc) : Make sure arg10/arg11 in (X ^ Y) == (Z ^ W) are always fold converted to matching arg00/arg01 types. * gcc.c-torture/compile/pr48305.c: New test. From-SVN: r171723 --- gcc/ChangeLog | 7 +++++++ gcc/fold-const.c | 16 ++++++++++++---- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/compile/pr48305.c | 7 +++++++ 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr48305.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0229f63f8f6..9458d99393e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2011-03-30 Jakub Jelinek + + PR c/48305 + * fold-const.c (fold_binary_loc) : Make sure + arg10/arg11 in (X ^ Y) == (Z ^ W) are always fold converted to + matching arg00/arg01 types. + 2011-03-30 Eric Botcazou * cfglayout.c (insn_locators_alloc): Initialize curr_location and diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 017aa8ad9cb..0c0420d043c 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -12606,13 +12606,21 @@ fold_binary_loc (location_t loc, operand_equal_p guarantees no side-effects so we don't need to use omit_one_operand on Z. */ if (operand_equal_p (arg01, arg11, 0)) - return fold_build2_loc (loc, code, type, arg00, arg10); + return fold_build2_loc (loc, code, type, arg00, + fold_convert_loc (loc, TREE_TYPE (arg00), + arg10)); if (operand_equal_p (arg01, arg10, 0)) - return fold_build2_loc (loc, code, type, arg00, arg11); + return fold_build2_loc (loc, code, type, arg00, + fold_convert_loc (loc, TREE_TYPE (arg00), + arg11)); if (operand_equal_p (arg00, arg11, 0)) - return fold_build2_loc (loc, code, type, arg01, arg10); + return fold_build2_loc (loc, code, type, arg01, + fold_convert_loc (loc, TREE_TYPE (arg01), + arg10)); if (operand_equal_p (arg00, arg10, 0)) - return fold_build2_loc (loc, code, type, arg01, arg11); + return fold_build2_loc (loc, code, type, arg01, + fold_convert_loc (loc, TREE_TYPE (arg01), + arg11)); /* Optimize (X ^ C1) op (Y ^ C2) as (X ^ (C1 ^ C2)) op Y. */ if (TREE_CODE (arg01) == INTEGER_CST diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ede28b20e37..52fbcaaec65 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-03-30 Jakub Jelinek + + PR c/48305 + * gcc.c-torture/compile/pr48305.c: New test. + 2011-03-29 Jason Merrill * g++.dg/cpp0x/regress/value-dep1.C: New. diff --git a/gcc/testsuite/gcc.c-torture/compile/pr48305.c b/gcc/testsuite/gcc.c-torture/compile/pr48305.c new file mode 100644 index 00000000000..aaec71c52a3 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr48305.c @@ -0,0 +1,7 @@ +/* PR c/48305 */ + +int +foo (int x) +{ + return (x ^ 1) == (x ^ 1U); +} -- 2.30.2