* [PATCH] sra: Only verify sizes of scalar accesses (PR 93845)
@ 2020-02-21 11:53 Martin Jambor
2020-02-21 12:31 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Martin Jambor @ 2020-02-21 11:53 UTC (permalink / raw)
To: GCC Patches; +Cc: Richard Biener
Hi,
the testcase is another example - in addition to recent PR 93516 - where
the SRA access verifier is confused by the fact that get_ref_base_extent
can return different sizes for the same type, depending whether they are
COMPONENT_REF or not. In the previous bug I decided to keep the
verifier check for aggregate type even though it is not really important
and instead avoid easily detectable type-within-the-same-type situation.
This testcase is however a result of a fairly random looking type cast
and so cannot be handled in the same way.
Because the check is not really important for aggregates, this patch
simply disables it for non-register types.
Bootstrapped and tested on x86_64-linux. OK for trunk?
Thanks,
Martin
2020-02-20 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/93845
* tree-sra.c (verify_sra_access_forest): Only test access size of
scalar types.
testsuite/
* g++.dg/tree-ssa/pr93845.C: New test.
---
gcc/ChangeLog | 6 +++++
gcc/testsuite/ChangeLog | 5 +++++
gcc/testsuite/g++.dg/tree-ssa/pr93845.C | 30 +++++++++++++++++++++++++
gcc/tree-sra.c | 3 ++-
4 files changed, 43 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr93845.C
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr93845.C b/gcc/testsuite/g++.dg/tree-ssa/pr93845.C
new file mode 100644
index 00000000000..72e473fffcd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr93845.C
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+
+struct g;
+struct h {
+ g *operator->();
+};
+class i {
+ void *a;
+ int b;
+
+public:
+ template <typename f> f j() { return *static_cast<f *>(this); }
+};
+struct k : i {};
+struct l : k {};
+struct m {
+ i n();
+ i o(l, l, int);
+};
+struct g {
+ void m_fn4(k);
+};
+h a;
+i b;
+i m::n() {
+ l c, d, e = o(d, c, 0).j<l>();
+ a->m_fn4(e);
+ return b;
+}
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 0cfac0a8192..1439f11f15a 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -2339,7 +2339,8 @@ verify_sra_access_forest (struct access *root)
gcc_assert (offset == access->offset);
gcc_assert (access->grp_unscalarizable_region
|| size == max_size);
- gcc_assert (max_size == access->size);
+ gcc_assert (!is_gimple_reg_type (access->type)
+ || max_size == access->size);
gcc_assert (reverse == access->reverse);
if (access->first_child)
--
2.25.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] sra: Only verify sizes of scalar accesses (PR 93845)
2020-02-21 11:53 [PATCH] sra: Only verify sizes of scalar accesses (PR 93845) Martin Jambor
@ 2020-02-21 12:31 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2020-02-21 12:31 UTC (permalink / raw)
To: Martin Jambor; +Cc: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 2870 bytes --]
On Fri, 21 Feb 2020, Martin Jambor wrote:
> Hi,
>
> the testcase is another example - in addition to recent PR 93516 - where
> the SRA access verifier is confused by the fact that get_ref_base_extent
> can return different sizes for the same type, depending whether they are
> COMPONENT_REF or not. In the previous bug I decided to keep the
> verifier check for aggregate type even though it is not really important
> and instead avoid easily detectable type-within-the-same-type situation.
> This testcase is however a result of a fairly random looking type cast
> and so cannot be handled in the same way.
>
> Because the check is not really important for aggregates, this patch
> simply disables it for non-register types.
>
> Bootstrapped and tested on x86_64-linux. OK for trunk?
OK.
Richard.
> Thanks,
>
> Martin
>
> 2020-02-20 Martin Jambor <mjambor@suse.cz>
>
> PR tree-optimization/93845
> * tree-sra.c (verify_sra_access_forest): Only test access size of
> scalar types.
>
> testsuite/
> * g++.dg/tree-ssa/pr93845.C: New test.
> ---
> gcc/ChangeLog | 6 +++++
> gcc/testsuite/ChangeLog | 5 +++++
> gcc/testsuite/g++.dg/tree-ssa/pr93845.C | 30 +++++++++++++++++++++++++
> gcc/tree-sra.c | 3 ++-
> 4 files changed, 43 insertions(+), 1 deletion(-)
> create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr93845.C
>
> diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr93845.C b/gcc/testsuite/g++.dg/tree-ssa/pr93845.C
> new file mode 100644
> index 00000000000..72e473fffcd
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/tree-ssa/pr93845.C
> @@ -0,0 +1,30 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O1" } */
> +
> +struct g;
> +struct h {
> + g *operator->();
> +};
> +class i {
> + void *a;
> + int b;
> +
> +public:
> + template <typename f> f j() { return *static_cast<f *>(this); }
> +};
> +struct k : i {};
> +struct l : k {};
> +struct m {
> + i n();
> + i o(l, l, int);
> +};
> +struct g {
> + void m_fn4(k);
> +};
> +h a;
> +i b;
> +i m::n() {
> + l c, d, e = o(d, c, 0).j<l>();
> + a->m_fn4(e);
> + return b;
> +}
> diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
> index 0cfac0a8192..1439f11f15a 100644
> --- a/gcc/tree-sra.c
> +++ b/gcc/tree-sra.c
> @@ -2339,7 +2339,8 @@ verify_sra_access_forest (struct access *root)
> gcc_assert (offset == access->offset);
> gcc_assert (access->grp_unscalarizable_region
> || size == max_size);
> - gcc_assert (max_size == access->size);
> + gcc_assert (!is_gimple_reg_type (access->type)
> + || max_size == access->size);
> gcc_assert (reverse == access->reverse);
>
> if (access->first_child)
>
--
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-02-21 12:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-21 11:53 [PATCH] sra: Only verify sizes of scalar accesses (PR 93845) Martin Jambor
2020-02-21 12:31 ` Richard Biener
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).