From: Richard Biener <richard.guenther@gmail.com>
To: Alan Lawrence <alan.lawrence@arm.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>, jamborm@gcc.gnu.org
Subject: Re: [PATCH] Fix PR70013
Date: Fri, 11 Mar 2016 12:01:00 -0000 [thread overview]
Message-ID: <CAFiYyc23ABst8qJmdLbU7dOJn1GK=dYMshhBm-PYp4f2ZKR24w@mail.gmail.com> (raw)
In-Reply-To: <1457691258-25010-1-git-send-email-alan.lawrence@arm.com>
On Fri, Mar 11, 2016 at 11:14 AM, Alan Lawrence <alan.lawrence@arm.com> wrote:
> In this PR, a packed structure containing bitfields, loses part of its constant-pool initialization in SRA.
>
> A fuller explanation is on the PR:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70013#c11. In short we need to
> treat constant-pool entries, like function parameters, as both come
> 'pre-initialized' before the function starts.
>
> Bootstrapped + regtest (gcc, g++) on AArch64; same with addition of Ada, on ARM
> and x86.
>
> OK for trunk?
Ok.
Richard.
> gcc/ChangeLog:
>
> PR tree-optimization/70013
> * tree-sra.c (analyze_access_subtree): Also set grp_unscalarized_data
> for constant-pool entries.
>
> gcc/testsuite/ChangeLog:
>
> * gcc.dg/tree-ssa/sra-20.c: New.
> ---
> gcc/testsuite/gcc.dg/tree-ssa/sra-20.c | 20 ++++++++++++++++++++
> gcc/tree-sra.c | 3 ++-
> 2 files changed, 22 insertions(+), 1 deletion(-)
> create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/sra-20.c
>
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/sra-20.c b/gcc/testsuite/gcc.dg/tree-ssa/sra-20.c
> new file mode 100644
> index 0000000..5002c24
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/sra-20.c
> @@ -0,0 +1,20 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O1 -Wall" } */
> +/* PR/70013, SRA of constant-pool loads removes initialization of part of d. */
> +#pragma pack (1)
> +struct S0 {
> + unsigned f0 : 17;
> +};
> +
> +int c;
> +
> +int
> +main (int argc, char **argv)
> +{
> + struct S0 d[] = { { 1 }, { 2 } };
> + struct S0 e = d[1];
> +
> + c = d[0].f0;
> + __builtin_printf ("%x\n", e.f0);
> + return 0;
> +}
> diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
> index 72157ed..24eac6a 100644
> --- a/gcc/tree-sra.c
> +++ b/gcc/tree-sra.c
> @@ -2427,7 +2427,8 @@ analyze_access_subtree (struct access *root, struct access *parent,
>
> if (!hole || root->grp_total_scalarization)
> root->grp_covered = 1;
> - else if (root->grp_write || TREE_CODE (root->base) == PARM_DECL)
> + else if (root->grp_write || TREE_CODE (root->base) == PARM_DECL
> + || constant_decl_p (root->base))
> root->grp_unscalarized_data = 1; /* not covered and written to */
> return sth_created;
> }
> --
> 1.9.1
>
prev parent reply other threads:[~2016-03-11 12:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-11 10:14 Alan Lawrence
2016-03-11 12:01 ` 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='CAFiYyc23ABst8qJmdLbU7dOJn1GK=dYMshhBm-PYp4f2ZKR24w@mail.gmail.com' \
--to=richard.guenther@gmail.com \
--cc=alan.lawrence@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jamborm@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).