public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Martin Jambor <mjambor@suse.cz>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>, Jan Hubicka <jh@suse.cz>,
	Jan Hubicka <hubicka@ucw.cz>
Subject: Re: [PATCH] ipa: Avoid IPA confusing scalar values and single-field aggregates (PR 108679)
Date: Tue, 14 Feb 2023 16:08:15 +0100	[thread overview]
Message-ID: <CAFiYyc2ZRyuyfgEfMj2vHqe=5jmyg-k89SRL8AyShYPw9xTDvA@mail.gmail.com> (raw)
In-Reply-To: <ri6y1p0gv37.fsf@suse.cz>

On Tue, Feb 14, 2023 at 3:50 PM Martin Jambor <mjambor@suse.cz> wrote:
>
> Hi,
>
> PR 108679 testcase shows a situation when IPA-CP is able to track a
> scalar constant in a single-field structure that is part of a bigger
> structure.  This smaller struture is however also passed in a few calls
> to other functions, but the two same-but-different entities, originally
> places at the same offset and with the same size, and this confuses the
> mechanism that takes care of handling call statements after IPA-SRA.
>
> I think that in stage 4 it is best to revert to GCC 12 behavior in this
> particular case (when IPA-CP detects a constant in a single-field
> structure or a single element array that is part of a bigger aggregate)
> and the patch below does that.  If accepted, I plan to file a
> missed-optimization bug to track that we could use the IPA-CP propagated
> value to re-construct the small aggregate arguments.
>
> Bootstrapped and tested and LTO bootstrapped on x86_64-linux.  OK for
> master?

OK.

Richard.

> Thanks,
>
> Martin
>
>
>
>
> gcc/ChangeLog:
>
> 2023-02-13  Martin Jambor  <mjambor@suse.cz>
>
>         PR ipa/108679
>         * ipa-sra.cc (push_param_adjustments_for_index): Do not omit
>         creation of non-scalar replacements even if IPA-CP knows their
>         contents.
>
> gcc/testsuite/ChangeLog:
>
> 2023-02-13  Martin Jambor  <mjambor@suse.cz>
>
>         PR ipa/108679
>         * gcc.dg/ipa/pr108679.c: New test.
> ---
>  gcc/ipa-sra.cc                      |  2 +-
>  gcc/testsuite/gcc.dg/ipa/pr108679.c | 25 +++++++++++++++++++++++++
>  2 files changed, 26 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/gcc.dg/ipa/pr108679.c
>
> diff --git a/gcc/ipa-sra.cc b/gcc/ipa-sra.cc
> index 0495f446bf4..3de7d426b7e 100644
> --- a/gcc/ipa-sra.cc
> +++ b/gcc/ipa-sra.cc
> @@ -3989,7 +3989,7 @@ push_param_adjustments_for_index (isra_func_summary *ifs, unsigned base_index,
>         {
>           ipa_argagg_value_list avl (ipcp_ts);
>           tree value = avl.get_value (base_index, pa->unit_offset);
> -         if (value)
> +         if (value && !AGGREGATE_TYPE_P (pa->type))
>             {
>               if (dump_file)
>                 fprintf (dump_file, "    - omitting component at byte "
> diff --git a/gcc/testsuite/gcc.dg/ipa/pr108679.c b/gcc/testsuite/gcc.dg/ipa/pr108679.c
> new file mode 100644
> index 00000000000..b1ed50bb831
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/ipa/pr108679.c
> @@ -0,0 +1,25 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2" } */
> +
> +struct S1 {
> +  signed f0;
> +};
> +struct S2 {
> +  struct S1 f2;
> +  short f8;
> +} g_18;
> +void safe_lshift_func_int16_t_s_u();
> +void safe_unary_minus_func_uint64_t_u();
> +int safe_mul_func_uint8_t_u_u(int, struct S1 p_14);
> +int g_732, func_6_l_17;
> +static int *func_12();
> +static int func_6(struct S2 p_7) { func_12(func_6_l_17, p_7.f2, g_18, 0); }
> +static int *func_12(int, struct S1 p_14) {
> +  safe_lshift_func_int16_t_s_u();
> +  safe_unary_minus_func_uint64_t_u();
> +  g_732 = safe_mul_func_uint8_t_u_u(0, p_14);
> +}
> +int main() {
> +  struct S2 l_10 = {3};
> +  func_6(l_10);
> +}
> --
> 2.39.1
>

      reply	other threads:[~2023-02-14 15:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-14 14:50 Martin Jambor
2023-02-14 15:08 ` Richard Biener [this message]

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='CAFiYyc2ZRyuyfgEfMj2vHqe=5jmyg-k89SRL8AyShYPw9xTDvA@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=jh@suse.cz \
    --cc=mjambor@suse.cz \
    /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).