https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87248
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
/* A & N ? N : 0 is simply A & N if N is a power of two. This
is probably obsolete because the first operand should be a
truth value (that's why we have the two cases above), but let's
leave it in until we can confirm this for all front-ends. */
if (integer_zerop (op2)
&& TREE_CODE (arg0) == NE_EXPR
&& integer_zerop (TREE_OPERAND (arg0, 1))
&& integer_pow2p (arg1)
&& TREE_CODE (TREE_OPERAND (arg0, 0)) == BIT_AND_EXPR
&& operand_equal_p (TREE_OPERAND (TREE_OPERAND (arg0, 0), 1),
arg1, OEP_ONLY_CONST))
return pedantic_non_lvalue_loc (loc,
fold_convert_loc (loc, type,
TREE_OPERAND (arg0, 0)));
is the problem, while arg1 (8-bit) is integer_pow2p, TREE_OPERAND (TREE_OPERAND
(arg0, 0), 1)) is equal to it (-128), but is not a pow2p.