OSDN Git Service

* tree-vrp.c (identify_jump_threads): Slightly simplify type
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 16 Mar 2011 17:32:58 +0000 (17:32 +0000)
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 16 Mar 2011 17:32:58 +0000 (17:32 +0000)
  check for operands of conditional.  Allow type to be a
  pointer.

  * gcc.dg/tree-ssa/vrp55.c: New test.

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/vrp55.c [new file with mode: 0644]
gcc/tree-vrp.c

index c19efcb..faf65fc 100644 (file)
@@ -1,3 +1,9 @@
+2011-03-16  Jeff Law  <law@redhat.com>
+
+       * tree-vrp.c (identify_jump_threads): Slightly simplify type
+       check for operands of conditional.  Allow type to be a
+       pointer.
+
 2011-03-16  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/48149
index 649dc4c..72f30d8 100644 (file)
@@ -1,3 +1,7 @@
+2011-03-16  Jeff Law <law@redhat.com>
+
+       * gcc.dg/tree-ssa/vrp55.c: New test.
+
 2011-03-16  Jason Merrill  <jason@redhat.com>
 
        * g++.dg/cpp0x/auto22.C: New.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp55.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp55.c
new file mode 100644 (file)
index 0000000..7adfe62
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-vrp1-blocks-vops-details" } */
+
+fu (char *p, int x)
+{
+  if (x)
+   *p = 69;
+  if (p)
+    arf ();
+}
+
+/* { dg-final { scan-tree-dump-times "Threaded jump" 1 "vrp1" } } */
+/* { dg-final { cleanup-tree-dump "vrp1" } } */
+
index 65d249f..d2e6551 100644 (file)
@@ -7538,12 +7538,14 @@ identify_jump_threads (void)
        continue;
 
       /* We're basically looking for any kind of conditional with
-        integral type arguments.  */
+        integral or pointer type arguments.  Note the type of the second
+        argument will be the same as the first argument, so no need to
+        check it explicitly.  */
       if (TREE_CODE (gimple_cond_lhs (last)) == SSA_NAME
-         && INTEGRAL_TYPE_P (TREE_TYPE (gimple_cond_lhs (last)))
+         && (INTEGRAL_TYPE_P (TREE_TYPE (gimple_cond_lhs (last)))
+             || POINTER_TYPE_P (TREE_TYPE (gimple_cond_lhs (last))))
          && (TREE_CODE (gimple_cond_rhs (last)) == SSA_NAME
-             || is_gimple_min_invariant (gimple_cond_rhs (last)))
-         && INTEGRAL_TYPE_P (TREE_TYPE (gimple_cond_rhs (last))))
+             || is_gimple_min_invariant (gimple_cond_rhs (last))))
        {
          edge_iterator ei;