From: Richard Biener <richard.guenther@gmail.com>
To: Martin Jambor <mjambor@suse.cz>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [GCC 9 backport] cplxlower: Avoid a transform when looking at a default definition
Date: Wed, 30 Mar 2022 12:04:02 +0200 [thread overview]
Message-ID: <CAFiYyc2q8raXyjbu36r-_oJozrJv5Afis5bkkjETptBMARgzCQ@mail.gmail.com> (raw)
In-Reply-To: <ri6ee2jojhj.fsf@suse.cz>
On Wed, Mar 30, 2022 at 11:52 AM Martin Jambor <mjambor@suse.cz> wrote:
>
> Hi,
>
> I did not backport my fix of PR 97456 to GCC 9 and it re-surfaced there
> as PR 105071. I have cherry-picked the fix, pasted below, on top of the
> gcc 9 branch (the only change is an extra bug reference in the
> ChangeLog) and made sure it passes bootstrap and testing on
> x86_64-linux. Can I commit the backport to the branch?
OK
> I think the old testcase is sufficient and so did not add the new one.
>
> Thanks,
>
> Martin
>
>
>
>
> In PR 97456, IPA-SRA triggers a bug in tree-complex.c where it
> converts:
>
> <bb 2>
> a$_M_value_21 = COMPLEX_EXPR <ISRA.18_10(D), ISRA.18_10(D)>;
>
> (where ISRA.18 is IPA-SRA created PARM_DECL with DECL_IGNORED_P set,
> which is why it only happens with IPA-SRA) into:
>
> <bb 2>
> a$_M_value_21 = COMPLEX_EXPR <a$_M_value$real_10(D), a$_M_value$real_10(D)>;
>
> i.e. it replaces two uses of the parameter default-def with two
> uninitialized default-defs of a new variable - all in hope to produce
> code with better debug info.
>
> This patch fixes it by avoiding the transform when the SSA_NAME to be
> replaced is a default definition.
>
> gcc/ChangeLog:
>
> 2020-10-19 Martin Jambor <mjambor@suse.cz>
>
> PR tree-optimization/97456
> PR middle-end/105071
> * tree-complex.c (set_component_ssa_name): Do not replace ignored decl
> default definitions with new component vars. Reorder if conditions.
>
> gcc/testsuite/ChangeLog:
>
> 2020-10-19 Martin Jambor <mjambor@suse.cz>
>
> PR tree-optimization/97456
> * gcc.dg/tree-ssa/pr97456.c: New test.
>
> (cherry picked from commit 619f91eaa8c8a50f1f9d3e7b96ee837037f0e806)
> ---
> gcc/testsuite/gcc.dg/tree-ssa/pr97456.c | 40 +++++++++++++++++++++++++
> gcc/tree-complex.c | 3 +-
> 2 files changed, 42 insertions(+), 1 deletion(-)
> create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr97456.c
>
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr97456.c b/gcc/testsuite/gcc.dg/tree-ssa/pr97456.c
> new file mode 100644
> index 00000000000..5171c9b4577
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr97456.c
> @@ -0,0 +1,40 @@
> +/* { dg-do run } */
> +/* { dg-options "-O2 -fwhole-program" } */
> +
> +
> +float val2 = 1.710780f;
> +float val3;
> +volatile float vf;
> +
> +int __attribute__((noipa))
> +get_bool (void)
> +{
> + return 1;
> +}
> +
> +int __attribute__((noinline))
> +wrong (float *pos)
> +{
> + _Complex float a;
> +
> + __real__ a = *pos;
> + __imag__ a = *pos;
> +
> + _Complex float b = 0 + 0i;
> +
> + b = b + a;
> +
> + if (b == 0.0f)
> + return 1;
> +
> + vf = __imag__ b;
> + return 0;
> +}
> +
> +int main(int argc, char **argv) {
> + float val = get_bool () == 1 ? val2 : val3;
> +
> + if ((wrong(&val), wrong(&val)))
> + __builtin_abort ();
> + return 0;
> +}
> diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c
> index d4b053d68e1..36a4d6f06d5 100644
> --- a/gcc/tree-complex.c
> +++ b/gcc/tree-complex.c
> @@ -569,7 +569,8 @@ set_component_ssa_name (tree ssa_name, bool imag_p, tree value)
> {
> /* Replace an anonymous base value with the variable from cvc_lookup.
> This should result in better debug info. */
> - if (SSA_NAME_VAR (ssa_name)
> + if (!SSA_NAME_IS_DEFAULT_DEF (value)
> + && SSA_NAME_VAR (ssa_name)
> && (!SSA_NAME_VAR (value) || DECL_IGNORED_P (SSA_NAME_VAR (value)))
> && !DECL_IGNORED_P (SSA_NAME_VAR (ssa_name)))
> {
> --
> 2.35.1
>
prev parent reply other threads:[~2022-03-30 10:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-30 9:52 Martin Jambor
2022-03-30 10:04 ` 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=CAFiYyc2q8raXyjbu36r-_oJozrJv5Afis5bkkjETptBMARgzCQ@mail.gmail.com \
--to=richard.guenther@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--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).