https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64511
--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The #c8 case can be easily fixed:
--- gcc/simplify-rtx.c.jj 2015-01-19 09:31:25.000000000 +0100
+++ gcc/simplify-rtx.c 2015-01-21 10:59:03.808280655 +0100
@@ -4589,7 +4589,8 @@ simplify_relational_operation_1 (enum rt
if ((code == EQ || code == NE)
&& op0code == AND
&& rtx_equal_p (XEXP (op0, 0), op1)
- && !side_effects_p (op1))
+ && !side_effects_p (op1)
+ && op1 != CONST0_RTX (cmp_mode))
{
rtx not_y = simplify_gen_unary (NOT, cmp_mode, XEXP (op0, 1), cmp_mode);
rtx lhs = simplify_gen_binary (AND, cmp_mode, not_y, XEXP (op0, 0));
@@ -4602,7 +4603,8 @@ simplify_relational_operation_1 (enum rt
if ((code == EQ || code == NE)
&& op0code == AND
&& rtx_equal_p (XEXP (op0, 1), op1)
- && !side_effects_p (op1))
+ && !side_effects_p (op1)
+ && op1 != CONST0_RTX (cmp_mode))
{
rtx not_x = simplify_gen_unary (NOT, cmp_mode, XEXP (op0, 0), cmp_mode);
rtx lhs = simplify_gen_binary (AND, cmp_mode, not_x, XEXP (op0, 1));
The thing is that the MEM has side_effects_p, thus we don't optimize (and (mem)
(const_int 0)) into (const_int 0), and this optimization turns the
(ne (and (mem) (const_int 0)) (const_int 0))
into
(ne (and (not (mem)) (const_int 0)) (const_int 0))
which is turned into:
(ne (and (mem) (const_int 0)) (const_int 0))
and so forth. Whether this is a problem with the original testcase will have
to verify.