Bug 91240 - [8/9/10 Regression] Wrong code with -O3 due to unroll and jam pass
Summary: [8/9/10 Regression] Wrong code with -O3 due to unroll and jam pass
Status: RESOLVED DUPLICATE of bug 90796
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 10.0
: P2 normal
Target Milestone: 8.4
Assignee: Michael Matz
URL:
Keywords: wrong-code
Depends on:
Blocks: yarpgen
  Show dependency treegraph
 
Reported: 2019-07-23 21:20 UTC by Vsevolod Livinskii
Modified: 2021-11-01 23:07 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work: 7.4.0
Known to fail: 10.0, 8.3.0, 9.1.0
Last reconfirmed: 2019-07-24 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vsevolod Livinskii 2019-07-23 21:20:19 UTC
GCC produces wrong code with -O3.

Reproducer:

#include <stdio.h>

long long a;
int b[96][76];
int c[81];

void d(long long *e, int p2) { *e ^= p2; }

int main() {
  for (int f = 0; f < 80; ++f)
    for (int g = 0; g < 76; ++g)
      b[f][g] = c[f] = 9094;

  for (int f = 6; f <= 9; f++)
    for (int g = 6; g <= 75; g++)
      if (b[0][g])
        c[f + 1] *= f + (unsigned)c[f];

  printf("%d\n", c[8]);
}

Error:
>$ gcc -O3 small.c ; ./a.out
1637288310
>$ gcc -O0 small.c ; ./a.out
-2106497818

GCC version is 10.0.0 (Rev: 273743)
Comment 1 Martin Liška 2019-07-24 07:07:25 UTC
Confirmed, started with Michael's r255467.
Comment 2 Michael Matz 2019-08-05 14:11:58 UTC
Mine.
Comment 3 Michael Matz 2019-08-05 20:00:27 UTC
Also fixed by the patch at PR90796.
Comment 4 Jakub Jelinek 2019-11-20 11:38:53 UTC
Dup.

*** This bug has been marked as a duplicate of bug 90796 ***