public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/102711] New: Infinite loop with extern calls removed with -O2 or higher
@ 2021-10-12 15:47 andy.koppe at analog dot com
2021-10-12 16:03 ` [Bug tree-optimization/102711] [9/10/11 Regression] CDDCE removes condition that might lead to an infinite loop causing an unconditional infinite loop pinskia at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: andy.koppe at analog dot com @ 2021-10-12 15:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102711
Bug ID: 102711
Summary: Infinite loop with extern calls removed with -O2 or
higher
Product: gcc
Version: 11.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: andy.koppe at analog dot com
Target Milestone: ---
Created attachment 51591
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51591&action=edit
Minimized example
Compiling the minimised example below (and attached) with -O2 or higher, if
FAIL is defined, the second infinite loop is removed. Code is produced for it
when FAIL is not defined.
Reproduced with gcc 10.3.1 for aarch64-none-elf, gcc 11.2.0 for
x86_64-pc-cygwin, and gcc 9.3.0 for x86_64-linux-gnu.
$ cat test.c
int bar(void);
void foo(void)
{
if (!bar())
for (;;);
for (;;) {
static int flag = 0;
int ret = 0;
bar();
if (flag) {
ret = bar();
if (!ret)
ret = bar();
}
flag = !bar();
#ifdef FAIL
if (!ret)
#endif
bar();
}
}
$ aarch64-none-elf-gcc -O2 -S test.c -DFAIL
$ cat test.s
.arch armv8-a
.file "test.c"
.text
.align 2
.p2align 4,,11
.global foo
.type foo, %function
foo:
stp x29, x30, [sp, -16]!
mov x29, sp
bl bar
.L2:
b .L2
.size foo, .-foo
.ident "GCC: (GNU Toolchain for the A-profile Architecture
10.3-2021.07 (arm-10.29)) 10.3.1 20210621"
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/102711] [9/10/11 Regression] CDDCE removes condition that might lead to an infinite loop causing an unconditional infinite loop
2021-10-12 15:47 [Bug c/102711] New: Infinite loop with extern calls removed with -O2 or higher andy.koppe at analog dot com
@ 2021-10-12 16:03 ` pinskia at gcc dot gnu.org
2021-10-12 16:08 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-12 16:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102711
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |9.5
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Looks to be fixed on the trunk.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/102711] [9/10/11 Regression] CDDCE removes condition that might lead to an infinite loop causing an unconditional infinite loop
2021-10-12 15:47 [Bug c/102711] New: Infinite loop with extern calls removed with -O2 or higher andy.koppe at analog dot com
2021-10-12 16:03 ` [Bug tree-optimization/102711] [9/10/11 Regression] CDDCE removes condition that might lead to an infinite loop causing an unconditional infinite loop pinskia at gcc dot gnu.org
@ 2021-10-12 16:08 ` pinskia at gcc dot gnu.org
2021-10-13 6:44 ` rguenth at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-12 16:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102711
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2021-10-12
Ever confirmed|0 |1
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Just for refence this is the testcase that can be done at runtime:
void exit(int);
__attribute__((noipa))
int bar(void)
{
static int t = 0;
t++;
if (t == 2) exit(0);
return 1;
}
__attribute__((noipa))
void foo(void)
{
if (!bar())
for (;;);
for (;;) {
static int flag = 0;
int ret = 0;
bar();
if (flag) {
ret = bar();
if (!ret)
ret = bar();
}
flag = !bar();
if (!ret)
bar();
}
}
int main(void)
{
foo();
}
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/102711] [9/10/11 Regression] CDDCE removes condition that might lead to an infinite loop causing an unconditional infinite loop
2021-10-12 15:47 [Bug c/102711] New: Infinite loop with extern calls removed with -O2 or higher andy.koppe at analog dot com
2021-10-12 16:03 ` [Bug tree-optimization/102711] [9/10/11 Regression] CDDCE removes condition that might lead to an infinite loop causing an unconditional infinite loop pinskia at gcc dot gnu.org
2021-10-12 16:08 ` pinskia at gcc dot gnu.org
@ 2021-10-13 6:44 ` rguenth at gcc dot gnu.org
2021-10-13 12:10 ` marxin at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-10-13 6:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102711
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
CC| |rguenth at gcc dot gnu.org
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=99101
Keywords| |needs-bisection
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Feels related to PR99101. We fail to mark the first if (!bar()) condition
as useful. On trunk we happen to mark it when visiting control dependences
of if (flag).
A related commit _might_ be g:58ad6b2802592f1448eed48e8ad4e0e87985cecb
Can somebody bisect whether that "fixed" the issue on trunk? Note that
wasn't really a "fix" - but as PR99101 notes I have a hunch that the
control dependence code doesn't behave like we want in the context of
CD-DCE and infinite loops.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/102711] [9/10/11 Regression] CDDCE removes condition that might lead to an infinite loop causing an unconditional infinite loop
2021-10-12 15:47 [Bug c/102711] New: Infinite loop with extern calls removed with -O2 or higher andy.koppe at analog dot com
` (2 preceding siblings ...)
2021-10-13 6:44 ` rguenth at gcc dot gnu.org
@ 2021-10-13 12:10 ` marxin at gcc dot gnu.org
2021-10-13 12:14 ` rguenther at suse dot de
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-10-13 12:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102711
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |marxin at gcc dot gnu.org
--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
Fixed on master with r12-2591-g2e96b5f14e402569.
Note it started with r8-2318-g34e5c5116fa58f77.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/102711] [9/10/11 Regression] CDDCE removes condition that might lead to an infinite loop causing an unconditional infinite loop
2021-10-12 15:47 [Bug c/102711] New: Infinite loop with extern calls removed with -O2 or higher andy.koppe at analog dot com
` (3 preceding siblings ...)
2021-10-13 12:10 ` marxin at gcc dot gnu.org
@ 2021-10-13 12:14 ` rguenther at suse dot de
2021-11-10 14:32 ` marxin at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenther at suse dot de @ 2021-10-13 12:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102711
--- Comment #5 from rguenther at suse dot de <rguenther at suse dot de> ---
On Wed, 13 Oct 2021, marxin at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102711
>
> Martin Liška <marxin at gcc dot gnu.org> changed:
>
> What |Removed |Added
> ----------------------------------------------------------------------------
> CC| |marxin at gcc dot gnu.org
>
> --- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
> Fixed on master with r12-2591-g2e96b5f14e402569.
OK, that likely made it latent only.
> Note it started with r8-2318-g34e5c5116fa58f77.
I see - probably makes sense since that subtly changes post-dominators
for backwards unreachable regions which reflects back on control
dependence. But there's nothing "wrong" here, I think it avoided
placing the fake exit edges at the infinite loop headers as opposed
to the latch but I don't remember exactly.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/102711] [9/10/11 Regression] CDDCE removes condition that might lead to an infinite loop causing an unconditional infinite loop
2021-10-12 15:47 [Bug c/102711] New: Infinite loop with extern calls removed with -O2 or higher andy.koppe at analog dot com
` (4 preceding siblings ...)
2021-10-13 12:14 ` rguenther at suse dot de
@ 2021-11-10 14:32 ` marxin at gcc dot gnu.org
2022-05-27 9:46 ` [Bug tree-optimization/102711] [10/11 " rguenth at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-10 14:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102711
--- Comment #6 from Martin Liška <marxin at gcc dot gnu.org> ---
> I see - probably makes sense since that subtly changes post-dominators
> for backwards unreachable regions which reflects back on control
> dependence. But there's nothing "wrong" here, I think it avoided
> placing the fake exit edges at the infinite loop headers as opposed
> to the latch but I don't remember exactly.
Do we still need more bisection?
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/102711] [10/11 Regression] CDDCE removes condition that might lead to an infinite loop causing an unconditional infinite loop
2021-10-12 15:47 [Bug c/102711] New: Infinite loop with extern calls removed with -O2 or higher andy.koppe at analog dot com
` (5 preceding siblings ...)
2021-11-10 14:32 ` marxin at gcc dot gnu.org
@ 2022-05-27 9:46 ` rguenth at gcc dot gnu.org
2022-06-28 10:46 ` jakub at gcc dot gnu.org
2023-07-07 10:41 ` [Bug tree-optimization/102711] [11 " rguenth at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27 9:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102711
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|9.5 |10.4
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9 branch is being closed
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/102711] [10/11 Regression] CDDCE removes condition that might lead to an infinite loop causing an unconditional infinite loop
2021-10-12 15:47 [Bug c/102711] New: Infinite loop with extern calls removed with -O2 or higher andy.koppe at analog dot com
` (6 preceding siblings ...)
2022-05-27 9:46 ` [Bug tree-optimization/102711] [10/11 " rguenth at gcc dot gnu.org
@ 2022-06-28 10:46 ` jakub at gcc dot gnu.org
2023-07-07 10:41 ` [Bug tree-optimization/102711] [11 " rguenth at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102711
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|10.4 |10.5
--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/102711] [11 Regression] CDDCE removes condition that might lead to an infinite loop causing an unconditional infinite loop
2021-10-12 15:47 [Bug c/102711] New: Infinite loop with extern calls removed with -O2 or higher andy.koppe at analog dot com
` (7 preceding siblings ...)
2022-06-28 10:46 ` jakub at gcc dot gnu.org
@ 2023-07-07 10:41 ` rguenth at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102711
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|10.5 |11.5
--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10 branch is being closed.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-07-07 10:41 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12 15:47 [Bug c/102711] New: Infinite loop with extern calls removed with -O2 or higher andy.koppe at analog dot com
2021-10-12 16:03 ` [Bug tree-optimization/102711] [9/10/11 Regression] CDDCE removes condition that might lead to an infinite loop causing an unconditional infinite loop pinskia at gcc dot gnu.org
2021-10-12 16:08 ` pinskia at gcc dot gnu.org
2021-10-13 6:44 ` rguenth at gcc dot gnu.org
2021-10-13 12:10 ` marxin at gcc dot gnu.org
2021-10-13 12:14 ` rguenther at suse dot de
2021-11-10 14:32 ` marxin at gcc dot gnu.org
2022-05-27 9:46 ` [Bug tree-optimization/102711] [10/11 " rguenth at gcc dot gnu.org
2022-06-28 10:46 ` jakub at gcc dot gnu.org
2023-07-07 10:41 ` [Bug tree-optimization/102711] [11 " rguenth at gcc dot gnu.org
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).