From d375cf0dff09d27332cc061002475f74c7e365fa Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Tue, 4 Jul 2017 23:28:01 +0300 Subject: [PATCH] Modified 8 and 16-bit CAS loops to employ register renaming. --- .../boost/atomic/detail/extra_ops_gcc_x86.hpp | 7 ++++--- include/boost/atomic/detail/ops_gcc_x86.hpp | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/include/boost/atomic/detail/extra_ops_gcc_x86.hpp b/include/boost/atomic/detail/extra_ops_gcc_x86.hpp index b42d593..59b3906 100644 --- a/include/boost/atomic/detail/extra_ops_gcc_x86.hpp +++ b/include/boost/atomic/detail/extra_ops_gcc_x86.hpp @@ -15,7 +15,6 @@ #define BOOST_ATOMIC_DETAIL_EXTRA_OPS_GCC_X86_HPP_INCLUDED_ #include -#include #include #include #include @@ -116,9 +115,10 @@ struct extra_operations< Base, 1u, Signed > : { typedef gcc_x86_extra_operations_common< Base > base_type; typedef typename base_type::storage_type storage_type; + typedef typename make_storage_type< 4u, Signed >::type temp_storage_type; #define BOOST_ATOMIC_DETAIL_CAS_LOOP(op, result)\ - boost::uint32_t new_val;\ + temp_storage_type new_val;\ __asm__ __volatile__\ (\ ".align 16\n\t"\ @@ -431,9 +431,10 @@ struct extra_operations< Base, 2u, Signed > : { typedef gcc_x86_extra_operations_common< Base > base_type; typedef typename base_type::storage_type storage_type; + typedef typename make_storage_type< 4u, Signed >::type temp_storage_type; #define BOOST_ATOMIC_DETAIL_CAS_LOOP(op, result)\ - boost::uint32_t new_val;\ + temp_storage_type new_val;\ __asm__ __volatile__\ (\ ".align 16\n\t"\ diff --git a/include/boost/atomic/detail/ops_gcc_x86.hpp b/include/boost/atomic/detail/ops_gcc_x86.hpp index dafba33..8d51871 100644 --- a/include/boost/atomic/detail/ops_gcc_x86.hpp +++ b/include/boost/atomic/detail/ops_gcc_x86.hpp @@ -17,7 +17,6 @@ #define BOOST_ATOMIC_DETAIL_OPS_GCC_X86_HPP_INCLUDED_ #include -#include #include #include #include @@ -109,6 +108,7 @@ struct operations< 1u, Signed > : typedef gcc_x86_operations< typename make_storage_type< 1u, Signed >::type, operations< 1u, Signed > > base_type; typedef typename base_type::storage_type storage_type; typedef typename make_storage_type< 1u, Signed >::aligned aligned_storage_type; + typedef typename make_storage_type< 4u, Signed >::type temp_storage_type; static BOOST_CONSTEXPR_OR_CONST std::size_t storage_size = 1u; static BOOST_CONSTEXPR_OR_CONST bool is_signed = Signed; @@ -155,16 +155,16 @@ struct operations< 1u, Signed > : } #define BOOST_ATOMIC_DETAIL_CAS_LOOP(op, argument, result)\ - boost::uint32_t new_val;\ + temp_storage_type new_val;\ __asm__ __volatile__\ (\ ".align 16\n\t"\ - "1: movzbl %[arg], %2\n\t"\ + "1: mov %[arg], %2\n\t"\ op " %%al, %b2\n\t"\ "lock; cmpxchgb %b2, %[storage]\n\t"\ "jne 1b"\ : [res] "+a" (result), [storage] "+m" (storage), "=&q" (new_val)\ - : [arg] "q" (argument)\ + : [arg] "ir" ((temp_storage_type)argument)\ : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory"\ ) @@ -199,6 +199,7 @@ struct operations< 2u, Signed > : typedef gcc_x86_operations< typename make_storage_type< 2u, Signed >::type, operations< 2u, Signed > > base_type; typedef typename base_type::storage_type storage_type; typedef typename make_storage_type< 2u, Signed >::aligned aligned_storage_type; + typedef typename make_storage_type< 4u, Signed >::type temp_storage_type; static BOOST_CONSTEXPR_OR_CONST std::size_t storage_size = 2u; static BOOST_CONSTEXPR_OR_CONST bool is_signed = Signed; @@ -245,16 +246,16 @@ struct operations< 2u, Signed > : } #define BOOST_ATOMIC_DETAIL_CAS_LOOP(op, argument, result)\ - boost::uint32_t new_val;\ + temp_storage_type new_val;\ __asm__ __volatile__\ (\ ".align 16\n\t"\ - "1: movzwl %[arg], %2\n\t"\ + "1: mov %[arg], %2\n\t"\ op " %%ax, %w2\n\t"\ "lock; cmpxchgw %w2, %[storage]\n\t"\ "jne 1b"\ : [res] "+a" (result), [storage] "+m" (storage), "=&q" (new_val)\ - : [arg] "q" (argument)\ + : [arg] "ir" ((temp_storage_type)argument)\ : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory"\ ) @@ -339,12 +340,12 @@ struct operations< 4u, Signed > : __asm__ __volatile__\ (\ ".align 16\n\t"\ - "1: movl %[arg], %[new_val]\n\t"\ + "1: mov %[arg], %[new_val]\n\t"\ op " %%eax, %[new_val]\n\t"\ "lock; cmpxchgl %[new_val], %[storage]\n\t"\ "jne 1b"\ : [res] "+a" (result), [storage] "+m" (storage), [new_val] "=&r" (new_val)\ - : [arg] "r" (argument)\ + : [arg] "ir" (argument)\ : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC_COMMA "memory"\ )