http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55152
--- Comment #4 from Marc Glisse <glisse at gcc dot gnu.org> --- Created attachment 30502 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30502&action=edit fold-const.c patch I've had this patch on my hard drive for a while and it will be better here. It needs more work. The MAX optimization can probably never be reached from C code (and the signed overflow warning seems unnecessary in this particular case), part of the patch should move to gimple I guess, and I shouldn't produce the non-canonical 0 op X when I could easily use swap_tree_comparison.