https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54571
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Richard Biener from comment #1) > Confirmed. The natural place to optimize this is the tree level phiopt pass. > > <bb 2>: > _3 = x_2(D) & 2; > if (_3 != 0) > goto <bb 3>; > else > goto <bb 4>; > > <bb 3>: > y_5 = y_4(D) | 1; > > <bb 4>: > # y_1 = PHI <y_4(D)(2), y_5(3)> > > where we should handle > > int f1(int x, int y, int d) { int tem; if ((tem = x & d)) y |= tem; return > y; } > > as well. Yes, that's just y |= x & d, but it falls out naturally if the > transform is implemented in a generic enough way. This one should be easy to add to match.pd: (simplify (cond @1 (ior @2 INTEGER_CST@3) @2) (ior @2 (bit_and (negate (convert @1)) @3))) (bit_and (negate (convert thurth_value@1)) integer_onep) should be just converted to: @1 Which is not done right now, I fill that as a bug.