https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111432
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org Last reconfirmed| |2023-10-10 Ever confirmed|0 |1 Status|UNCONFIRMED |ASSIGNED --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- The reason why this is correct is: a & (x | CST) -> (a & x) | (a & CST) -> // due to `a & CST -> a` (a & x) | a -> a So: ``` /* `a & (x | CST)` -> a if we know that (a & ~CST) == 0 */ (simplify (bit_and:c SSA_NAME@0 (bit_ior @1 INTEGER_CST@2)) (if (INTEGRAL_TYPE_P (TREE_TYPE (@0)) && wi::bit_and_not (get_nonzero_bits (@0), wi::to_wide (@2)) == 0) @0)) ``` // a | (x & CST) simplifies down to `(a | x) & CST` but I don't see if that is an improvement here as we still have 2 operations.