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 0092be861e84f16aa89d755b1baf2366f58962b7..b4ce1a73031567a060e64dabf4b8d427edbe8ede 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 56f1c8dbd406a6344f31616689975ebf96debb04..e41e168efade517c0df94224bae43bba2fff301d 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 7a08be7b2aa8340b71e4ac89bfb1fe14a9b9892e..46bbd823bfcbda77aefc9750e58af87d4088b0c1 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.  */