re PR rtl-optimization/83985 (Compile time hog for 32-bit BE powerpc targets)
authorJakub Jelinek <jakub@redhat.com>
Fri, 26 Jan 2018 11:48:05 +0000 (12:48 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 26 Jan 2018 11:48:05 +0000 (12:48 +0100)
PR rtl-optimization/83985
* dce.c (deletable_insn_p): Return false for separate shrink wrapping
REG_CFA_RESTORE insns.
(delete_unmarked_insns): Don't ignore separate shrink wrapping
REG_CFA_RESTORE insns here.

* gcc.dg/pr83985.c: New test.

From-SVN: r257087

gcc/ChangeLog
gcc/dce.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr83985.c [new file with mode: 0644]

index 32fb7baf5912fc764d70c792b458e885d5c9ed2b..764368ae20accd01b670a824bd295baaa8a4fa00 100644 (file)
@@ -1,5 +1,11 @@
 2018-01-26  Jakub Jelinek  <jakub@redhat.com>
 
+       PR rtl-optimization/83985
+       * dce.c (deletable_insn_p): Return false for separate shrink wrapping
+       REG_CFA_RESTORE insns.
+       (delete_unmarked_insns): Don't ignore separate shrink wrapping
+       REG_CFA_RESTORE insns here.
+
        PR c/83989
        * gimple-ssa-warn-restrict.c (builtin_memref::builtin_memref): Don't
        use SSA_NAME_VAR as base for SSA_NAMEs with non-NULL SSA_NAME_VAR.
index 590b6874e53d4f9b456e38a8c53dbdd622388f75..e00d029db651dc719f9989855c513ec2ac5c8130 100644 (file)
--- a/gcc/dce.c
+++ b/gcc/dce.c
@@ -131,6 +131,12 @@ deletable_insn_p (rtx_insn *insn, bool fast, bitmap arg_stores)
             && REGNO (pic_offset_table_rtx) >= FIRST_PSEUDO_REGISTER)
       return false;
 
+  /* Callee-save restores are needed.  */
+  if (RTX_FRAME_RELATED_P (insn)
+      && crtl->shrink_wrapped_separate
+      && find_reg_note (insn, REG_CFA_RESTORE, NULL))
+    return false;
+
   body = PATTERN (insn);
   switch (GET_CODE (body))
     {
@@ -592,15 +598,6 @@ delete_unmarked_insns (void)
          if (!dbg_cnt (dce))
            continue;
 
-         if (crtl->shrink_wrapped_separate
-             && find_reg_note (insn, REG_CFA_RESTORE, NULL))
-           {
-             if (dump_file)
-               fprintf (dump_file, "DCE: NOT deleting insn %d, it's a "
-                                   "callee-save restore\n", INSN_UID (insn));
-             continue;
-           }
-
          if (dump_file)
            fprintf (dump_file, "DCE: Deleting insn %d\n", INSN_UID (insn));
 
index c484d5b7ffeee28c38d9a1c497cd62da46df6bc0..5fa94c88af95b87554114b609c8a62feda307e88 100644 (file)
@@ -1,5 +1,8 @@
 2018-01-26  Jakub Jelinek  <jakub@redhat.com>
 
+       PR rtl-optimization/83985
+       * gcc.dg/pr83985.c: New test.
+
        PR c/83989
        * c-c++-common/Wrestrict-3.c: New test.
 
diff --git a/gcc/testsuite/gcc.dg/pr83985.c b/gcc/testsuite/gcc.dg/pr83985.c
new file mode 100644 (file)
index 0000000..51cfc49
--- /dev/null
@@ -0,0 +1,25 @@
+/* PR rtl-optimization/83985 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-additional-options "-mcpu=e300c3 -mtune=e300c3" { target { powerpc*-*-* && ilp32 } } } */
+
+long long int v;
+
+void
+foo (int x)
+{
+  if (x == 0)
+    return;
+
+  while (v < 2)
+    {
+      signed char *a;
+      v /= x;
+      a = v == 0 ? (signed char *) &x : (signed char *) &v;
+      ++*a;
+      ++v;
+    }
+
+  while (1)
+    ;
+}