https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110919
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- After reassoc1 we have: _19 = _6 == iftmp.1_8; _3 = iftmp.1_8 ^ 1; _21 = (_Bool) _3; _23 = _6 != 0; _10 = _19 & _23; _5 = _10 & _21; Which is: (_6 != 0) & (_6 == iftmp.1_8) But since we know that iftmp.1_8 only has 2 values, we could optimize this to: (_6 == 1) & (iftmp.1_8 == 1) Reduced testcase: ``` _Bool f(int a, int b) { b &= 1; _Bool t = a == b; int c = b^1; _Bool d = c; _Bool e = a; _Bool g = t & d; _Bool h = g & e; return h; } ``` This should return false always. So something like: (simplify (bit_and:c (eq:c @0 @1) (ne:c @0 INTEGER_CST@2)) (if (has_two_value_range (@1)) (with { tree other_value = ...; } (bit_and (eq @0 { other_value; }) (eq @1 { other_value; })) ) ) )