Bug 115671 - [15 Regression] wrong code at -O1 with "-fgcse -fno-inline -fschedule-insns" on x86_64-linux-gnu
Summary: [15 Regression] wrong code at -O1 with "-fgcse -fno-inline -fschedule-insns" ...
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 15.0
: P3 normal
Target Milestone: 15.0
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2024-06-26 21:54 UTC by Zhendong Su
Modified: 2024-06-27 06:10 UTC (History)
1 user (show)

See Also:
Host:
Target: x86_64-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zhendong Su 2024-06-26 21:54:25 UTC
It seems to be a recent regression as it doesn't reproduce with 14.1. 

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

[648] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/15.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 --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240626 (experimental) (GCC) 
[649] % 
[649] % gcctk -O1 small.c; ./a.out
[650] % 
[650] % gcctk -O1 -fgcse -fno-inline -fschedule-insns small.c
[651] % ./a.out
Aborted
[652] % 
[652] % cat small.c
int printf(const char *, ...);
int a, b, c, d, e;
short f[2];
int g(int h, int i) { return 0; }
int j(int h, int i) { return i; }
void k() {
  int l;
  for (; b < 1; b++) {
    l = g(a, e);
    c = l < a;
    e = j(f[1 + b], 2);
    d = a || d;
    if (j(0, 1))
      return;
  }
}
int main() {
  k();
  if (c != 0)
    __builtin_abort();
  return 0;
}
Comment 1 Sam James 2024-06-27 03:44:22 UTC
I can't reproduce this with a GCC patched for PR115661.