public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "stefansf at linux dot ibm.com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/113994] [13/14 Regression] Probable C++ code generation bug with -O2 on s390x platform
Date: Thu, 29 Feb 2024 10:17:24 +0000	[thread overview]
Message-ID: <bug-113994-4-fVEUnymHEG@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113994-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #6 from Stefan Schulze Frielinghaus <stefansf at linux dot ibm.com> ---
Looks like wrong liveness information.  The problem is that df_analyze_loop
only considers basic blocks which strictly belong to a loop which is not
enough.  During loop2_doloop basic block 9 (previously 8) embodies the CC
consumer jump_insn 42 and is not part of the loop and therefore does not
contribute to the liveness analysis.  A quick and dirty experiment by forcing a
merge with BB 9

diff --git a/gcc/df-core.cc b/gcc/df-core.cc
index f0eb4c93957..79f37e22ec1 100644
--- a/gcc/df-core.cc
+++ b/gcc/df-core.cc
@@ -957,9 +957,11 @@ df_worklist_propagate_backward (struct dataflow *dataflow,
   if (EDGE_COUNT (bb->succs) > 0)
     FOR_EACH_EDGE (e, ei, bb->succs)
       {
-       if (bbindex_to_postorder[e->dest->index] < last_change_age.length ()
+       if ((bbindex_to_postorder[e->dest->index] < last_change_age.length ()
            && age <= last_change_age[bbindex_to_postorder[e->dest->index]]
            && bitmap_bit_p (considered, e->dest->index))
+           || (strcmp ("loop2_doloop", current_pass->name) == 0
+               && e->src->index == 6 && e->dest->index == 9))
           changed |= dataflow->problem->con_fun_n (e);
       }
   else if (dataflow->problem->con_fun_0)

shows that, now, CC is live at BB 6 and therefore doloop performs no
transformation due to

bool fail = bitmap_intersect_p (df_get_live_out (loop_end), modified);
BITMAP_FREE (modified);

if (fail)
  {
    if (dump_file)
      fprintf (dump_file, "Doloop: doloop pattern clobbers live out\n");
    return false;
  }

In a first try I enlarged the set of basic blocks for which df_analyze_loop is
run to also include basic blocks which have a direct edge originating from a
basic block of a loop.  Of course, this solves this problem.  However, in
general this may not be enough.  I'm wondering what the IL allows.  Is it
possible to have a graph containing not only outgoing edges of a loop but also
ingoing?  If so I think we would need to compute the set of basic blocks which
are reachable from within the loop.  Any thoughts?

  parent reply	other threads:[~2024-02-29 10:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-19 15:01 [Bug c++/113994] New: " thierry at lelegard dot fr
2024-02-19 23:46 ` [Bug target/113994] " xry111 at gcc dot gnu.org
2024-02-19 23:57 ` jakub at gcc dot gnu.org
2024-02-20  8:08 ` rguenth at gcc dot gnu.org
2024-02-21 10:37 ` jakub at gcc dot gnu.org
2024-02-21 11:00 ` [Bug target/113994] [13/14 Regression] " jakub at gcc dot gnu.org
2024-02-21 12:25 ` jakub at gcc dot gnu.org
2024-02-29 10:17 ` stefansf at linux dot ibm.com [this message]
2024-02-29 10:23 ` jakub at gcc dot gnu.org
2024-02-29 12:00 ` rguenth at gcc dot gnu.org
2024-02-29 12:02 ` rguenth at gcc dot gnu.org
2024-02-29 12:04 ` jakub at gcc dot gnu.org
2024-02-29 12:59 ` rguenth at gcc dot gnu.org
2024-05-21  9:19 ` [Bug target/113994] [13/14/15 " jakub 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-113994-4-fVEUnymHEG@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).