Handle POINTER_TYPE_P in EVRP
authorKugan Vivekanandarajah <kuganv@linaro.org>
Thu, 6 Oct 2016 19:55:14 +0000 (19:55 +0000)
committerKugan Vivekanandarajah <kugan@gcc.gnu.org>
Thu, 6 Oct 2016 19:55:14 +0000 (19:55 +0000)
Handle POINTER_TYPE_P in EVRP
gcc/ChangeLog:

2016-10-06  Kugan Vivekanandarajah  <kuganv@linaro.org>

* tree-vrp.c (evrp_dom_walker::before_dom_children): Handle
  POINTER_TYPE_P.

gcc/testsuite/ChangeLog:

2016-10-06  Kugan Vivekanandarajah  <kuganv@linaro.org>

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

From-SVN: r240841

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

index 0092be8..b4ce1a7 100644 (file)
@@ -1,3 +1,8 @@
+2016-10-06  Kugan Vivekanandarajah  <kuganv@linaro.org>
+
+       * tree-vrp.c (evrp_dom_walker::before_dom_children): Handle
+         POINTER_TYPE_P.
+
 2016-10-05  Jeff Law  <law@redhat.com>
 
        PR tree-optimization/71661
index 56f1c8d..e41e168 100644 (file)
@@ -1,3 +1,7 @@
+2016-10-06  Kugan Vivekanandarajah  <kuganv@linaro.org>
+
+       * gcc.dg/tree-ssa/evrp4.c: New test.
+
 2016-10-06  Jeff Law  <law@redhat.com>
 
        PR tree-optimization/71661
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/evrp4.c b/gcc/testsuite/gcc.dg/tree-ssa/evrp4.c
new file mode 100644 (file)
index 0000000..ebb87ed
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-evrp" } */
+
+int foo (int *p);
+
+struct st
+{
+  int a;
+  int b;
+};
+
+int bar (struct st *s)
+{
+
+  if (!s)
+    return 0;
+  foo (&s->a);
+}
+
+/* { dg-final { scan-tree-dump "\~\\\[0B, 0B\\\]" "evrp" } } */
index 7a08be7..46bbd82 100644 (file)
@@ -10666,7 +10666,8 @@ evrp_dom_walker::before_dom_children (basic_block bb)
          && gimple_code (stmt) == GIMPLE_COND
          && (op0 = gimple_cond_lhs (stmt))
          && TREE_CODE (op0) == SSA_NAME
-         && INTEGRAL_TYPE_P (TREE_TYPE (gimple_cond_lhs (stmt))))
+         && (INTEGRAL_TYPE_P (TREE_TYPE (gimple_cond_lhs (stmt)))
+             || POINTER_TYPE_P (TREE_TYPE (gimple_cond_lhs (stmt)))))
        {
          /* Entering a new scope.  Try to see if we can find a VR
             here.  */