[Bug tree-optimization/93131] ((a&8) == 8) && ((a&2) == 2) is not optimized to (a&(8|2)) == (8|2)
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jan 2 21:47:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93131
--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Oh, and there is another case I'm worried about. While match.pd has the
/* X == C (or X & Z == Y | C) is impossible if ~nonzero(X) & C != 0. */
(for cmp (eq ne)
(simplify
(cmp:c (with_possible_nonzero_bits2 @0) (with_certain_nonzero_bits2 @1))
(if (wi::bit_and_not (wi::to_wide (@1), get_nonzero_bits (@0)) != 0)
{ constant_boolean_node (cmp == NE_EXPR, type); })))
optimization, not sure if we can rely on that one happening always before this
one, and if it doesn't, e.g.
((x & 6) == 5) & ((x & 15) == 13)
where the precondition ((6 & 15) & 5) == ((6 & 15) & 13) is true we would
incorrectly transform it into (x & 15) == 13, even when it should be false.
So, shouldn't the precondition be (N&M)&CST1 == (N&M)&CST2 && (CST1&~N) == 0 &&
(CST2&~M) == 0?
Especially when get_nonzero_bits will not really do anything until ccp or other
optimization determines those.
More information about the Gcc-bugs
mailing list