tree-vrp.c (find_assert_locations): Pre-seed live bitmaps for loop latches from heade...
authorJakub Jelinek <jakub@gcc.gnu.org>
Thu, 7 Nov 2013 14:28:57 +0000 (15:28 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 7 Nov 2013 14:28:57 +0000 (15:28 +0100)
* tree-vrp.c (find_assert_locations): Pre-seed live bitmaps for loop
latches from header PHI arguments from the latch edge.

        * gcc.dg/unroll_1.c: Add -fno-tree-vrp to dg-options.
        * gcc.dg/unroll_2.c: Likewise.
        * gcc.dg/unroll_3.c: Likewise.
        * gcc.dg/unroll_4.c: Likewise.
* gcc.dg/vrp90.c: New test.

From-SVN: r204515

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/vrp90.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/unroll_1.c
gcc/testsuite/gcc.dg/unroll_2.c
gcc/testsuite/gcc.dg/unroll_3.c
gcc/testsuite/gcc.dg/unroll_4.c
gcc/tree-vrp.c

index 5679435a343f003d78eab4f8f5d42c13af6bc674..2dbbfefa792111cc66966bb7ada7f863c27ea55b 100644 (file)
@@ -1,3 +1,9 @@
+2013-11-07  Richard Biener  <rguenther@suse.de>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       * tree-vrp.c (find_assert_locations): Pre-seed live bitmaps for loop
+       latches from header PHI arguments from the latch edge.
+
 2013-11-07  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/58176
index b45c8f4defc975170014e5890b63e753abdfb8c5..643d1569b376d088feb60ee79ff4c332df562c86 100644 (file)
@@ -1,3 +1,11 @@
+2013-11-07  Jakub Jelinek  <jakub@redhat.com>
+
+        * gcc.dg/unroll_1.c: Add -fno-tree-vrp to dg-options.
+        * gcc.dg/unroll_2.c: Likewise.
+        * gcc.dg/unroll_3.c: Likewise.
+        * gcc.dg/unroll_4.c: Likewise.
+       * gcc.dg/vrp90.c: New test.
+
 2013-11-07  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/58176
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp90.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp90.c
new file mode 100644 (file)
index 0000000..836c335
--- /dev/null
@@ -0,0 +1,36 @@
+/* { dg-do link } */
+/* { dg-options "-O2 -fdump-tree-vrp1" } */
+/* { dg-final { scan-tree-dump-not "link_error" "vrp1"} } */
+/* { dg-final { cleanup-tree-dump "vrp1" } } */
+
+extern void link_error (void);
+
+__attribute__((noinline, noclone)) int
+foo (unsigned int n, int r)
+{
+  int i;
+  if (n > 0)
+    {
+      asm ("");
+      if (n < 10)
+       {
+         asm ("");
+         do
+           {
+             --n;
+             r *= 2;
+             if (n >= 9)
+               link_error ();
+           }
+         while (n > 0);
+       }
+    }
+  return r + n;
+}
+
+int
+main ()
+{
+  foo (7, 2);
+  return 0;
+}
index 154c78e4bf9f30dc905043ea18527eb5542fec2b..378f819ed686f940ecb89d979d36bf75340d0d9e 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-rtl-loop2_unroll=stderr -fno-peel-loops -fdisable-tree-cunroll -fdisable-tree-cunrolli -fenable-rtl-loop2_unroll" } */
+/* { dg-options "-O2 -fdump-rtl-loop2_unroll=stderr -fno-peel-loops -fno-tree-vrp -fdisable-tree-cunroll -fdisable-tree-cunrolli -fenable-rtl-loop2_unroll" } */
 
 unsigned a[100], b[100];
 inline void bar()
index 601b38705c160bab20451f1667e1b895bb0d584a..2322a494012c0c92590456ac942d2b729168c278 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-rtl-loop2_unroll -fno-peel-loops -fdisable-tree-cunroll=foo -fdisable-tree-cunrolli=foo -fenable-rtl-loop2_unroll" } */
+/* { dg-options "-O2 -fdump-rtl-loop2_unroll -fno-peel-loops -fno-tree-vrp -fdisable-tree-cunroll=foo -fdisable-tree-cunrolli=foo -fenable-rtl-loop2_unroll" } */
 
 unsigned a[100], b[100];
 inline void bar()
index 1f4216b6068f51f8097e5272180af03865e0aa72..310bf064c977643e9c6c6049bde3e1faa27a5331 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-rtl-loop2_unroll -fno-peel-loops -fdisable-tree-cunroll -fdisable-tree-cunrolli -fenable-rtl-loop2_unroll=foo" } */
+/* { dg-options "-O2 -fdump-rtl-loop2_unroll -fno-peel-loops -fno-tree-vrp -fdisable-tree-cunroll -fdisable-tree-cunrolli -fenable-rtl-loop2_unroll=foo" } */
 
 unsigned a[100], b[100];
 inline void bar()
index 33d6edee2ccb63732b1a93d00adfa87a7e3bab47..fbffbb0d5f3f9eaf53dc412b6957cd2b04174622 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-rtl-loop2_unroll -fno-peel-loops -fdisable-tree-cunroll -fdisable-tree-cunrolli -fenable-rtl-loop2_unroll=foo2" } */
+/* { dg-options "-O2 -fdump-rtl-loop2_unroll -fno-peel-loops -fno-tree-vrp -fdisable-tree-cunroll -fdisable-tree-cunrolli -fenable-rtl-loop2_unroll=foo2" } */
 
 unsigned a[100], b[100];
 inline void bar()
index 9b26f17eb548c0cc44920ca1b1de1b40decafc91..c1ff4752cb040c3a40a60540b0c94a0e5987851a 100644 (file)
@@ -5904,6 +5904,34 @@ find_assert_locations (void)
   for (i = 0; i < rpo_cnt; ++i)
     bb_rpo[rpo[i]] = i;
 
+  /* Pre-seed loop latch liveness from loop header PHI nodes.  Due to
+     the order we compute liveness and insert asserts we otherwise
+     fail to insert asserts into the loop latch.  */
+  loop_p loop;
+  loop_iterator li;
+  FOR_EACH_LOOP (li, loop, 0)
+    {
+      i = loop->latch->index;
+      unsigned int j = single_succ_edge (loop->latch)->dest_idx;
+      for (gimple_stmt_iterator gsi = gsi_start_phis (loop->header);
+          !gsi_end_p (gsi); gsi_next (&gsi))
+       {
+         gimple phi = gsi_stmt (gsi);
+         if (virtual_operand_p (gimple_phi_result (phi)))
+           continue;
+         tree arg = gimple_phi_arg_def (phi, j);
+         if (TREE_CODE (arg) == SSA_NAME)
+           {
+             if (live[i] == NULL)
+               {
+                 live[i] = sbitmap_alloc (num_ssa_names);
+                 bitmap_clear (live[i]);
+               }
+             bitmap_set_bit (live[i], SSA_NAME_VERSION (arg));
+           }
+       }
+    }
+
   need_asserts = false;
   for (i = rpo_cnt - 1; i >= 0; --i)
     {