aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/fold-const.c16
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr48305.c7
4 files changed, 31 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0229f63..9458d99 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 017aa8a..0c0420d 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 ede28b2..52fbcaa 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..aaec71c
--- /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);
+}