* [PATCH] rtl-optimization/109585 - alias analysis typo
@ 2023-04-25 6:25 Richard Biener
2023-04-25 9:52 ` Jan Hubicka
0 siblings, 1 reply; 2+ messages in thread
From: Richard Biener @ 2023-04-25 6:25 UTC (permalink / raw)
To: gcc-patches; +Cc: Jan Hubicka
When r10-514-gc6b84edb6110dd2b4fb improved access path analysis
it introduced a typo that triggers when there's an access to a
trailing array in the first access path leading to false
disambiguation.
Bootstrapped and tested on x86_64-unknown-linux-gnu.
Honza, does this look OK?
Thanks,
Richard.
PR rtl-optimization/109585
* tree-ssa-alias.cc (aliasing_component_refs_p): Fix typo.
* gcc.dg/torture/pr109585.c: New testcase.
---
gcc/testsuite/gcc.dg/torture/pr109585.c | 33 +++++++++++++++++++++++++
gcc/tree-ssa-alias.cc | 2 +-
2 files changed, 34 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/torture/pr109585.c
diff --git a/gcc/testsuite/gcc.dg/torture/pr109585.c b/gcc/testsuite/gcc.dg/torture/pr109585.c
new file mode 100644
index 00000000000..f92de7c1f2e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr109585.c
@@ -0,0 +1,33 @@
+/* { dg-do run } */
+
+#include <stdlib.h>
+
+struct P {
+ long v;
+ struct P *n;
+};
+
+struct F {
+ long x;
+ struct P fam[];
+};
+
+int __attribute__((noipa))
+f(struct F *f, int i)
+{
+ struct P *p = f->fam;
+ asm("" : "+r"(f): "r"(p));
+ p->v = 0;
+ p->n = 0;
+ return f->fam->n != 0;
+}
+
+int
+main()
+{
+ struct F *m = malloc (sizeof (long) + 2 * sizeof (struct P));
+ m->fam[0].n = &m->fam[1];
+ if (f (m, 0))
+ abort ();
+ return 0;
+}
diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc
index 81bc51ed4ad..8a1ec9091fa 100644
--- a/gcc/tree-ssa-alias.cc
+++ b/gcc/tree-ssa-alias.cc
@@ -1330,7 +1330,7 @@ aliasing_component_refs_p (tree ref1,
/* If we didn't find a common base, try the other way around. */
if (cmp_outer <= 0
|| (end_struct_ref1
- && compare_type_sizes (TREE_TYPE (end_struct_ref1), type1) <= 0))
+ && compare_type_sizes (TREE_TYPE (end_struct_ref1), type2) <= 0))
{
int res = aliasing_component_refs_walk (ref2, type2, base2,
offset2, max_size2,
--
2.35.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] rtl-optimization/109585 - alias analysis typo
2023-04-25 6:25 [PATCH] rtl-optimization/109585 - alias analysis typo Richard Biener
@ 2023-04-25 9:52 ` Jan Hubicka
0 siblings, 0 replies; 2+ messages in thread
From: Jan Hubicka @ 2023-04-25 9:52 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches
> When r10-514-gc6b84edb6110dd2b4fb improved access path analysis
> it introduced a typo that triggers when there's an access to a
> trailing array in the first access path leading to false
> disambiguation.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu.
>
> Honza, does this look OK?
Yes, sorry for that - that is a nasty pasto :(
Honza
>
> Thanks,
> Richard.
>
> PR rtl-optimization/109585
> * tree-ssa-alias.cc (aliasing_component_refs_p): Fix typo.
>
> * gcc.dg/torture/pr109585.c: New testcase.
> ---
> gcc/testsuite/gcc.dg/torture/pr109585.c | 33 +++++++++++++++++++++++++
> gcc/tree-ssa-alias.cc | 2 +-
> 2 files changed, 34 insertions(+), 1 deletion(-)
> create mode 100644 gcc/testsuite/gcc.dg/torture/pr109585.c
>
> diff --git a/gcc/testsuite/gcc.dg/torture/pr109585.c b/gcc/testsuite/gcc.dg/torture/pr109585.c
> new file mode 100644
> index 00000000000..f92de7c1f2e
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/torture/pr109585.c
> @@ -0,0 +1,33 @@
> +/* { dg-do run } */
> +
> +#include <stdlib.h>
> +
> +struct P {
> + long v;
> + struct P *n;
> +};
> +
> +struct F {
> + long x;
> + struct P fam[];
> +};
> +
> +int __attribute__((noipa))
> +f(struct F *f, int i)
> +{
> + struct P *p = f->fam;
> + asm("" : "+r"(f): "r"(p));
> + p->v = 0;
> + p->n = 0;
> + return f->fam->n != 0;
> +}
> +
> +int
> +main()
> +{
> + struct F *m = malloc (sizeof (long) + 2 * sizeof (struct P));
> + m->fam[0].n = &m->fam[1];
> + if (f (m, 0))
> + abort ();
> + return 0;
> +}
> diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc
> index 81bc51ed4ad..8a1ec9091fa 100644
> --- a/gcc/tree-ssa-alias.cc
> +++ b/gcc/tree-ssa-alias.cc
> @@ -1330,7 +1330,7 @@ aliasing_component_refs_p (tree ref1,
> /* If we didn't find a common base, try the other way around. */
> if (cmp_outer <= 0
> || (end_struct_ref1
> - && compare_type_sizes (TREE_TYPE (end_struct_ref1), type1) <= 0))
> + && compare_type_sizes (TREE_TYPE (end_struct_ref1), type2) <= 0))
> {
> int res = aliasing_component_refs_walk (ref2, type2, base2,
> offset2, max_size2,
> --
> 2.35.3
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-04-25 9:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-25 6:25 [PATCH] rtl-optimization/109585 - alias analysis typo Richard Biener
2023-04-25 9:52 ` Jan Hubicka
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).