public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "luoxhu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug testsuite/103270] [12 regression] gcc.dg/vect/pr96698.c inner loop turned from hot to cold after r12-4526
Date: Wed, 17 Nov 2021 01:54:36 +0000	[thread overview]
Message-ID: <bug-103270-4-CsFngtLFLt@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-103270-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from luoxhu at gcc dot gnu.org ---
(In reply to Richard Biener from comment #1)
> So you say this is a problem with loop header copying, that would mean the
> issue is really latent and general, no?  Header copying uses
> gimple_duplicate_sese_region and has no own profile updating.  I guess its
> profile updating code isn't designed to cope with copying a region with
> "side"-entries (we are ignoring the backedge here).  Not sure if we can
> somehow generally handle those (maybe we can learn from tracer or threader
> here).
> 
> Honza?

Yes, it seems to be a general issue in gimple_duplicate_sese_region, the inner
loop cfg was:

8
|
3<-- 
| \ |
5  4  

And it is modified by ch_base::copy_headers->gimple_duplicate_sese_region to(
entry edge is 8->3, exit edge is 3->4):

8
|
12
|
4<-- 
|   |
3---
|
5

bb 12 is copied block from bb 3 as new preheader, bb 3 is rotated to be new
exit of the loop, bb 3 and bb 12 are adjusted count to "total_count -
entry_count" (354334800) and "entry_count"(719407024), at last bb 3 and bb 4
will be merged to one block by gimple_merge_blocks later by TODO_cleanup_cfg
with much smaller
count than preheader.


gimple_duplicate_sese_region:

  if (total_count.initialized_p () && entry_count.initialized_p ())
    {
      scale_bbs_frequencies_profile_count (region, n_region,
                                           total_count - entry_count,
                                           total_count);
      scale_bbs_frequencies_profile_count (region_copy, n_region, entry_count,
                                           total_count);
    }


Obviously, region of bb 3's profile count shouldn't be decreased from
"total_count" to "total_count - entry_count", it executes at every execution of
the loop.  Simply adjust it back to total_count and region_copy to entry_count
will cause some other cases fail. And at the moment edge 3->4 is still not a
backedge now?

  parent reply	other threads:[~2021-11-17  1:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-16  7:41 [Bug testsuite/103270] New: " luoxhu at gcc dot gnu.org
2021-11-16  8:19 ` [Bug testsuite/103270] " rguenth at gcc dot gnu.org
2021-11-17  1:54 ` luoxhu at gcc dot gnu.org [this message]
2021-11-23  5:13 ` luoxhu at gcc dot gnu.org
2021-11-23  5:13 ` luoxhu at gcc dot gnu.org
2021-11-23  5:31 ` luoxhu at gcc dot gnu.org
2021-12-21  3:50 ` cvs-commit at gcc dot gnu.org
2021-12-22  2:49 ` luoxhu 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-103270-4-CsFngtLFLt@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).