On Wed, Nov 25, 2015 at 03:52:10PM +0100, Richard Biener wrote: > On Wed, Nov 25, 2015 at 2:18 PM, Michael Matz <m...@suse.de> wrote: > > Hi, > > > > On Wed, 25 Nov 2015, Richard Biener wrote: > > > >> I don't think so. Btw, if you want to add this please add a new gimple > >> predicate to identify "memory barrier" (any call or asm with a VDEF). > > > > if (is_gimple_call (stmt) && !nonfreeing_call_p (stmt)) > > nt_call_phase++; > > That looks bogus to me. It misses asm()s and at least today > nonfreeing_call_p too much checks what it sounds like it checks. > In practice it might work though. At least all the __sync_* and > __atomic_* calls are _not_ barriers this way. A pthread_mutex_lock is > though as we don't have a builtin for it. > > I'd change the above to a conservative > > if ((is_gimple_call (stmt) || is_gimple_asm (stmt)) && gimple_vuse (stmt))
nonfreeing_call_p is one necessary condition (if that is true, it means the call could mean that the first access does not trap while the second one does). But I agree that we need a predicate for nonbarrier_call_p or similar. Some atomic builtins are not barriers though and IMHO should not be treated as such, at least relaxed atomic loads/stores and pehraps even other relaxed atomics. And it would be nice to have IPA discovery of nonbarrier_call_p calls, like we have for nonfreeing_fn. Jakub