https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125250
Bug ID: 125250
Summary: [16/17 Regression] wrong code at -O1/2/3
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: xxs_chy at outlook dot com
Target Milestone: ---
Reproducer: https://godbolt.org/z/bTjnsz7M6
Testcase:
#include <stdint.h>
#include <stdio.h>
int16_t g0, __chk, g9, g6;
_Bool g1;
void *g4;
void __attribute__((noinline)) f5(_Bool a2, int32_t a5)
{
void *a1 = &a2;
lbl_br11:
*(_Bool *)a1 = 0;
a1 = &a5;
if (!a2)
{
g1 = *(_Bool *)g4;
if (g1)
{
g9 = -g9;
goto lbl_br11;
}
}
g6 = a5;
}
int main()
{
g4 = &g0;
f5(0, 8);
__chk = g6;
printf("checksum=0x%016llx\n", (unsigned long long)__chk);
}
This testcase prints 8 at -O0, while printing 0 at -O1/2/3.