[PATCH] D11382: x86 atomic: optimize a.store(reg op a.load(acquire), release)

JF Bastien jfb at chromium.org
Tue Jul 21 09:53:56 PDT 2015


jfb added a comment.

In http://reviews.llvm.org/D11382#208803, @dvyukov wrote:

> Will this optimization transform:
>
>   int foo() {
>      int r = atomic_load_n(&x, __ATOMIC_RELAXED);
>      atomic_store_n(&x, r+1, __ATOMIC_RELAXED);
>      return r;
>   }
>   
>
> ? If yes, how?


Good point, I added test `add_32r_self` to ensure that this doesn't happen, and that the pattern matching figures out dependencies properly.


http://reviews.llvm.org/D11382







More information about the llvm-commits mailing list