libstdc++: Minor codegen improvement for atomic wait spinloop
This patch merges the spin loops in the atomic wait implementation which is a minor codegen improvement. libstdc++-v3/ChangeLog: * include/bits/atomic_wait.h (__atomic_spin): Merge spin loops.
This commit is contained in:
parent
db613e8fa8
commit
e75da2ace6
1 changed files with 7 additions and 10 deletions
|
@ -142,8 +142,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
#endif
|
||||
}
|
||||
|
||||
constexpr auto __atomic_spin_count_1 = 12;
|
||||
constexpr auto __atomic_spin_count_2 = 4;
|
||||
constexpr auto __atomic_spin_count_relax = 12;
|
||||
constexpr auto __atomic_spin_count = 16;
|
||||
|
||||
struct __default_spin_policy
|
||||
{
|
||||
|
@ -157,18 +157,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
bool
|
||||
__atomic_spin(_Pred& __pred, _Spin __spin = _Spin{ }) noexcept
|
||||
{
|
||||
for (auto __i = 0; __i < __atomic_spin_count_1; ++__i)
|
||||
for (auto __i = 0; __i < __atomic_spin_count; ++__i)
|
||||
{
|
||||
if (__pred())
|
||||
return true;
|
||||
__detail::__thread_relax();
|
||||
}
|
||||
|
||||
for (auto __i = 0; __i < __atomic_spin_count_2; ++__i)
|
||||
{
|
||||
if (__pred())
|
||||
return true;
|
||||
__detail::__thread_yield();
|
||||
if (__i < __atomic_spin_count_relax)
|
||||
__detail::__thread_relax();
|
||||
else
|
||||
__detail::__thread_yield();
|
||||
}
|
||||
|
||||
while (__spin())
|
||||
|
|
Loading…
Add table
Reference in a new issue