Jakub Jelinek <ja...@redhat.com> wrote: >Hi! > >As mentioned in the PR, the actual important bug has been fixed in >range_fits_type_p by Richard Sandiford recently, so here are just two >minor >nits. An extension of a signed src_type to unsigned wider type is fine >only >if the vr doesn't have negative min or max, so always assuming we can >extend >is wrong (but not a very big deal, as we always pass unsigned_p = false >when calling the function right now). >The other change mattered in 4.7 where CODE_FOR_nothing is a big >number, in >4.8 it is just a consistency issue when all the other can_float_p calls >are compared with CODE_FOR_nothing (== 0). > >Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > >What about 4.7 (together with backport of Richard's >http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194800 fix) after a >while?
Ok for both. Thanks, Richard. >2013-01-07 Jakub Jelinek <ja...@redhat.com> > > PR tree-optimization/54120 > * tree-vrp.c (range_fits_type_p): Don't allow > src_precision < precision from signed vr to unsigned_p > if vr->min or vr->max is negative. > (simplify_float_conversion_using_ranges): Test can_float_p > against CODE_FOR_nothing. > >--- gcc/tree-vrp.c.jj 2013-01-02 21:05:34.137069022 +0100 >+++ gcc/tree-vrp.c 2013-01-07 18:15:32.088880351 +0100 >@@ -8753,9 +8753,11 @@ range_fits_type_p (value_range_t *vr, un > && !POINTER_TYPE_P (src_type)) > return false; > >- /* An extension is always fine, so is an identity transform. */ >+ /* An extension is fine unless VR is signed and unsigned_p, >+ and so is an identity transform. */ > src_precision = TYPE_PRECISION (TREE_TYPE (vr->min)); >- if (src_precision < precision >+ if ((src_precision < precision >+ && !(unsigned_p && !TYPE_UNSIGNED (src_type))) > || (src_precision == precision > && TYPE_UNSIGNED (src_type) == unsigned_p)) > return true; >@@ -8813,7 +8815,7 @@ simplify_float_conversion_using_ranges ( > mode = TYPE_MODE (TREE_TYPE (rhs1)); >/* If we can do the conversion in the current input mode do nothing. >*/ > else if (can_float_p (fltmode, TYPE_MODE (TREE_TYPE (rhs1)), >- TYPE_UNSIGNED (TREE_TYPE (rhs1)))) >+ TYPE_UNSIGNED (TREE_TYPE (rhs1))) != CODE_FOR_nothing) > return false; > /* Otherwise search for a mode we can use, starting from the narrowest > integer mode available. */ > > Jakub