public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/115661] New: wrong code at -O{2,3} on x86_64-linux-gnu
@ 2024-06-26 10:06 zhendong.su at inf dot ethz.ch
  2024-06-26 10:14 ` [Bug tree-optimization/115661] " zhendong.su at inf dot ethz.ch
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2024-06-26 10:06 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115661
           Summary: wrong code at -O{2,3} on x86_64-linux-gnu
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This appears to be a recent regression as it doesn't reproduce with 14.1.

Compiler Explorer: https://godbolt.org/z/1dneGGoTE

[517] % 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) 
[518] % 
[518] % gcctk -O0 small.c; ./a.out
[519] % gcctk -O2 small.c
[520] % ./a.out
0
[521] % cat small.c
int printf(const char *, ...);
int a, b[6], c = 2, d, e = 446984904, *g, h, *i = &b[5];
int *m() {
  int *f = &c;
  if (d < 6)
    return &b[5];
  return f;
}
void n() {
  int j;
  for (; a < 1; a++)
    for (j = 0; j < 1; j++) {
      g = m();
      int k = *g;
      if (k) {
        int l = (3504049682 + e) & 3504049682;
        h = ~(k * l) * 7455084268;
        if (h > -1436818931) {
          printf("0\n");
          continue;
        }
        return;
      }
    }
}
int main() {
  *i = 1;
  n();
  return 0;
}

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

end of thread, other threads:[~2024-06-28 12:50 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-26 10:06 [Bug tree-optimization/115661] New: wrong code at -O{2,3} on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
2024-06-26 10:14 ` [Bug tree-optimization/115661] " zhendong.su at inf dot ethz.ch
2024-06-26 10:35 ` [Bug tree-optimization/115661] [15 Regression] " rguenth at gcc dot gnu.org
2024-06-26 11:29 ` sjames at gcc dot gnu.org
2024-06-26 11:34 ` [Bug tree-optimization/115661] [15 Regression] wrong code at -O{2,3} on x86_64-linux-gnu since r15-1599-g63512c72df09b4 sjames at gcc dot gnu.org
2024-06-26 12:27 ` sjames at gcc dot gnu.org
2024-06-26 13:30 ` [Bug target/115661] " rguenth at gcc dot gnu.org
2024-06-26 18:43 ` Evgeny.Karpov at microsoft dot com
2024-06-26 23:45 ` sjames at gcc dot gnu.org
2024-06-27  5:00 ` sjames at gcc dot gnu.org
2024-06-27  7:24 ` Evgeny.Karpov at microsoft dot com
2024-06-28 12:47 ` cvs-commit at gcc dot gnu.org
2024-06-28 12:50 ` clyon 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).