PR tree-optimization/57331
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 21 May 2013 15:17:31 +0000 (15:17 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 21 May 2013 15:17:31 +0000 (15:17 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@199148 138bc75d-0d04-0410-961f-82ee72b054a4

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

index ffd389e..0199bd5 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 1ba9007..77b02f5 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 b5de683..66c50ca 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);