https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115275
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- I suspect r14-1951-g7b34cacc573538 exposes the missed optimization here. You can see the same missed optimization with: ``` template<class T> T min(T a, T b) { return a < b ? a : b; } template<class T> T max(T a, T b) { return a > b ? a : b; } unsigned short m, a, b; void fn(unsigned short f) { if( (min(max(f, a) ? f : 0U, 84991U)) - (min(max(f, b) ? f : 0U, 84991U)) ) {m=1;} } ```