llvm / llvm/llvm-project

Wrong code on x86-64 at -O2 -mavx2

Open
#218,382 5 comments 0 reactions 1 assignee Claimed by @el-ev View on GitHub
backend:X86 generated by fuzzer miscompilation
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Reproducer: https://godbolt.org/z/9ves5zW3b
Reduced case:
```c
#include
#define BITCAST(DST_TYPE, SRC_TYPE, VALUE) \
(union { \
SRC_TYPE src; \
DST_TYPE dst \
}){ VALUE } \
.dst
typedef uint32_t v2u32 __attribute__((vector_size(8)));
uint64_t g8, g16;
int main()
{
v2u32 bc7 = { 0, 3 };
bc7[0] = __builtin_parity(g16 % 4);
uint64_t v5 = BITCAST(uint64_t, v2u32, bc7);
g8 = 405633242997854673 % v5;
bc7[(uint8_t)v5] = 0;
g16 = bc7[0];
}
```

This case triggers SIGBUS at -O2 -mavx2, and terminates normally at -O0.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.