http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59429
--- Comment #9 from Kai Tietz <ktietz at gcc dot gnu.org> --- The general solution here for patterns like '(a cmp1 b ? x : (a cmp2 b ? y : z))' would be to split such statment up into 3 conditions like: if (a cmp1 b) r = x; else if (a cmp2 b) r = y; else if (!(a cmp2 b && a cmp1 b)) r = z; By this we can resort conditions and try to normalize it. Of course this just works for floating-points with fast-math, or just on integral types.