I once wondered why fold didn't optimize (long)int-val > INT_MAX
when niter analysis tried to fold this.  Now when moving
fold_widened_comparison to match.pd I noticed that a bogus
condition on the limit folding causes it to only apply in the
case when it won't simplify anything...

Thus, fixed.  C testcase notoriously hard because of the frontend
already shortening the compare (and doing the desired simplification).

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2015-07-08  Richard Biener  <rguent...@suse.de>

        * fold-const.c (fold_widened_comparison): Fix inverted comparison.

Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c    (revision 225501)
+++ gcc/fold-const.c    (working copy)
@@ -6794,7 +6794,7 @@ fold_widened_comparison (location_t loc,
 
   if (TREE_CODE (arg1_unw) != INTEGER_CST
       || TREE_CODE (shorter_type) != INTEGER_TYPE
-      || !int_fits_type_p (arg1_unw, shorter_type))
+      || int_fits_type_p (arg1_unw, shorter_type))
     return NULL_TREE;
 
   /* If we are comparing with the integer that does not fit into the range

Reply via email to