https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61734
--- Comment #5 from Marc Glisse <glisse at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #2) > So perhaps teach fold also about A CMP B ? A - B : -(A - B) etc.? Or teach phiopt about A CMP B ? (U)((T)A - (T)B) : (U)((T)B - (T)A)? Hmm, it is starting to be a bit big, with a number of variations depending on where the casts are. fold may be easier indeed. (In reply to Jakub Jelinek from comment #4) > Perhaps in addition to MINUS_EXPR we should handle PLUS_EXPR with > INTEGER_CST second operand, so > A >= 5 ? (A + (-5)) : -(A + (-5)) and similar cases. I believe we canonicalize A+(-5) to A-5, but A >= -5 ? (A + 5) : -(A + 5) is the same idea.