Bug 105621 - [13 Regression] Wrong code with -O3
Summary: [13 Regression] Wrong code with -O3
Status: RESOLVED DUPLICATE of bug 105613
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 13.0
: P3 normal
Target Milestone: 13.0
Assignee: Not yet assigned to anyone
URL:
Keywords: needs-bisection, wrong-code
Depends on:
Blocks: yarpgen
  Show dependency treegraph
 
Reported: 2022-05-16 19:03 UTC by Vsevolod Livinskii
Modified: 2022-05-17 10:50 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work: 12.0
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vsevolod Livinskii 2022-05-16 19:03:58 UTC
Link to the Compiler Explorer: https://godbolt.org/z/jscK4bTP6

Reproducer:
#include <stdio.h>

unsigned short a = (unsigned short)31272;
int b = -1902905271;
unsigned int c = 1618489477U;
bool d = (bool)0;

void test(unsigned short a, int b, unsigned c) __attribute__((noipa));
void test(unsigned short a, int b, unsigned c) {
  for (int i = 2; i < 24; i += 3)
    d = b ? a ? c : 2086607777901731118 : 0; 
}

int main() {
    test(a, b, c);
    printf("%d\n", (int)d);
    if (d != 1)
      __builtin_abort();
}

Error:
>$ g++ -O2 driver.cpp && ./a.out 
1
>$ g++ -O3 driver.cpp && ./a.out 
0
Aborted (core dumped)

GCC version 13.0.0 20220516 (69c4b5c519f0df37e4903992644cc29682721bc1)
Comment 1 Martin Liška 2022-05-17 10:50:32 UTC
Dup.

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