public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/110391] New: wrong code at -O2 and -O3 with "on x86_64-linux-gnu
@ 2023-06-24 13:17 zhendong.su at inf dot ethz.ch
  2023-06-24 13:20 ` [Bug rtl-optimization/110391] wrong code at -O2 and -O3 with "-fsel-sched-pipelining -fselective-scheduling2" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2023-06-24 13:17 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110391
           Summary: wrong code at -O2 and -O3 with "on x86_64-linux-gnu
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug rtl-optimization/110391] wrong code at -O2 and -O3 with "-fsel-sched-pipelining -fselective-scheduling2" on x86_64-linux-gnu
  2023-06-24 13:17 [Bug rtl-optimization/110391] New: wrong code at -O2 and -O3 with "on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
@ 2023-06-24 13:20 ` zhendong.su at inf dot ethz.ch
  2023-06-24 15:23 ` [Bug rtl-optimization/110391] [12/13/14 Regression] " pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2023-06-24 13:20 UTC (permalink / raw)
  To: gcc-bugs

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

Zhendong Su <zhendong.su at inf dot ethz.ch> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|wrong code at -O2 and -O3   |wrong code at -O2 and -O3
                   |with "on x86_64-linux-gnu   |with
                   |                            |"-fsel-sched-pipelining
                   |                            |-fselective-scheduling2" on
                   |                            |x86_64-linux-gnu

--- Comment #1 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
It appears to be a regression from 11.*, and affects 12.* and later.

Compiler Explorer: https://godbolt.org/z/WEhzh66Pz

[571] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230623 (experimental) [master r14-924-gd709841ae0f] (GCC) 
[572] % 
[572] % gcctk -O3 -fsel-sched-pipelining -fselective-scheduling2 -fPIC small.c
[573] % ./a.out
Floating point exception
[574] % 
[574] % gcctk -O3 small.c; ./a.out
[575] % 
[575] % cat small.c
int printf(const char *, ...);
int a, d, b, i = 2, e;
static unsigned c = 1;
char f, g = 1;
void j() {
k:
  if (b)
    for (;;)
      __builtin_abort();
  unsigned l = i && 2 / c * d % g;
  if (a) {
    l = c;
    g = i;
    if (d > 1) {
      printf("%d", c);
      goto k;
    }
  }
  a = c = l;
}
int main() {
  a = -2;
  j();
  i = 0;
  f = ~c;
  if (f > 0) {
    printf("%d", f);
    a = 2 % i;
  }
  return 0;
}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug rtl-optimization/110391] [12/13/14 Regression] wrong code at -O2 and -O3 with "-fsel-sched-pipelining -fselective-scheduling2" on x86_64-linux-gnu
  2023-06-24 13:17 [Bug rtl-optimization/110391] New: wrong code at -O2 and -O3 with "on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
  2023-06-24 13:20 ` [Bug rtl-optimization/110391] wrong code at -O2 and -O3 with "-fsel-sched-pipelining -fselective-scheduling2" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
@ 2023-06-24 15:23 ` pinskia at gcc dot gnu.org
  2023-06-26  9:12 ` zhendong.su at inf dot ethz.ch
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-24 15:23 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|wrong code at -O2 and -O3   |[12/13/14 Regression] wrong
                   |with                        |code at -O2 and -O3 with
                   |"-fsel-sched-pipelining     |"-fsel-sched-pipelining
                   |-fselective-scheduling2" on |-fselective-scheduling2" on
                   |x86_64-linux-gnu            |x86_64-linux-gnu
            Version|unknown                     |14.0
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=95123
   Target Milestone|---                         |12.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug rtl-optimization/110391] [12/13/14 Regression] wrong code at -O2 and -O3 with "-fsel-sched-pipelining -fselective-scheduling2" on x86_64-linux-gnu
  2023-06-24 13:17 [Bug rtl-optimization/110391] New: wrong code at -O2 and -O3 with "on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
  2023-06-24 13:20 ` [Bug rtl-optimization/110391] wrong code at -O2 and -O3 with "-fsel-sched-pipelining -fselective-scheduling2" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
  2023-06-24 15:23 ` [Bug rtl-optimization/110391] [12/13/14 Regression] " pinskia at gcc dot gnu.org
@ 2023-06-26  9:12 ` zhendong.su at inf dot ethz.ch
  2023-06-29  9:18 ` zhendong.su at inf dot ethz.ch
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2023-06-26  9:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
A likely related reproducer that affects 10.* and later. 

Compiler Explorer: https://godbolt.org/z/KP6PnTKPj

[579] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230625 (experimental) [master r14-924-gd709841ae0f] (GCC) 
[580] % 
[580] % gcctk -O2 -fsel-sched-pipelining -fschedule-insns
-fselective-scheduling2 small.c
[581] % ./a.out
Floating point exception
[582] % 
[582] % gcctk -O2 small.c; ./a.out
[583] % 
[583] % cat small.c
int printf(const char *, ...);
int a, d, e = -2;
char b;
long c = -2;
int main() {
  int g, h;
  d = e;
  g = c;
 L:
  h = d;
  c = 1;
  d = c % ~e;
  e = e >> ~g;
  if (e > b)
    printf("%ld", c);
  if (g > c)
    printf("%d", a);
  if (b)
    goto L;
  e = h;
  return 0;
}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug rtl-optimization/110391] [12/13/14 Regression] wrong code at -O2 and -O3 with "-fsel-sched-pipelining -fselective-scheduling2" on x86_64-linux-gnu
  2023-06-24 13:17 [Bug rtl-optimization/110391] New: wrong code at -O2 and -O3 with "on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (2 preceding siblings ...)
  2023-06-26  9:12 ` zhendong.su at inf dot ethz.ch
@ 2023-06-29  9:18 ` zhendong.su at inf dot ethz.ch
  2023-06-29 17:33 ` zhendong.su at inf dot ethz.ch
  2024-03-04  1:49 ` law at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2023-06-29  9:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
Another related reproducer. 

Compiler Explorer: https://godbolt.org/z/E8GPcfPY5


[543] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230629 (experimental) [master r14-924-gd709841ae0f] (GCC) 
[544] % 
[544] % gcctk -O2 -fselective-scheduling2 small.c
[545] % timeout -s 9 5 ./a.out
Killed
[546] % 
[546] % gcctk -O1 small.c; ./a.out
[547] % 
[547] % cat small.c
int printf(const char *, ...);
int a = -1, b = 1, *c = &a;
int main() {
  *c |= 1;
  if (a) {
  L:
    if (a < -1)
      printf("%d", 0);
    if (!b) {
      printf("%d", 1);
      goto L;
    }
    if (a > 0)
      goto L;
    b = 0;
  }
  return 0;
}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug rtl-optimization/110391] [12/13/14 Regression] wrong code at -O2 and -O3 with "-fsel-sched-pipelining -fselective-scheduling2" on x86_64-linux-gnu
  2023-06-24 13:17 [Bug rtl-optimization/110391] New: wrong code at -O2 and -O3 with "on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (3 preceding siblings ...)
  2023-06-29  9:18 ` zhendong.su at inf dot ethz.ch
@ 2023-06-29 17:33 ` zhendong.su at inf dot ethz.ch
  2024-03-04  1:49 ` law at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2023-06-29 17:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
Another likely related reproducer that affects 9.* and later.

Compiler Explorer: https://godbolt.org/z/8vTd7rx6d

[641] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230629 (experimental) [master r14-924-gd709841ae0f] (GCC) 
[642] % 
[642] % gcctk -O2 -fselective-scheduling2 -fno-tree-pre small.c
[643] % ./a.out
34
[644] % gcctk -O2 small.c
[645] % ./a.out
1
[646] % cat small.c
int printf(const char *, ...);
int a, b;
int main() {
  unsigned int c = 0;
  unsigned char d = 33;
  for (; a < 1; a++) {
    unsigned int e = 0;
    unsigned char f = 0;
    if (c < 1) {
      e = f = d;
      c = b * 4;
      if (c < b)
        printf("%ld", (long)d);
      if (!f)
        break;
    }
    c = e;
    d = f;
  }
  printf("%d\n", a);
  return 0;
}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug rtl-optimization/110391] [12/13/14 Regression] wrong code at -O2 and -O3 with "-fsel-sched-pipelining -fselective-scheduling2" on x86_64-linux-gnu
  2023-06-24 13:17 [Bug rtl-optimization/110391] New: wrong code at -O2 and -O3 with "on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (4 preceding siblings ...)
  2023-06-29 17:33 ` zhendong.su at inf dot ethz.ch
@ 2024-03-04  1:49 ` law at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-04  1:49 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey A. Law <law at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
                 CC|                            |law at gcc dot gnu.org

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-03-04  1:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-24 13:17 [Bug rtl-optimization/110391] New: wrong code at -O2 and -O3 with "on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
2023-06-24 13:20 ` [Bug rtl-optimization/110391] wrong code at -O2 and -O3 with "-fsel-sched-pipelining -fselective-scheduling2" on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
2023-06-24 15:23 ` [Bug rtl-optimization/110391] [12/13/14 Regression] " pinskia at gcc dot gnu.org
2023-06-26  9:12 ` zhendong.su at inf dot ethz.ch
2023-06-29  9:18 ` zhendong.su at inf dot ethz.ch
2023-06-29 17:33 ` zhendong.su at inf dot ethz.ch
2024-03-04  1:49 ` law 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).