re PR middle-end/31710 (ICE in in set_value_range, at tree-vrp.c:278)
authorIan Lance Taylor <iant@google.com>
Fri, 27 Apr 2007 20:47:24 +0000 (20:47 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Fri, 27 Apr 2007 20:47:24 +0000 (20:47 +0000)
./: PR middle-end/31710
* tree.c (build_distinct_type_copy): If TYPE_MIN_VALUE or
TYPE_MAX_VALUE exist, convert them to the new type.
testsuite/:
PR middle-end/31710
* gcc.c-torture/compile/pr31710.c: New test.

From-SVN: r124237

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr31710.c [new file with mode: 0644]
gcc/tree.c

index b50c1aab5fcc54f3768c599b28b20a13bdd3e49c..9e1510b2f5ed8cac31191bbf8b2bb026de93072c 100644 (file)
@@ -1,3 +1,9 @@
+2007-04-27  Ian Lance Taylor  <iant@google.com>
+
+       PR middle-end/31710
+       * tree.c (build_distinct_type_copy): If TYPE_MIN_VALUE or
+       TYPE_MAX_VALUE exist, convert them to the new type.
+
 2007-04-27  Zdenek Dvorak  <dvorakz@suse.cz>
 
        * tree-cfgcleanup.c (cleanup_tree_cfg): Verify dominance info
index 49ed2ba7f837e760e43f1b92b50bc4d8b54ba5b8..22726009746c84145f305f8690093d6addfc6817 100644 (file)
@@ -1,3 +1,8 @@
+2007-04-27  Ian Lance Taylor  <iant@google.com>
+
+       PR middle-end/31710
+       * gcc.c-torture/compile/pr31710.c: New test.
+
 2007-04-27  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/30965
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr31710.c b/gcc/testsuite/gcc.c-torture/compile/pr31710.c
new file mode 100644 (file)
index 0000000..0c8562d
--- /dev/null
@@ -0,0 +1,6 @@
+typedef short SHORT;
+struct v { SHORT i; };
+void f(struct v *pin, struct v *pout) {
+        if (pin->i == (-0x7fff)-1)
+            pout->i = -pin->i;
+}
index 1f2e91919e8a86fa8e56cb770089809113228625..626f8e447c04a259b0259291338c271199117fc3 100644 (file)
@@ -4174,6 +4174,15 @@ build_distinct_type_copy (tree type)
   TYPE_MAIN_VARIANT (t) = t;
   TYPE_NEXT_VARIANT (t) = 0;
   
+  /* VRP assumes that TREE_TYPE (TYPE_MIN_VALUE (type)) == type.  */
+  if (INTEGRAL_TYPE_P (t) || SCALAR_FLOAT_TYPE_P (t))
+    {
+      if (TYPE_MIN_VALUE (t) != NULL_TREE)
+       TYPE_MIN_VALUE (t) = fold_convert (t, TYPE_MIN_VALUE (t));
+      if (TYPE_MAX_VALUE (t) != NULL_TREE)
+       TYPE_MAX_VALUE (t) = fold_convert (t, TYPE_MAX_VALUE (t));
+    }
+
   return t;
 }