public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@ucw.cz>
To: "Andre Vieira (lists)" <andre.simoesdiasvieira@arm.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: Check that passes do not forget to define profile
Date: Wed, 4 Oct 2023 13:02:18 +0200	[thread overview]
Message-ID: <ZR1GOnVP6Pi9m5hm@kam.mff.cuni.cz> (raw)
In-Reply-To: <101e48f0-6af5-96d4-8389-be04cdf4cf3c@arm.com>

> Hi Honza,
> 
> My current patch set for AArch64 VLA omp codegen started failing on
> gcc.dg/gomp/pr87898.c after this. I traced it back to
> 'move_sese_region_to_fn' in tree/cfg.cc not setting count for the bb
> created.
> 
> I was able to 'fix' it locally by setting the count of the new bb to the
> accumulation of e->count () of all the entry_endges (if initialized). I'm
> however not even close to certain that's the right approach, attached patch
> for illustration.
> 
> Kind regards,
> Andre
> diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc

> index ffab7518b1568b58e610e26feb9e3cab18ddb3c2..32fc47ae683164bf8fac477fbe6e2c998382e754 100644
> --- a/gcc/tree-cfg.cc
> +++ b/gcc/tree-cfg.cc
> @@ -8160,11 +8160,15 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
>    bb = create_empty_bb (entry_pred[0]);
>    if (current_loops)
>      add_bb_to_loop (bb, loop);
> +  profile_count count = profile_count::zero ();
>    for (i = 0; i < num_entry_edges; i++)
>      {
>        e = make_edge (entry_pred[i], bb, entry_flag[i]);
>        e->probability = entry_prob[i];
> +      if (e->count ().initialized_p ())
> +	count += e->count ();
>      }
> +  bb->count = count;

This looks generally right - if you create a BB you need to set its
count and unless it has self-loop that is the sum of counts of
incommping edges.

However the initialized_p check should be unnecessary: if one of entry
edges to BB is uninitialized, the + operation will make bb count
uninitialized too, which is OK.

Honza
>  
>    for (i = 0; i < num_exit_edges; i++)
>      {


  reply	other threads:[~2023-10-04 11:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-24 13:14 Jan Hubicka
2023-08-24 13:20 ` Richard Biener
2023-08-24 15:36   ` Jan Hubicka
2023-08-31  0:15 ` [EXTERNAL] " Eugene Rozenfeld
2023-09-05  7:16 ` [PATCH 16/12] _BitInt profile fixes [PR102989] Jakub Jelinek
2023-10-03 16:56 ` Check that passes do not forget to define profile Andre Vieira (lists)
2023-10-04 11:02   ` Jan Hubicka [this message]
2023-10-17 10:29     ` Andre Vieira (lists)
2023-10-17 13:52       ` Jan Hubicka

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=ZR1GOnVP6Pi9m5hm@kam.mff.cuni.cz \
    --to=hubicka@ucw.cz \
    --cc=andre.simoesdiasvieira@arm.com \
    --cc=gcc-patches@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).