[Bug tree-optimization/101650] (len | N) == len is transformed to len & N != 0
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Aug 23 01:22:09 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101650
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So the pattern which we have currently matching (X | Y) == Y does this:
/* (X | Y) == Y becomes (X & ~Y) == 0. */
(simplify
(cmp:c (bit_ior:c @0 @1) @1)
(cmp (bit_and @0 (bit_not! @1)) { build_zero_cst (TREE_TYPE (@0)); }))
So adding:
/* (Y | CST) == Y becomes (Y & CST) != 0. */
(simplify
(cmp:c (bit_ior @1 INTEGER_CST@0) @1)
(icmp (bit_and @1 @0) { build_zero_cst (TREE_TYPE (@0)); }))
Is needed.
More information about the Gcc-bugs
mailing list