https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97442
Bug ID: 97442 Summary: Wrong represenation of AArch64 saba in RTL Product: gcc Version: unknown Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: ktkachov at gcc dot gnu.org Target Milestone: --- Target: aarch64 This is similar to the issue fixed in https://gcc.gnu.org/git/?p=gcc.git&a=commit;h=8544ed6eea68a80999504c8a4b21b77d29cd86e2 The representation of the SABA (and UABA) in RTL is not correct and the below testcase will abort at -O3 -fwrapv: #define N 16 signed char a[] = {-100, -100, -100, -100,-100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100 }; signed char b[] = { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 }; signed char out[N] = { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 }; __attribute__ ((noinline,noipa)) void foo (void) { for (int i = 0; i < N; i++) { signed char diff = b[i] - a[i]; out[i] += diff > 0 ? diff : -diff; } } signed char out2[N] = { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 }; __attribute__ ((noinline,noipa)) void foo_scalar (void) { for (int i = 0; i < N; i++) { asm volatile (""); signed char diff = b[i] - a[i]; out2[i] += diff > 0 ? diff : -diff; } } int main (void) { foo (); foo_scalar (); for (int i = 0; i < N; i++) if (out[i] != out2[i]) __builtin_abort (); return 0; } due to function foo generating a saba when it shouldn't