public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/107404] New: [12/13 Regression] Wrong code with -O3
@ 2022-10-26  0:40 vsevolod.livinskiy at gmail dot com
  2022-10-26  0:59 ` [Bug tree-optimization/107404] " pinskia at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: vsevolod.livinskiy at gmail dot com @ 2022-10-26  0:40 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107404
           Summary: [12/13 Regression] Wrong code with -O3
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vsevolod.livinskiy at gmail dot com
  Target Milestone: ---

Link to the Compiler Explorer: https://godbolt.org/z/jP6chErEY

The reproducer is a bit too big, but it's the best I was able to achieve with
Creduce, Cvise, and manual reduction. UBSan and ASan say that it is compliant
with the standard.

Reproducer:
#include <stdio.h>
unsigned long long a;
void b(unsigned long long *f, int p2) { *f ^= p2; }
long c;
char e, i;
short g, m;
long long ab[1][25][21][22];
unsigned long long aa[1][21][22];
unsigned long long ae[1][25][21][21];
long long ac[129360];
char ad[25][1][21];
char ah[1][25][1][21];
short af[100];
long max(long f, unsigned long p2) { return f < p2 ? p2 : f; }
const int &max2(const int &f, const int &p2) { return f < p2 ? p2 : f; }
void foo(unsigned f, unsigned p2, char l, char p4, long long n[][25][21][22],
        unsigned long long p6[][21][22], unsigned long long u[][25][21][21]) {
  long an;
  for (int j = 0; j < 4; j = p2)
    for (short k = 0; k < 7; k += 2)
      for (short o = 0; o < (short)p2 + 21742; o = l) {
        for (signed char p = 2; p < 9; p += p4)
          if (p6[j][o][p])
            for (long q(3); 4 ? n[0][k][o][0] : 0;
                 q += p6[0][o][0] ? p6[j][0][p] : 0)
              ac[j + q] = 5066799590;
        for (long r(p4 - 16); r < 21; r += 4) {
          ad[k][o][r] = max(u[j][k][o][r], f + u[j][k][o][r]);
          long d = u[j][k][o][r];
          an = d < p2 ? p2 : d;
          e = ah[j][k][o][r] = an;
          af[o * r] = i;
        }
        for (short s(c); s < (short)p2; s = 2)
          for (short am(m); am; am = max2(3, p2))
            for (long y = 0; y; y = 3)
              for (short t(0); t < max2(g, 0);)
                ;
      }
}
int main() {
  foo(7, 1558227751, 104, 16, ab, aa, ae);
  for (size_t v = 0; v < 5; ++v)
    for (size_t w = 0; w < 1; ++w)
      for (size_t x = 0; x < 21; ++x)
        b(&a, ad[v][w][x]);
  printf("%llu\n", a);
}

Error:
>$ g++ -O3 small.cpp && ./a.out 
28
>$ g++ -O0 small.cpp && ./a.out 
0

gcc version 13.0.0 20221025 (321f89e58510dd5df1b3dbe323344b987a7b11c6)

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

end of thread, other threads:[~2022-11-03 16:18 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-26  0:40 [Bug tree-optimization/107404] New: [12/13 Regression] Wrong code with -O3 vsevolod.livinskiy at gmail dot com
2022-10-26  0:59 ` [Bug tree-optimization/107404] " pinskia at gcc dot gnu.org
2022-10-26  1:07 ` pinskia at gcc dot gnu.org
2022-10-26  6:36 ` [Bug tree-optimization/107404] [12/13 Regression] Wrong code with -O3 since r12-6416-g037cc0b4a6646cc8 marxin at gcc dot gnu.org
2022-10-26  6:36 ` marxin at gcc dot gnu.org
2022-10-26  8:58 ` rsandifo at gcc dot gnu.org
2022-10-26  9:05 ` jakub at gcc dot gnu.org
2022-10-26 11:13 ` rsandifo at gcc dot gnu.org
2022-11-03  9:29 ` [Bug target/107404] " ubizjak at gmail dot com
2022-11-03 10:00 ` ubizjak at gmail dot com
2022-11-03 13:18 ` cvs-commit at gcc dot gnu.org
2022-11-03 16:13 ` cvs-commit at gcc dot gnu.org
2022-11-03 16:18 ` ubizjak at gmail dot com

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