https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57359
--- Comment #28 from Richard Biener <rguenth at gcc dot gnu.org> --- OK, so more "advanced" testcases are a bit difficult because the ref_always_accessed_p logic is too simple and it's required for store-motion of accesses in conditional paths. Basically if we have if (test) { *p = 1; } else { *p = 0; } LIM doesn't figure *p is accessed unconditionally (that's a missed optimization). Anyway, here's a testcase circumventing that by using static storage and showing that conditionally executed SM (with and without -fallow-store-data-races) fail. It's supposed to be a testcase for a "merge" point of two different sequenced store sequences we need to check. typedef int A; typedef float B; float x[256]; void __attribute__((noinline,noclone)) foo(long unk, long ack) { B *q = x; for (long i = 0; i < unk; ++i) { if (ack & i) { *((A*)q + 4) = 1; q[i] = 42; } else { q[i] = 42; *((A*)q + 4) = 1; } } } int main(void) { foo(5, 6); if (x[4] != 42) __builtin_abort(); return 0; }