re PR middle-end/54120 (FAIL: gfortran.fortran-torture/execute/random_2.f90 execution)
authorJakub Jelinek <jakub@redhat.com>
Tue, 8 Jan 2013 08:33:43 +0000 (09:33 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 8 Jan 2013 08:33:43 +0000 (09:33 +0100)
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.

From-SVN: r195007

gcc/ChangeLog
gcc/tree-vrp.c

index 25e60e3..379de4d 100644 (file)
@@ -1,4 +1,13 @@
 2013-01-08  Jakub Jelinek  <jakub@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.
+
+2013-01-08  Jakub Jelinek  <jakub@redhat.com>
            Richard Biener  <rguenther@suse.de>
 
        PR middle-end/55851
index 6b8cbf3..f6b1517 100644 (file)
@@ -1,5 +1,5 @@
 /* Support routines for Value Range Propagation (VRP).
-   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
+   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
    Free Software Foundation, Inc.
    Contributed by Diego Novillo <dnovillo@redhat.com>.
 
@@ -8753,9 +8753,11 @@ range_fits_type_p (value_range_t *vr, unsigned precision, bool unsigned_p)
       && !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 (gimple_stmt_iterator *gsi, gimple stmt)
     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.  */