On Tue, Apr 10, 2012 at 9:34 AM, Andi Kleen <a...@firstfloor.org> wrote: > "H.J. Lu" <hjl.to...@gmail.com> writes: > >>> So, to emit HLE prefix, it is possible to do: >>> int >>> foo2 (int *p, int oldv, int newv) >>> { >>> __atomic_compare_exchange_n (p, &oldv, newv, 0, __ATOMIC_ACQUIRE | >>> __ATOMIC_USE_HLE, __ATOMIC_ACQUIRE); >>> return oldv; >>> } >> >> This is wrong since HLE ACQUIRE/RELEASE has nothing to do with >> C++ atomic acquire/release. You can have HLE RELEASE with C++ >> atomic acquire. > > It makes sense to combine the two. On x86 C++ atomic acquire/release > means the compiler cannot move references outside. For HLE > we really want the same, otherwise some of the memory references > inside the transaction may not be transactional. > > So I think HLE_ACQUIRE should imply C++ acquire > and HLE_RELEASE imply C++ release. >
If it is the case, can we generate HLE RELEASE/ACQUIRE prefix automatically for C++ atomics via -mhle command line option. Then you don't need to modify the source codes to enable HLE support. -- H.J.