re PR tree-optimization/57331 (ICE: tree check: expected integer_type or enumeral_typ...
authorJakub Jelinek <jakub@redhat.com>
Tue, 21 May 2013 15:17:31 +0000 (17:17 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 21 May 2013 15:17:31 +0000 (17:17 +0200)
PR tree-optimization/57331
* tree-vrp.c (simplify_cond_using_ranges): Don't optimize
comparison of conversion from pointer type to integral type
with integer.

* gcc.c-torture/compile/pr57331.c: New test.

From-SVN: r199148

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

index ffd389e94797af82969dab03cddc753eea9005e3..0199bd5b199cf0077d0ff994ae2211435ebc91d6 100644 (file)
@@ -1,3 +1,10 @@
+2013-05-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/57331
+       * tree-vrp.c (simplify_cond_using_ranges): Don't optimize
+       comparison of conversion from pointer type to integral type
+       with integer.
+
 2013-05-21  Martin Jambor  <mjambor@suse.cz>
 
        PR lto/57289
index 1ba9007ac6c7c345c7b6d8a0465ce2803b8e2417..77b02f5843e460774f59c235f2dae98ea1aab5c6 100644 (file)
@@ -1,3 +1,8 @@
+2013-05-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/57331
+       * gcc.c-torture/compile/pr57331.c: New test.
+
 2013-05-21  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/57330
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr57331.c b/gcc/testsuite/gcc.c-torture/compile/pr57331.c
new file mode 100644 (file)
index 0000000..b30e1ad
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR tree-optimization/57331 */
+
+int
+foo (int x)
+{
+  void *p = x ? (void *) 1 : (void *) 0;
+  __INTPTR_TYPE__ b = (__INTPTR_TYPE__) p;
+  if (b)
+    return 0;
+  return 1;
+}
index b5de683961fa4baeb1b2a5bf5e8543c5029a9f07..66c50ca4b310d8b9284f0f9b33db87b2d625797c 100644 (file)
@@ -8661,7 +8661,8 @@ simplify_cond_using_ranges (gimple stmt)
 
       innerop = gimple_assign_rhs1 (def_stmt);
 
-      if (TREE_CODE (innerop) == SSA_NAME)
+      if (TREE_CODE (innerop) == SSA_NAME
+         && !POINTER_TYPE_P (TREE_TYPE (innerop)))
        {
          value_range_t *vr = get_value_range (innerop);