https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98117

            Bug ID: 98117
           Summary: wrong code with "-O3 -fno-tree-scev-cprop"
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: suochenyao at 163 dot com
  Target Milestone: ---

*******************************************************************************
OS and Platform:
CentOS Linux release 7.8.2003 (Core), x86_64 GNU/Linux
*******************************************************************************
Program:
$ cat a.c
int printf(const char *, ...);
int a=0;
char b=0, c=0;
short d=0;
void e() {
  for (; b; b++)
    d = a + 8;
  for (; d;)
    ;
f:
  c++;
  if (c)
    goto f;
}
int main() {
  e();
  printf("%d\n", c);
}
*******************************************************************************
gcc version:
$ gcc --version
gcc (GCC) 11.0.0 20201203 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*******************************************************************************
Command Lines:
$ gcc a.c -o a1.o
$ gcc -Wall -Wextra -fno-strict-aliasing -fwrapv -O3 -fno-tree-scev-cprop  a.c
-o a2.o
$ ./a1.o
0
$ ./a2.o
-32

Reply via email to