re PR tree-optimization/67955 (tree-dse does not use pointer info)
authorJeff Law <law@redhat.com>
Wed, 4 Jan 2017 19:22:44 +0000 (12:22 -0700)
committerJeff Law <law@gcc.gnu.org>
Wed, 4 Jan 2017 19:22:44 +0000 (12:22 -0700)
PR tree-optimizatin/67955
* tree-ssa-alias.c (same_addr_size_stores_p): Check offsets first.
Allow any SSA_VAR_P as the base objects.  Use integer_zerop.  Verify
the points-to solution does not include pt_null.  Use DECL_PT_UID
unconditionally.

PR tree-optimization/67955
* gcc.dg/tree-ssa/ssa-dse-28.c: New test.

From-SVN: r244067

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-28.c [new file with mode: 0644]
gcc/tree-ssa-alias.c

index d43c9bcc5a0935f2b9fda2e0f4dc98b5facc895a..3a7ad9d5ffdf0036c8fd93ed2b38e6d9655c74ef 100644 (file)
@@ -1,3 +1,11 @@
+2017-01-04  Jeff Law  <law@redhat.com>
+
+       PR tree-optimizatin/67955
+       * tree-ssa-alias.c (same_addr_size_stores_p): Check offsets first.
+       Allow any SSA_VAR_P as the base objects.  Use integer_zerop.  Verify
+       the points-to solution does not include pt_null.  Use DECL_PT_UID
+       unconditionally.
+
 2017-01-04  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/i386/i386.md (HI/SImode test with imm to QImode splitters):
index d8ff32fb05e52ac1c0b73c79c84d1d00456cf631..0cbc8ccda8d63cbe66e843d77ad6b813bdfeec2c 100644 (file)
@@ -1,3 +1,8 @@
+2017-01-03  Jeff Law  <law@redhat.com>
+
+       PR tree-optimization/67955
+       * gcc.dg/tree-ssa/ssa-dse-28.c: New test.
+
 2017-01-04  Marek Polacek  <polacek@redhat.com>
 
        PR c++/77545
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-28.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-28.c
new file mode 100644 (file)
index 0000000..d35377b
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-dse-details -fexceptions -fnon-call-exceptions -fno-isolate-erroneous-paths-dereference" } */
+
+
+int foo (int *p, int b)
+{
+  int *q;
+  int i = 1;
+  if (b)
+    q = &i;
+  else
+    q = (void *)0;
+  *q = 2;
+  return i;
+}
+
+/* { dg-final { scan-tree-dump-not "Deleted dead store" "dse1"} } */
+/* { dg-final { scan-tree-dump-not "Deleted dead store" "dse2"} } */
+/* { dg-final { scan-tree-dump-not "Deleted dead store" "dse3"} } */
+
index 0a9fc742f9d3892cba20ef161bfa5aa1e1eaa4f3..871fa121fd07734dbca4ae31a48a26dfa7716a98 100644 (file)
@@ -2326,9 +2326,13 @@ same_addr_size_stores_p (tree base1, HOST_WIDE_INT offset1, HOST_WIDE_INT size1,
                         tree base2, HOST_WIDE_INT offset2, HOST_WIDE_INT size2,
                         HOST_WIDE_INT max_size2)
 {
-  /* For now, just handle VAR_DECL.  */
-  bool base1_obj_p = VAR_P (base1);
-  bool base2_obj_p = VAR_P (base2);
+  /* Offsets need to be 0.  */
+  if (offset1 != 0
+      || offset2 != 0)
+    return false;
+
+  bool base1_obj_p = SSA_VAR_P (base1);
+  bool base2_obj_p = SSA_VAR_P (base2);
 
   /* We need one object.  */
   if (base1_obj_p == base2_obj_p)
@@ -2356,13 +2360,9 @@ same_addr_size_stores_p (tree base1, HOST_WIDE_INT offset1, HOST_WIDE_INT size1,
   if (size1 != size2)
     return false;
 
-  /* Offsets need to be 0.  */
-  if (offset1 != 0
-      || offset2 != 0)
-    return false;
 
   /* Check that memref is a store to pointer with singleton points-to info.  */
-  if (!tree_int_cst_equal (TREE_OPERAND (memref, 1), integer_zero_node))
+  if (!integer_zerop (TREE_OPERAND (memref, 1)))
     return false;
   tree ptr = TREE_OPERAND (memref, 0);
   if (TREE_CODE (ptr) != SSA_NAME)
@@ -2373,10 +2373,13 @@ same_addr_size_stores_p (tree base1, HOST_WIDE_INT offset1, HOST_WIDE_INT size1,
       || !pt_solution_singleton_or_null_p (&pi->pt, &pt_uid))
     return false;
 
+  /* If the solution has a singleton and NULL, then we can not
+     be sure that the two stores hit the same address.  */
+  if (pi->pt.null)
+    return false;
+
   /* Check that ptr points relative to obj.  */
-  unsigned int obj_uid = (DECL_PT_UID_SET_P (obj)
-                         ? DECL_PT_UID (obj)
-                         : DECL_UID (obj));
+  unsigned int obj_uid = DECL_PT_UID (obj);
   if (obj_uid != pt_uid)
     return false;