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

            Bug ID: 123298
           Summary: [9 - 16 Regression] X86-64: miscompile at -O3
           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/E1absroqG
Testcase:
#include <stdint.h>
#include <stdio.h>
#define BS_VEC(type, num) type __attribute__((vector_size(num)))
uint64_t BS_CHECKSUM;
int8_t g_64, func_1_BS_COND_11, g_858 = 1, g_258 = 50;
int32_t g_94;
int32_t *g_104 = &g_94;
uint8_t *g_576 = &g_258;
uint8_t **g_575 = &g_576;
int32_t **g_1280 = &g_104;
int32_t ***g_1279 = &g_1280;
int32_t **g_2045 = &g_104;
uint32_t func_1()
{
    BS_VEC(int32_t, 4) BS_VAR_1 = { 2062908036 };
    BS_VEC(int8_t, 16) BS_VAR_5 = { 6010899, 1035108901057810460 };
    if (func_1_BS_COND_11) goto BS_LABEL_0;
    uint64_t LOCAL_CHECKSUM = BS_VAR_1[0] = 0;
    for (; g_64 <= 5;)
    {
    BS_LABEL_0:
        for (;;)
        {
            for (uint32_t BS_TEMP_62 = 0; BS_TEMP_62 < 6; BS_TEMP_62++)
                for (uint32_t BS_TEMP_63 = 0; BS_TEMP_63 < 6; BS_TEMP_63++)
                    LOCAL_CHECKSUM ^=
                        BS_VAR_5[BS_TEMP_63] + LOCAL_CHECKSUM >> 2;
            ***g_1279 = (uint32_t)(**g_575 == 0) != g_858;
            if (**g_2045) break;
            int32_t l_2408 = BS_CHECKSUM += LOCAL_CHECKSUM;
            return l_2408;
        }
        BS_VAR_5[BS_VAR_1[0] < 5] = 0;
        for (g_258 = 0; 0;);
    }
}
int main()
{
    func_1();
    printf("BackSmith Checksum = 0x%016llx\n", BS_CHECKSUM);
}

Command:
> gcc -O3 test.c && ./a.out
> BackSmith Checksum = 0x000000000000000f

> gcc -O2 test.c && ./a.out
> BackSmith Checksum = 0x0000000000000001

Reply via email to