re PR tree-optimization/21021 (ICE in tree-vrp building glibc)
authorKazu Hirata <kazu@cs.umass.edu>
Fri, 15 Apr 2005 01:29:44 +0000 (01:29 +0000)
committerKazu Hirata <kazu@gcc.gnu.org>
Fri, 15 Apr 2005 01:29:44 +0000 (01:29 +0000)
gcc/
PR tree-optimization/21021
* tree-vrp.c (compare_values): Work around a bug in the front
end that produces a comparison of mismatched types.

testsuite/
PR tree-optimization/21021
* gcc.c-torture/compile/pr21021.c: New.

From-SVN: r98161

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

index eb8f4db0ea4b54d272bcc1a72cd310cc1488237a..df59529802112a018ff22e78aa07c541249edfbd 100644 (file)
@@ -1,3 +1,9 @@
+2005-04-14  Kazu Hirata  <kazu@cs.umass.edu>
+
+       PR tree-optimization/21021
+       * tree-vrp.c (compare_values): Work around a bug in the front
+       end that produces a comparison of mismatched types.
+
 2004-04-14  Richard Henderson  <rth@redhat.com>
 
        * config/ia64/ia64.h (enum fetchop_code): Remove.
index 28f04d35904f6ea73b0d06c26ca895d877cc06ae..eed557ebda182297727e41ea92456597a07092e8 100644 (file)
@@ -1,3 +1,8 @@
+2005-04-14  Kazu Hirata  <kazu@cs.umass.edu>
+
+       PR tree-optimization/21021
+       * gcc.c-torture/compile/pr21021.c: New.
+
 2005-04-14  Janis Johnson  <janis187@us.ibm.com
 
        PR testsuite/21010
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr21021.c b/gcc/testsuite/gcc.c-torture/compile/pr21021.c
new file mode 100644 (file)
index 0000000..b748216
--- /dev/null
@@ -0,0 +1,19 @@
+/* PR tree-optimization/21021
+
+   The front end produces a comparison of mismatched types, namely an
+   integer and a pointer, causing VRP to compute TYPE_MAX_VALUE for a
+   pointer, which we cannot.  */
+
+extern void *bar (void);
+
+int
+foo (unsigned int *p, unsigned int *q)
+{
+  const void *r = bar ();
+
+  if (r >= (const void *) *p
+      && r < (const void *) *q)
+    return 1;
+
+  return 0;
+}
index 014f1956926ea4457163b72eb449bb8376c1ee0a..41cf6e1806b226b86430aad2bf6f73048a86d2ec 100644 (file)
@@ -287,7 +287,13 @@ compare_values (tree val1, tree val2)
     return 0;
 
   /* Do some limited symbolic comparisons.  */
-  if (!POINTER_TYPE_P (TREE_TYPE (val1)))
+  /* FIXME: The second check of POINTER_TYPE_P should not be necessary
+     because we should be comparing values of the same type here, but
+     for whatever reason, the front end throws us a type mismatched
+     comparison.  For now, work around the problem by checking both
+     types.  See PR 21021 and PR 21024.  */
+  if (!POINTER_TYPE_P (TREE_TYPE (val1))
+      && !POINTER_TYPE_P (TREE_TYPE (val2)))
     {
       /* We can determine some comparisons against +INF and -INF even
         if the other value is an expression.  */
@@ -400,7 +406,13 @@ compare_values (tree val1, tree val2)
   if (!is_gimple_min_invariant (val1) || !is_gimple_min_invariant (val2))
     return -2;
 
-  if (!POINTER_TYPE_P (TREE_TYPE (val1)))
+  /* FIXME: The second check of POINTER_TYPE_P should not be necessary
+     because we should be comparing values of the same type here, but
+     for whatever reason, the front end throws us a type mismatched
+     comparison.  For now, work around the problem by checking both
+     types.  See PR 21021 and PR 21024.  */
+  if (!POINTER_TYPE_P (TREE_TYPE (val1))
+      && !POINTER_TYPE_P (TREE_TYPE (val2)))
     return tree_int_cst_compare (val1, val2);
   else
     {