On 2012-08-31 05:48, Andrew MacLeod wrote: > On 08/30/2012 07:04 PM, Richard Henderson wrote: >> Actually, we already have a memory barrier feature in rtl: >> >> ALIAS_SET_MEMORY_BARRIER >> >> but since we already set that in get_builtin_sync_mem, we'll need >> to figure out why that's no longer working. >> >> As far as I can tell from reading alias.c, we should already be >> indicating that such memories alias... >> >> What was the testcase again? I seem to have lost the top of the thread... >> >> > > #include <atomic> > using namespace std; > > atomic_uint a_8; > int32_t g_70; > int32_t g_141; > > int main (int, char *[]) { > a_8.load () & a_8.load (); > g_141 = g_70 != 0; > } > > or equivalently > > int a_8; > int g_70; > int g_141; > > int main () > { > __atomic_load_n (&a_8, __ATOMIC_SEQ_CST) & __atomic_load_n (&a_8, > __ATOMIC_SEQ_CST); > g_141 = g_70 != 0; > }
Fixed as follows. This seems to be the only entry point in alias.c that didn't take ALIAS_SET_MEMORY_BARRIER into account. Getting the above into a test case is tricky, and I havn't figured out how to match it. Full testing still underway, but I expect it to pass. r~
* alias.c (read_dependence): Account for ALIAS_SET_MEMORY_BARRIER. diff --git a/gcc/alias.c b/gcc/alias.c index e9d701f..5848e75 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -2132,7 +2132,12 @@ memrefs_conflict_p (int xsize, rtx x, int ysize, rtx y, HOST_WIDE_INT c) int read_dependence (const_rtx mem, const_rtx x) { - return MEM_VOLATILE_P (x) && MEM_VOLATILE_P (mem); + if (MEM_VOLATILE_P (x) && MEM_VOLATILE_P (mem)) + return true; + if (MEM_ALIAS_SET (x) == ALIAS_SET_MEMORY_BARRIER + || MEM_ALIAS_SET (mem) == ALIAS_SET_MEMORY_BARRIER) + return true; + return false; } /* Returns nonzero if something about the mode or address format MEM1