* [Bug c/109585] Carla/sord miscompiled with -O2 on ARM64 (inlining issue)
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
@ 2023-04-21 10:40 ` hector at marcansoft dot com
2023-04-21 10:52 ` rguenth at gcc dot gnu.org
` (27 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: hector at marcansoft dot com @ 2023-04-21 10:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
--- Comment #1 from Hector Martin <hector at marcansoft dot com> ---
Created attachment 54901
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54901&action=edit
Preprocessed input
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug c/109585] Carla/sord miscompiled with -O2 on ARM64 (inlining issue)
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
2023-04-21 10:40 ` [Bug c/109585] " hector at marcansoft dot com
@ 2023-04-21 10:52 ` rguenth at gcc dot gnu.org
2023-04-21 11:36 ` [Bug target/109585] " hector at marcansoft dot com
` (26 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-04-21 10:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
I wonder if you can provide a harness exercising this at runtime?
Can you try -fno-schedule-insns -fno-schedule-insns2?
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug target/109585] Carla/sord miscompiled with -O2 on ARM64 (inlining issue)
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
2023-04-21 10:40 ` [Bug c/109585] " hector at marcansoft dot com
2023-04-21 10:52 ` rguenth at gcc dot gnu.org
@ 2023-04-21 11:36 ` hector at marcansoft dot com
2023-04-21 11:37 ` hector at marcansoft dot com
` (25 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: hector at marcansoft dot com @ 2023-04-21 11:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
--- Comment #3 from Hector Martin <hector at marcansoft dot com> ---
Created attachment 54903
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54903&action=edit
lv2 plugin bundle for testing
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug target/109585] Carla/sord miscompiled with -O2 on ARM64 (inlining issue)
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (2 preceding siblings ...)
2023-04-21 11:36 ` [Bug target/109585] " hector at marcansoft dot com
@ 2023-04-21 11:37 ` hector at marcansoft dot com
2023-04-21 16:36 ` hector at marcansoft dot com
` (24 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: hector at marcansoft dot com @ 2023-04-21 11:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
--- Comment #4 from Hector Martin <hector at marcansoft dot com> ---
This whole codebase is complex, and the problem is in btree code which is hard
to simplify down. Best I can do right now is this. First grab the lv2.tar.gz
attachment and extract it into /tmp. Then:
$ git clone https://github.com/falkTX/Carla
$ cd Carla && make -C source/modules/lilv
$ cat > test.c << EOF
#include "lilv/lilv.h"
int main(int argc, char **argv)
{
LilvWorld* world = lilv_world_new();
lilv_world_load_all(world, "/tmp/lv2");
}
EOF
$ gcc -I source/includes/ -I source/modules/lilv/lilv-0.24.0/ -o test test.c
./build/modules/Release/lilv.a -lm
$ ./test
Compiling with -fno-schedule-insns -fno-schedule-insns2 seems to work properly.
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug target/109585] Carla/sord miscompiled with -O2 on ARM64 (inlining issue)
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (3 preceding siblings ...)
2023-04-21 11:37 ` hector at marcansoft dot com
@ 2023-04-21 16:36 ` hector at marcansoft dot com
2023-04-21 16:38 ` hector at marcansoft dot com
` (23 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: hector at marcansoft dot com @ 2023-04-21 16:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
--- Comment #5 from Hector Martin <hector at marcansoft dot com> ---
Created attachment 54904
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54904&action=edit
self-contained reproducer
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug target/109585] Carla/sord miscompiled with -O2 on ARM64 (inlining issue)
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (4 preceding siblings ...)
2023-04-21 16:36 ` hector at marcansoft dot com
@ 2023-04-21 16:38 ` hector at marcansoft dot com
2023-04-21 16:43 ` pinskia at gcc dot gnu.org
` (22 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: hector at marcansoft dot com @ 2023-04-21 16:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
--- Comment #6 from Hector Martin <hector at marcansoft dot com> ---
Cleaned it up into a self-contained repro. Simply compiling with `gcc -O2 -o
test test.c && test` gives a segfault. -O1 or -fno-schedule-insns
-fno-schedule-insns2 avoids the issue.
Looking at assembly output on godbolt, it seems this likely goes at least as
far back as 11.1 if not earlier.
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug target/109585] Carla/sord miscompiled with -O2 on ARM64 (inlining issue)
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (5 preceding siblings ...)
2023-04-21 16:38 ` hector at marcansoft dot com
@ 2023-04-21 16:43 ` pinskia at gcc dot gnu.org
2023-04-21 16:50 ` [Bug middle-end/109585] " pinskia at gcc dot gnu.org
` (21 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-21 16:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
-fno-strict-aliasing also fixes the issue ...
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug middle-end/109585] Carla/sord miscompiled with -O2 on ARM64 (inlining issue)
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (6 preceding siblings ...)
2023-04-21 16:43 ` pinskia at gcc dot gnu.org
@ 2023-04-21 16:50 ` pinskia at gcc dot gnu.org
2023-04-21 16:55 ` hector at marcansoft dot com
` (20 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-21 16:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Interesting compiling with the C++ front-end (with one minor change of adding a
cast to the malloc) does not seg fault at -O2.
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug middle-end/109585] Carla/sord miscompiled with -O2 on ARM64 (inlining issue)
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (7 preceding siblings ...)
2023-04-21 16:50 ` [Bug middle-end/109585] " pinskia at gcc dot gnu.org
@ 2023-04-21 16:55 ` hector at marcansoft dot com
2023-04-21 17:05 ` pinskia at gcc dot gnu.org
` (19 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: hector at marcansoft dot com @ 2023-04-21 16:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
--- Comment #9 from Hector Martin <hector at marcansoft dot com> ---
Yes, a strict aliasing violation could explain the behavior of the optimizer
here... but given all the types are identical and there is no casting going on,
clearly there is no strict aliasing violation.
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug middle-end/109585] Carla/sord miscompiled with -O2 on ARM64 (inlining issue)
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (8 preceding siblings ...)
2023-04-21 16:55 ` hector at marcansoft dot com
@ 2023-04-21 17:05 ` pinskia at gcc dot gnu.org
2023-04-21 17:08 ` hector at marcansoft dot com
` (18 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-21 17:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
If I change zix_btree_iter_is_end to:
ZIX_API bool
zix_btree_iter_is_end(const struct ZixBTreeIterImpl* const i)
{
if (!i)
return 1;
if (i->stack[0].node == NULL)
return 1;
return 0;
}
Then both the C and C++ front-end generated IR causes the segfault.
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug middle-end/109585] Carla/sord miscompiled with -O2 on ARM64 (inlining issue)
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (9 preceding siblings ...)
2023-04-21 17:05 ` pinskia at gcc dot gnu.org
@ 2023-04-21 17:08 ` hector at marcansoft dot com
2023-04-21 17:16 ` [Bug middle-end/109585] Carla/sord miscompiled with -O2 on ARM64 with flexible array member pinskia at gcc dot gnu.org
` (17 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: hector at marcansoft dot com @ 2023-04-21 17:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
--- Comment #11 from Hector Martin <hector at marcansoft dot com> ---
Giving a nonzero size to the `ZixBTreeIterFrame stack[]` member also avoids the
segfault, so this might be a flexible array member thing.
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug middle-end/109585] Carla/sord miscompiled with -O2 on ARM64 with flexible array member
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (10 preceding siblings ...)
2023-04-21 17:08 ` hector at marcansoft dot com
@ 2023-04-21 17:16 ` pinskia at gcc dot gnu.org
2023-04-22 21:48 ` [Bug rtl-optimization/109585] " amonakov at gcc dot gnu.org
` (16 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-21 17:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Carla/sord miscompiled with |Carla/sord miscompiled with
|-O2 on ARM64 (inlining |-O2 on ARM64 with flexible
|issue) |array member
--- Comment #12 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Looks like the aliasing code is getting the flexible array member aliasing
wrong.
Replacing:
ZixBTreeIterFrame stack[];
With:
ZixBTreeIterFrame stack[1];
Fixes the issue ...
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug rtl-optimization/109585] Carla/sord miscompiled with -O2 on ARM64 with flexible array member
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (11 preceding siblings ...)
2023-04-21 17:16 ` [Bug middle-end/109585] Carla/sord miscompiled with -O2 on ARM64 with flexible array member pinskia at gcc dot gnu.org
@ 2023-04-22 21:48 ` amonakov at gcc dot gnu.org
2023-04-23 7:06 ` sjames at gcc dot gnu.org
` (15 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: amonakov at gcc dot gnu.org @ 2023-04-22 21:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
Alexander Monakov <amonakov at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |amonakov at gcc dot gnu.org
--- Comment #13 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
The small repro from comment #5 is reproducible on x86_64 trunk as well with
-O2 -DNDEBUG (as well as on older x86_64 branches without -DNDEBUG).
sched2 is lifting
(insn:TI 295 100 101 12 (set (reg:CCZ 17 flags)
(compare:CCZ (mem/f:DI (plus:DI (reg/v/f:DI 3 bx [orig:133 t ] [133])
(const_int 8 [0x8])) [2 MEM[(const struct ZixBTreeIter
*)t_3(D)].stack[0].node+0 S8 A64])
(const_int 0 [0]))) "/app/example.c":65:12 discrim 2 8
{*cmpdi_ccno_1}
(nil))
above conflicting
(insn 101 295 102 12 (set (mem/f:DI (reg/v/f:DI 0 ax [orig:96 f ] [96]) [2
f_69->node+0 S8 A64])
(const_int 0 [0])) "/app/example.c":86:14 88 {*movdi_internal}
(nil))
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug rtl-optimization/109585] Carla/sord miscompiled with -O2 on ARM64 with flexible array member
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (12 preceding siblings ...)
2023-04-22 21:48 ` [Bug rtl-optimization/109585] " amonakov at gcc dot gnu.org
@ 2023-04-23 7:06 ` sjames at gcc dot gnu.org
2023-04-23 7:08 ` hector at marcansoft dot com
` (14 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-04-23 7:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
Sam James <sjames at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target|aarch64 |aarch64, x86_64-linux-gnu
--- Comment #14 from Sam James <sjames at gcc dot gnu.org> ---
(In reply to Alexander Monakov from comment #13)
> The small repro from comment #5 is reproducible on x86_64 trunk as well with
> -O2 -DNDEBUG (as well as on older x86_64 branches without -DNDEBUG).
>
I'll add x86_64-linux-gnu to target then, hopefully that's alright (unclear b/c
it's only the reduced one seemingly).
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug rtl-optimization/109585] Carla/sord miscompiled with -O2 on ARM64 with flexible array member
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (13 preceding siblings ...)
2023-04-23 7:06 ` sjames at gcc dot gnu.org
@ 2023-04-23 7:08 ` hector at marcansoft dot com
2023-04-23 7:50 ` xry111 at gcc dot gnu.org
` (13 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: hector at marcansoft dot com @ 2023-04-23 7:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
--- Comment #15 from Hector Martin <hector at marcansoft dot com> ---
The prior repro was too complex and depended on other environmental stuff (some
other people couldn't repro it on arm64 either), so please ignore it. If the
reduced repro triggers the issue, it's the same bug.
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug rtl-optimization/109585] Carla/sord miscompiled with -O2 on ARM64 with flexible array member
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (14 preceding siblings ...)
2023-04-23 7:08 ` hector at marcansoft dot com
@ 2023-04-23 7:50 ` xry111 at gcc dot gnu.org
2023-04-23 7:55 ` [Bug rtl-optimization/109585] [10/11/12/13/14 regression] " xry111 at gcc dot gnu.org
` (12 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-04-23 7:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |xry111 at gcc dot gnu.org
--- Comment #16 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to Hector Martin from comment #15)
> The prior repro was too complex and depended on other environmental stuff
> (some other people couldn't repro it on arm64 either), so please ignore it.
> If the reduced repro triggers the issue, it's the same bug.
I can reproduce the issue with the reduced repro on x86_64-linux-gnu too.
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug rtl-optimization/109585] [10/11/12/13/14 regression] Carla/sord miscompiled with -O2 on ARM64 with flexible array member
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (15 preceding siblings ...)
2023-04-23 7:50 ` xry111 at gcc dot gnu.org
@ 2023-04-23 7:55 ` xry111 at gcc dot gnu.org
2023-04-24 6:39 ` rguenth at gcc dot gnu.org
` (11 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-04-23 7:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Carla/sord miscompiled with |[10/11/12/13/14 regression]
|-O2 on ARM64 with flexible |Carla/sord miscompiled with
|array member |-O2 on ARM64 with flexible
| |array member
--- Comment #17 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
With GCC 9 it was fine, but not GCC 10. I guess we can try a bisect...
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug rtl-optimization/109585] [10/11/12/13/14 regression] Carla/sord miscompiled with -O2 on ARM64 with flexible array member
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (16 preceding siblings ...)
2023-04-23 7:55 ` [Bug rtl-optimization/109585] [10/11/12/13/14 regression] " xry111 at gcc dot gnu.org
@ 2023-04-24 6:39 ` rguenth at gcc dot gnu.org
2023-04-24 6:40 ` rguenth at gcc dot gnu.org
` (10 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-04-24 6:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
CC| |rguenth at gcc dot gnu.org
Target Milestone|--- |10.5
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug rtl-optimization/109585] [10/11/12/13/14 regression] Carla/sord miscompiled with -O2 on ARM64 with flexible array member
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (17 preceding siblings ...)
2023-04-24 6:39 ` rguenth at gcc dot gnu.org
@ 2023-04-24 6:40 ` rguenth at gcc dot gnu.org
2023-04-24 8:46 ` amonakov at gcc dot gnu.org
` (9 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-04-24 6:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2023-04-24
Status|UNCONFIRMED |NEW
--- Comment #18 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Alexander Monakov from comment #13)
> The small repro from comment #5 is reproducible on x86_64 trunk as well with
> -O2 -DNDEBUG (as well as on older x86_64 branches without -DNDEBUG).
>
> sched2 is lifting
>
> (insn:TI 295 100 101 12 (set (reg:CCZ 17 flags)
> (compare:CCZ (mem/f:DI (plus:DI (reg/v/f:DI 3 bx [orig:133 t ] [133])
> (const_int 8 [0x8])) [2 MEM[(const struct ZixBTreeIter
> *)t_3(D)].stack[0].node+0 S8 A64])
> (const_int 0 [0]))) "/app/example.c":65:12 discrim 2 8
> {*cmpdi_ccno_1}
> (nil))
>
> above conflicting
>
> (insn 101 295 102 12 (set (mem/f:DI (reg/v/f:DI 0 ax [orig:96 f ] [96]) [2
> f_69->node+0 S8 A64])
> (const_int 0 [0])) "/app/example.c":86:14 88 {*movdi_internal}
> (nil))
since MEM_ALIAS_SET are the same it must be MEM_EXPR handling going wrong,
or points-to info giving the wrong answer.
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug rtl-optimization/109585] [10/11/12/13/14 regression] Carla/sord miscompiled with -O2 on ARM64 with flexible array member
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (18 preceding siblings ...)
2023-04-24 6:40 ` rguenth at gcc dot gnu.org
@ 2023-04-24 8:46 ` amonakov at gcc dot gnu.org
2023-04-24 9:04 ` jakub at gcc dot gnu.org
` (8 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: amonakov at gcc dot gnu.org @ 2023-04-24 8:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
--- Comment #19 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Manually minimized testcase for investigation, miscompiled at -O2:
struct P {
long v;
struct P *n;
};
struct F {
long x;
struct P fam[];
};
int 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;
}
Trunk emits:
f:
lea rdx, [rdi+8]
mov rax, rdi
mov QWORD PTR [rdi+8], 0
cmp QWORD PTR [rax+16], 0
mov QWORD PTR [rdi+16], 0
setne al
movzx eax, al
ret
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug rtl-optimization/109585] [10/11/12/13/14 regression] Carla/sord miscompiled with -O2 on ARM64 with flexible array member
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (19 preceding siblings ...)
2023-04-24 8:46 ` amonakov at gcc dot gnu.org
@ 2023-04-24 9:04 ` jakub at gcc dot gnu.org
2023-04-24 9:54 ` rguenth at gcc dot gnu.org
` (7 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-04-24 9:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hubicka at gcc dot gnu.org,
| |jakub at gcc dot gnu.org
--- Comment #20 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
On the #c5 testcase on x86_64 at -O2 this bisects to
r10-514-gc6b84edb6110dd2b4fb
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug rtl-optimization/109585] [10/11/12/13/14 regression] Carla/sord miscompiled with -O2 on ARM64 with flexible array member
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (20 preceding siblings ...)
2023-04-24 9:04 ` jakub at gcc dot gnu.org
@ 2023-04-24 9:54 ` rguenth at gcc dot gnu.org
2023-04-24 11:35 ` rguenth at gcc dot gnu.org
` (6 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-04-24 9:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
--- Comment #21 from Richard Biener <rguenth at gcc dot gnu.org> ---
aliasing_component_refs_p seems to try handle trailing arrays via
component_ref_to_zero_sized_trailing_array_p. It properly detects
f_5->fam[0].n
but fails on
MEM[(struct P *)f_3(D) + 8B].n
but it would also in all cases happily continue with the base ref type
when comparing sizes:
/* Now search for the type1 in the access path of ref2. This
would be a common base for doing offset based disambiguation on.
This however only makes sense if type2 is big enough to hold type1. */
int cmp_outer = compare_type_sizes (type2, type1);
I also wonder if
/* 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))
here type1 shouldn't be type2?
In any case we end up failing the access_path_may_continue_p checks and
disambiguate.
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,
seems to fix the testcase - can anybody confirm?
Honza, is that indeed a typo or do I just hide the issue?
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug rtl-optimization/109585] [10/11/12/13/14 regression] Carla/sord miscompiled with -O2 on ARM64 with flexible array member
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (21 preceding siblings ...)
2023-04-24 9:54 ` rguenth at gcc dot gnu.org
@ 2023-04-24 11:35 ` rguenth at gcc dot gnu.org
2023-04-25 12:24 ` cvs-commit at gcc dot gnu.org
` (5 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-04-24 11:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #22 from Richard Biener <rguenth at gcc dot gnu.org> ---
Created attachment 54911
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54911&action=edit
patch I am testing
I am testing the attached.
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug rtl-optimization/109585] [10/11/12/13/14 regression] Carla/sord miscompiled with -O2 on ARM64 with flexible array member
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (22 preceding siblings ...)
2023-04-24 11:35 ` rguenth at gcc dot gnu.org
@ 2023-04-25 12:24 ` cvs-commit at gcc dot gnu.org
2023-04-25 12:25 ` [Bug rtl-optimization/109585] [10/11/12/13 " rguenth at gcc dot gnu.org
` (4 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-25 12:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
--- Comment #23 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:6d4bd27a60447c7505cb4783e675e98a191a8904
commit r14-219-g6d4bd27a60447c7505cb4783e675e98a191a8904
Author: Richard Biener <rguenther@suse.de>
Date: Mon Apr 24 13:31:07 2023 +0200
rtl-optimization/109585 - alias analysis typo
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.
PR rtl-optimization/109585
* tree-ssa-alias.cc (aliasing_component_refs_p): Fix typo.
* gcc.dg/torture/pr109585.c: New testcase.
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug rtl-optimization/109585] [10/11/12/13 regression] Carla/sord miscompiled with -O2 on ARM64 with flexible array member
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (23 preceding siblings ...)
2023-04-25 12:24 ` cvs-commit at gcc dot gnu.org
@ 2023-04-25 12:25 ` rguenth at gcc dot gnu.org
2023-04-26 9:33 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-04-25 12:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[10/11/12/13/14 regression] |[10/11/12/13 regression]
|Carla/sord miscompiled with |Carla/sord miscompiled with
|-O2 on ARM64 with flexible |-O2 on ARM64 with flexible
|array member |array member
Known to work| |14.0
--- Comment #24 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed on trunk sofar.
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug rtl-optimization/109585] [10/11/12/13 regression] Carla/sord miscompiled with -O2 on ARM64 with flexible array member
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (24 preceding siblings ...)
2023-04-25 12:25 ` [Bug rtl-optimization/109585] [10/11/12/13 " rguenth at gcc dot gnu.org
@ 2023-04-26 9:33 ` cvs-commit at gcc dot gnu.org
2023-04-26 10:41 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
28 siblings, 0 replies; 30+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-26 9:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
--- Comment #25 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:bb406a6aea336966681927a27f54ee89c4fd4ea1
commit r13-7251-gbb406a6aea336966681927a27f54ee89c4fd4ea1
Author: Richard Biener <rguenther@suse.de>
Date: Mon Apr 24 13:31:07 2023 +0200
rtl-optimization/109585 - alias analysis typo
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.
PR rtl-optimization/109585
* tree-ssa-alias.cc (aliasing_component_refs_p): Fix typo.
* gcc.dg/torture/pr109585.c: New testcase.
(cherry picked from commit 6d4bd27a60447c7505cb4783e675e98a191a8904)
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug rtl-optimization/109585] [10/11/12/13 regression] Carla/sord miscompiled with -O2 on ARM64 with flexible array member
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (25 preceding siblings ...)
2023-04-26 9:33 ` cvs-commit at gcc dot gnu.org
@ 2023-04-26 10:41 ` cvs-commit at gcc dot gnu.org
2023-05-02 12:04 ` [Bug rtl-optimization/109585] [10/11 " cvs-commit at gcc dot gnu.org
2023-07-07 10:08 ` [Bug rtl-optimization/109585] [10 " rguenth at gcc dot gnu.org
28 siblings, 0 replies; 30+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-26 10:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
--- Comment #26 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:ef6051b36241bf130bf76af0b775248635dc616e
commit r12-9473-gef6051b36241bf130bf76af0b775248635dc616e
Author: Richard Biener <rguenther@suse.de>
Date: Mon Apr 24 13:31:07 2023 +0200
rtl-optimization/109585 - alias analysis typo
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.
PR rtl-optimization/109585
* tree-ssa-alias.cc (aliasing_component_refs_p): Fix typo.
* gcc.dg/torture/pr109585.c: New testcase.
(cherry picked from commit 6d4bd27a60447c7505cb4783e675e98a191a8904)
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug rtl-optimization/109585] [10/11 regression] Carla/sord miscompiled with -O2 on ARM64 with flexible array member
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (26 preceding siblings ...)
2023-04-26 10:41 ` cvs-commit at gcc dot gnu.org
@ 2023-05-02 12:04 ` cvs-commit at gcc dot gnu.org
2023-07-07 10:08 ` [Bug rtl-optimization/109585] [10 " rguenth at gcc dot gnu.org
28 siblings, 0 replies; 30+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-02 12:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
--- Comment #27 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:e54ecbcbe625847f384b11c41562038477a3eb2c
commit r11-10678-ge54ecbcbe625847f384b11c41562038477a3eb2c
Author: Richard Biener <rguenther@suse.de>
Date: Mon Apr 24 13:31:07 2023 +0200
rtl-optimization/109585 - alias analysis typo
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.
PR rtl-optimization/109585
* tree-ssa-alias.c (aliasing_component_refs_p): Fix typo.
* gcc.dg/torture/pr109585.c: New testcase.
(cherry picked from commit 6d4bd27a60447c7505cb4783e675e98a191a8904)
^ permalink raw reply [flat|nested] 30+ messages in thread
* [Bug rtl-optimization/109585] [10 regression] Carla/sord miscompiled with -O2 on ARM64 with flexible array member
2023-04-21 10:39 [Bug c/109585] New: Carla/sord miscompiled with -O2 on ARM64 (inlining issue) hector at marcansoft dot com
` (27 preceding siblings ...)
2023-05-02 12:04 ` [Bug rtl-optimization/109585] [10/11 " cvs-commit at gcc dot gnu.org
@ 2023-07-07 10:08 ` rguenth at gcc dot gnu.org
28 siblings, 0 replies; 30+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |10.5.0
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
Target Milestone|10.5 |11.4
--- Comment #28 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed in GCC 11.4
^ permalink raw reply [flat|nested] 30+ messages in thread