From: Jakub Jelinek <jakub@redhat.com>
To: Tamar Christina <Tamar.Christina@arm.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
nd <nd@arm.com>, "jwakely@redhat.com" <jwakely@redhat.com>
Subject: Re: [PATCH]middle-end: Recursively check is_trivially_copyable_or_pair in vec.h
Date: Thu, 5 Oct 2023 16:14:33 +0200 [thread overview]
Message-ID: <ZR7EyesA9dBfVMsx@tucnak> (raw)
In-Reply-To: <VI1PR08MB5325BD3DAFB0F28953E7201FFFCAA@VI1PR08MB5325.eurprd08.prod.outlook.com>
On Thu, Oct 05, 2023 at 02:01:40PM +0000, Tamar Christina wrote:
> gcc/ChangeLog:
>
> * tree-if-conv.cc (INCLUDE_ALGORITHM): Remove.
> (typedef struct ifcvt_arg_entry): New.
> (cmp_arg_entry): New.
> (gen_phi_arg_condition, gen_phi_nest_statement,
> predicate_scalar_phi): Use them.
> - /* Compute phi_arg_map. */
> + /* Compute phi_arg_map, determine the list of unique PHI args and the indices
> + where they are in the PHI node. The indices will be used to determine
> + the conditions to apply and their complexity. */
> + auto_vec<tree> unique_args (num_args);
> for (i = 0; i < num_args; i++)
> {
> tree arg;
>
> arg = gimple_phi_arg_def (phi, i);
> if (!phi_arg_map.get (arg))
> - args.quick_push (arg);
> + unique_args.quick_push (arg);
> phi_arg_map.get_or_insert (arg).safe_push (i);
> }
I meant instead of using another vector (unique_args) just do
args.quick_push ({ arg, 0, 0, NULL });
above (to avoid needing another allocation etc.).
> - /* Determine element with max number of occurrences and complexity. Looking at only
> - number of occurrences as a measure for complexity isn't enough as all usages can
> - be unique but the comparisons to reach the PHI node differ per branch. */
> - typedef std::pair <tree, std::pair <unsigned, unsigned>> ArgEntry;
> - auto_vec<ArgEntry> argsKV;
> - for (i = 0; i < args.length (); i++)
> + /* Determine element with max number of occurrences and complexity. Looking
> + at only number of occurrences as a measure for complexity isn't enough as
> + all usages can be unique but the comparisons to reach the PHI node differ
> + per branch. */
> + for (auto arg : unique_args)
And then
for (auto &entry : args)
here with entry.arg instead of arg and
> {
> unsigned int len = 0;
> - for (int index : phi_arg_map.get (args[i]))
> + vec<int> *indices = phi_arg_map.get (arg);
> + for (int index : *indices)
> {
> edge e = gimple_phi_arg_edge (phi, index);
> len += get_bb_num_predicate_stmts (e->src);
> }
>
> - unsigned occur = phi_arg_map.get (args[i])->length ();
> + unsigned occur = indices->length ();
> if (dump_file && (dump_flags & TDF_DETAILS))
> fprintf (dump_file, "Ranking %d as len=%d, idx=%d\n", i, len, occur);
> - argsKV.safe_push ({ args[i], { len, occur }});
> + args.safe_push ({ arg, len, occur, indices });
either
entry.num_compares = len;
entry.occur = occur;
entry.indices = indices;
here or just using entry.{num_occurrences,occur,indices} directly
instead of the extra automatic vars.
> }
>
> + unique_args.release ();
Plus drop this.
Though, if Richi or Jeff think this is ok as is, I won't stand against it.
Jakub
next prev parent reply other threads:[~2023-10-05 14:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-02 12:38 Tamar Christina
2023-10-02 13:21 ` Jakub Jelinek
2023-10-02 13:28 ` Tamar Christina
2023-10-03 10:27 ` Tamar Christina
2023-10-03 11:01 ` Jakub Jelinek
2023-10-03 11:41 ` Tamar Christina
2023-10-03 11:52 ` Jakub Jelinek
2023-10-05 14:01 ` Tamar Christina
2023-10-05 14:14 ` Jakub Jelinek [this message]
2023-10-06 2:23 ` Tamar Christina
2023-10-06 6:38 ` Jakub Jelinek
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=ZR7EyesA9dBfVMsx@tucnak \
--to=jakub@redhat.com \
--cc=Tamar.Christina@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jwakely@redhat.com \
--cc=nd@arm.com \
/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).