https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93131

--- Comment #11 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #10)
> 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.

Yes I agree.  Let me add those conditions too.  Especially when it comes to
generic version, rather than just the gimple version.

Reply via email to