https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126720
Bug ID: 126720
Summary: [15/16/17 Regression] wrong code with -O3
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/qMx8M31Pa
Testcase:
#include <stdint.h>
#define BITCAST(DST_TYPE, SRC_TYPE, VALUE)
\
(((union {
\
SRC_TYPE src;
\
DST_TYPE dst
\
})VALUE)
\
.dst)
typedef int16_t v2i16 __attribute__((vector_size(4)));
typedef uint16_t v2u16 __attribute__((vector_size(4)));
typedef uint32_t v2u32;
v2u32 g17;
uint8_t g29;
_Bool f6_a2;
int main()
{
uint16_t v9;
v2u16 bc16;
uint16_t v17 = 0;
lbl_cont8:
v9 = ~v17;
bc16 = (v2u16)0;
v17 = v9;
v9 = bc16[g29];
bc16 = BITCAST(v2u16, uint32_t, (uint32_t)v17);
bc16 = (v2i16)bc16 < 0;
v17 = 29834 >> v9;
bc16 = __builtin_shufflevector(bc16, bc16, 3, 1);
bc16 = ~bc16;
lbl_sw25:
bc16 = ~bc16;
lbl_bf33:
bc16 = ~bc16;
bc16[1] = ~v17;
lbl_br46:
switch (~BITCAST(uint32_t, v2u16, bc16))
{
case 1955201024: goto lbl_sw_def57;
case 4033962: goto lbl_sw53;
default: __builtin_unreachable();
}
lbl_sw53:
if (f6_a2) goto lbl_sw25;
goto lbl_cont8;
lbl_sw_def57:
bc16 = bc16 >= 0;
if (v9 == 3) return 0;
g17 = g17 > (v2u32){};
if (g29) goto lbl_br46;
}
This case triggers SIGSEGV at -O3.