public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "amonakov at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/108519] [13 regression] gcc.target/powerpc/pr105586.c  fails after r13-5154-g733a1b777f16cd
Date: Wed, 25 Jan 2023 16:12:50 +0000	[thread overview]
Message-ID: <bug-108519-4-sEW6A2akYi@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108519-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108519

--- Comment #1 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
We diverge in sched1 due to extra calls to advance_one_cycle when scheduling a
BB that is empty apart from one debug insn. The following patch adds a hexdump
of automaton state to make the problem evident:

diff --git a/gcc/sched-rgn.cc b/gcc/sched-rgn.cc
index 420c45dff..c09398897 100644
--- a/gcc/sched-rgn.cc
+++ b/gcc/sched-rgn.cc
@@ -3098,8 +3098,14 @@ save_state_for_fallthru_edge (basic_block last_bb,
state_t state)
     memcpy (bb_state[f->dest->index], state,
            dfa_state_size);
     if (sched_verbose >= 5)
-      fprintf (sched_dump, "saving state for edge %d->%d\n",
-              f->src->index, f->dest->index);
+      {
+       fprintf (sched_dump, "saving state for edge %d->%d\n",
+                f->src->index, f->dest->index);
+       for (size_t i = 0; i < dfa_state_size; i++)
+         fprintf (sched_dump, "%02x%c", i[(unsigned char *)state],
+                  (i+1) % 16 ? ' ' : '\n');
+       fprintf(sched_dump, "\n---\n");
+      }
   }
 }

With the above patch it's obvious we advance the automaton state a few extra
times when scheduling BB 3, and then inherit the modified state to BB 4.

I think we don't need to schedule blocks that only contain debug insns. IBM
folks, care to test the following?

diff --git a/gcc/haifa-sched.cc b/gcc/haifa-sched.cc
index 4efaa9445..f00a92e26 100644
--- a/gcc/haifa-sched.cc
+++ b/gcc/haifa-sched.cc
@@ -5040,7 +5040,7 @@ no_real_insns_p (const rtx_insn *head, const rtx_insn
*tail)
 {
   while (head != NEXT_INSN (tail))
     {
-      if (!NOTE_P (head) && !LABEL_P (head))
+      if (!NOTE_P (head) && !LABEL_P (head) && !DEBUG_INSN_P (head))
        return 0;
       head = NEXT_INSN (head);
     }
diff --git a/gcc/sched-rgn.cc b/gcc/sched-rgn.cc
index 420c45dff..c09398897 100644
--- a/gcc/sched-rgn.cc
+++ b/gcc/sched-rgn.cc
@@ -2753,7 +2753,7 @@ free_block_dependencies (int bb)

   get_ebb_head_tail (EBB_FIRST_BB (bb), EBB_LAST_BB (bb), &head, &tail);

-  if (no_real_insns_p (head, tail))
+  if (0 && no_real_insns_p (head, tail))
     return;

   sched_free_deps (head, tail, true);

  parent reply	other threads:[~2023-01-25 16:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-24 15:16 [Bug other/108519] New: " seurer at gcc dot gnu.org
2023-01-24 15:18 ` [Bug rtl-optimization/108519] " rguenth at gcc dot gnu.org
2023-01-25 16:12 ` amonakov at gcc dot gnu.org [this message]
2023-01-26 19:21 ` seurer at gcc dot gnu.org
2023-01-26 20:28 ` amonakov at gcc dot gnu.org
2023-02-23  9:12 ` linkw at gcc dot gnu.org
2023-02-23  9:46 ` linkw at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-108519-4-sEW6A2akYi@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).