+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.
--- /dev/null
+/* 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;
+}
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. */
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
{