https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123636
Bug ID: 123636
Summary: [Trunk] miscompile at -O1
Product: gcc
Version: 16.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/z81sjd7Ph
Testcase:
#include <stdint.h>
#include <stdio.h>
uint64_t BS_CHECKSUM;
int32_t g_58, g_170;
int main()
{
for (int i = 0; i < 8; i++)
{
int64_t BS_VAR_0[9] = {};
uint64_t LOCAL_CHECKSUM = 0;
label:
g_58 = g_170 == 0;
for (uint32_t BS_TEMP_101 = 0; BS_TEMP_101 < 9; BS_TEMP_101++)
LOCAL_CHECKSUM ^= BS_VAR_0[BS_TEMP_101];
for (int32_t j = 0; j != 7; ++j)
for (int32_t k = 0; k >= 0; k--)
{
--g_170;
if (g_58) goto label;
BS_VAR_0[0] = 2;
}
BS_CHECKSUM += LOCAL_CHECKSUM;
}
printf("BackSmith Checksum = 0x%016llx\n", BS_CHECKSUM);
}
Output at -O0:
> BackSmith Checksum = 0x0000000000000000
Output at -O1:
> BackSmith Checksum = 0x0000000000000002