------- Comment #4 from rguenth at gcc dot gnu dot org 2006-11-10 14:35 ------- /* Optimize away "if (x & C) x |= C" and similar bit manipulation transformations. */
static int noce_try_bitop (struct noce_if_info *if_info) { ... /* ??? We could also handle AND here. */ if (GET_CODE (cond) == ZERO_EXTRACT) { if (XEXP (cond, 1) != const1_rtx || GET_CODE (XEXP (cond, 2)) != CONST_INT || ! rtx_equal_p (x, XEXP (cond, 0))) return FALSE; bitnum = INTVAL (XEXP (cond, 2)); mode = GET_MODE (x); if (bitnum >= HOST_BITS_PER_WIDE_INT) return FALSE; ... which is wrong for little-endian bitfieds ... /* if ((x & C) == 0) x |= C; is transformed to x |= C. */ /* if ((x & C) != 0) x |= C; is transformed to nothing. */ if (GET_CODE (a) == IOR) result = (code == NE) ? a : NULL_RTX; else if (code == NE) { /* if ((x & C) == 0) x ^= C; is transformed to x |= C. */ result = gen_int_mode ((HOST_WIDE_INT) 1 << bitnum, mode); result = simplify_gen_binary (IOR, mode, x, result); } else { /* if ((x & C) != 0) x ^= C; is transformed to x &= ~C. */ result = gen_int_mode (~((HOST_WIDE_INT) 1 << bitnum), mode); result = simplify_gen_binary (AND, mode, x, result); } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29797