tree-vrp.c (identify_jump_threads): Slightly simplify type check for operands of...
authorJeff Law <law@redhat.com>
Wed, 16 Mar 2011 17:32:58 +0000 (11:32 -0600)
committerJeff Law <law@gcc.gnu.org>
Wed, 16 Mar 2011 17:32:58 +0000 (11:32 -0600)
  * tree-vrp.c (identify_jump_threads): Slightly simplify type
  check for operands of conditional.  Allow type to be a
  pointer.

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

From-SVN: r171055

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

index c19efcb5d9fdffff924a4d0d54aa052b98c003cf..faf65fc4eb98c904c281a6048e55966a7076dc59 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 649dc4c61f8b96e1cb2d93c6cabe333c212c7560..72f30d8215a944be05ea8de1c0c717cf60c261c7 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 65d249f9ae2f930d8f7865ae5b07da604ca88c54..d2e6551d9928d260f0a453cc58622ef934f69ebd 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;