+2006-05-21 Kazu Hirata <kazu@codesourcery.com>
+
+ PR rtl-optimization/27671
+ * simplify-rtx.c (simplify_relational_operation_1): Fix
+ simplifications of (eq/ne (xor x y) y) and
+ (eq/ne (xor x y) x).
+
2006-05-21 Bernhard Fischer <aldot@gcc.gnu.org>
* tree-cfg.c: Prune whitespace.
return simplify_gen_relational (code, mode, cmp_mode,
XEXP (op0, 0), XEXP (op0, 1));
- /* (eq/ne (xor x y) x) simplifies to (eq/ne x 0). */
+ /* (eq/ne (xor x y) x) simplifies to (eq/ne y 0). */
if ((code == EQ || code == NE)
&& op0code == XOR
&& rtx_equal_p (XEXP (op0, 0), op1)
- && !side_effects_p (XEXP (op0, 1)))
- return simplify_gen_relational (code, mode, cmp_mode, op1, const0_rtx);
- /* Likewise (eq/ne (xor x y) y) simplifies to (eq/ne y 0). */
+ && !side_effects_p (XEXP (op0, 0)))
+ return simplify_gen_relational (code, mode, cmp_mode,
+ XEXP (op0, 1), const0_rtx);
+
+ /* Likewise (eq/ne (xor x y) y) simplifies to (eq/ne x 0). */
if ((code == EQ || code == NE)
&& op0code == XOR
&& rtx_equal_p (XEXP (op0, 1), op1)
- && !side_effects_p (XEXP (op0, 0)))
- return simplify_gen_relational (code, mode, cmp_mode, op1, const0_rtx);
+ && !side_effects_p (XEXP (op0, 1)))
+ return simplify_gen_relational (code, mode, cmp_mode,
+ XEXP (op0, 0), const0_rtx);
/* (eq/ne (xor x C1) C2) simplifies to (eq/ne x (C1^C2)). */
if ((code == EQ || code == NE)
--- /dev/null
+/* PR rtl-optimization/27671.
+ The combiner used to simplify "a ^ b == a" to "a" via
+ simplify_relational_operation_1 in simplify-rtx.c. */
+
+extern void abort (void) __attribute__ ((noreturn));
+extern void exit (int) __attribute__ ((noreturn));
+
+static int __attribute__((noinline))
+foo (int a, int b)
+{
+ int c = a ^ b;
+ if (c == a)
+ abort ();
+}
+
+int
+main (void)
+{
+ foo (0, 1);
+ exit (0);
+}
--- /dev/null
+/* PR rtl-optimization/27671.
+ The combiner used to simplify "a ^ b == a" to "a" via
+ simplify_relational_operation_1 in simplify-rtx.c. */
+/* { dg-do run } */
+/* { dg-options "-O1" } */
+/* { dg-options "-O1 -march=pentium4" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+
+extern void abort (void) __attribute__ ((noreturn));
+extern void exit (int) __attribute__ ((noreturn));
+
+static void __attribute__ ((noinline))
+bar (int k)
+{
+ int n = k % 2;
+ if (n == 0)
+ abort ();
+}
+
+int
+main (void)
+{
+ bar (1);
+ exit (0);
+}