https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97711
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #4) > (In reply to Andrew Pinski from comment #3) > > Mine, the patch which fixes PR 103216 fixes this too. > > Note it does not fix it fully on the gimple level, we are left with: > _1 = x_3(D) & 1; > _7 = _1 != 0; > _6 = (int) _7; > _9 = x_3(D) - _6; So this is optimized because VRP is able to figure out _1 has a range of [0,1] a and then able to change _1 != 0 to (bool) _1. That will be for GCC 13 to fix this fully on the gimple level.