Issue 181002
Summary [AArch64] Wrong code at -O2
Labels backend:AArch64, miscompilation, generated by fuzzer
Assignees
Reporter XChy
    Reproducer: https://godbolt.org/z/KosfxK9ff
Testcase:
```c
#include <stdint.h>
#include <stdio.h>
#include <arm_neon.h>
#define BARRIER_v2u64(x) ((BS_VEC(uint64_t, 2))vqaddq_u64(x, (BS_VEC(uint64_t, 2)){}))
#define BS_VEC(type, num) type __attribute__((vector_size(num * sizeof(type))))
#define BITCAST(T, F, arg) \
    ((union { \
        F src; \
        T dst \
    })arg) \
        .dst
uint64_t BS_CHECKSUM;
void backsmith_checksum_4()
{
    int64_t BS_VAR_0 = 200366739780528840;
    uint64_t BS_VAR_3 = 0;
    int32_t BS_VAR_4 = 0;
 uint8_t BS_TEMP_479 =
        ~BITCAST(uint16_t, BS_VEC(uint8_t, 2),
 __builtin_convertvector(BARRIER_v2u64((BS_VEC(uint64_t, 2)){}),
 BS_VEC(uint8_t, 2)));
    for (uint8_t BS_INC_0; BS_INC_0 < BS_TEMP_479; BS_INC_0 += 1)
    {
 BS_VAR_3 = BS_VAR_4;
        BS_VAR_4 = BS_INC_0;
        BS_VAR_0 = 0;
 }
    BS_CHECKSUM ^= BS_VAR_0 ^= BS_VAR_3 + 9;
}
int main()
{
 backsmith_checksum_4();
    printf("BackSmith Checksum = 0x%016llx\n", BS_CHECKSUM);
}
```
The output at -O1:
```
BackSmith Checksum = 0x0000000000000106
```

The output at -O2:
```
BackSmith Checksum = 0x0000000000000105
```

Looks like a recent regression as clang 21.1.0 cannot reproduce it.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to