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

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).