re PR c/48305 (ice at -O0: verify_gimple failed)
authorJakub Jelinek <jakub@redhat.com>
Wed, 30 Mar 2011 12:36:18 +0000 (14:36 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 30 Mar 2011 12:36:18 +0000 (14:36 +0200)
PR c/48305
* fold-const.c (fold_binary_loc) <case EQ_EXPR, NE_EXPR>: 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
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr48305.c [new file with mode: 0644]

index 0229f63f8f6d9317e2ff1c2d4b0d11ba52865a53..9458d99393e4c6db6478f51be460a5a605cd60c6 100644 (file)
@@ -1,3 +1,10 @@
+2011-03-30  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/48305
+       * fold-const.c (fold_binary_loc) <case EQ_EXPR, NE_EXPR>: Make sure
+       arg10/arg11 in (X ^ Y) == (Z ^ W) are always fold converted to
+       matching arg00/arg01 types.
+
 2011-03-30  Eric Botcazou  <ebotcazou@adacore.com>
 
        * cfglayout.c (insn_locators_alloc): Initialize curr_location and
index 017aa8ad9cbbb22f3619699c749fdd5611a0fa35..0c0420d043c379feabb32ccef8db2233543330fe 100644 (file)
@@ -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
index ede28b20e37e2ff34ee089ea644c48c222212d7e..52fbcaaec650aaff2b2dabd5763168cffd35b7cf 100644 (file)
@@ -1,3 +1,8 @@
+2011-03-30  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/48305
+       * gcc.c-torture/compile/pr48305.c: New test.
+
 2011-03-29  Jason Merrill  <jason@redhat.com>
 
        * 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 (file)
index 0000000..aaec71c
--- /dev/null
@@ -0,0 +1,7 @@
+/* PR c/48305 */
+
+int
+foo (int x)
+{
+  return (x ^ 1) == (x ^ 1U);
+}