https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122837
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #2) > (In reply to Richard Biener from comment #1) > > <bb 2> [local count: 1073741824]: > > if (a_2(D) > b_3(D)) > > goto <bb 4>; [50.00%] > > else > > goto <bb 3>; [50.00%] > > > > <bb 3> [local count: 536870912]: > > > > <bb 4> [local count: 1073741824]: > > # __m_7 = PHI <a_2(D)(3), b_3(D)(2)> > > # __M_6 = PHI <b_3(D)(3), a_2(D)(2)> > > # prephitmp_17 = PHI <1(3), 18446744073709551615(2)> > > _8 = __M_6 - __m_7; > > _9 = _8 >> 1; > > _10 = _9 * prephitmp_17; > > _11 = a_2(D) + _10; > > return _11; > > > > so we miss max/min detection and a > b ? 1 : -1 is not if-converted either. > > > > But possibly the whole thing needs to be pattern-matched? > > The min/max issue is PR 67962 and PR 80874 . > > The 1/-1 thing could be rewritten as: > _100 = PHI <0(3), 1(2)> > > _101 = - _9; > _10 = _100 ? _101 : _9; > (if there is negcc optab for that type; or maybe just movcc) > > And then that should be convert into: > _100 = a_2(D) > b_3(D); > _10 = _100 ? _101 : _9; > > And I think combined that with the min/max it would just work. Meaning this is an isel+more advanced phiopt.
