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

            Bug ID: 126560
           Summary: [15/16/17 Regression] wrong code at -O3 on aarch64
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xxs_chy at outlook dot com
  Target Milestone: ---

Reproducer: https://godbolt.org/z/MWrb9TYeq
Testcase:
#include <stdint.h>
#include <stdio.h>
#define BITCAST(DST_TYPE, SRC_TYPE, VALUE)                                    
\
    (union {                                                                  
\
        SRC_TYPE src;                                                         
\
        DST_TYPE dst                                                          
\
    }){ VALUE }                                                               
\
        .dst
typedef uint8_t v2u8 __attribute__((vector_size(2)));
uint16_t g1;
uint32_t g6;
uint16_t g7 = 7252;
uint8_t g10;
uint8_t g14;
void launch()
{
    _Bool c4 = g14;
    v2u8 bc6;
    if (g6 != 4) goto lbl_sw_def3;
lbl_sw2:
    bc6 = BITCAST(v2u8, uint16_t, g7);
    if ((int8_t)g10 == -8) goto lbl_br7;
    while (c4);
    g10 = (178 & g14) / 22;
    return;
lbl_sw_def3:
    if (4 != g1)
    {
        g14 = g7;
        goto lbl_sw2;
    }
lbl_br7:
    g1 = BITCAST(uint16_t, v2u8, bc6);
    goto lbl_sw_def3;
}
int main()
{
    launch();
    uint64_t __chk = g10;
    printf("checksum=0x%016llx\n", (unsigned long long)__chk);
}

This case outputs checksum=0x0000000000000000 at -O0, and outputs
checksum=0x0000000000000046 at -O3.

Reply via email to