[Bug tree-optimization/52345] Missed optimization dealing with bools

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Apr 22 03:37:00 GMT 2018


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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The generic rule is:
original 3 expressions;

(((int)b) | i) == 0 -> (b == 0) & (i == 0) -> ~b & (i == 0)
    (4 expressions; maybe 3 if b is a comparison and single use)
(((int)b) | i) != 0 -> (b != 0) | (i != 0) -> b | (i != 0)
    (still 3 expressions)

(((int)b) & i) == 0 -> (b == 0) | ((i&1) == 0) -> ~b | ((i&1) == 0)
    (4 expressions; maybe 3 if b is a comparison and single use)

(((int)b) & i) != 0 -> (b != 0) & ((i&1) != 0) -> b & ((i&1) != 0)
    (still 3 expressions)
Where b is a "boolean" type variable.


More information about the Gcc-bugs mailing list