[committed] libstdc++: Add always_inline attribute to std::byte operators

Message ID 20220908183150.3290641-1-jwakely@redhat.com
State New, archived
Headers
Series [committed] libstdc++: Add always_inline attribute to std::byte operators |

Commit Message

Jonathan Wakely Sept. 8, 2022, 6:31 p.m. UTC
  These are all trivial bit-twiddling operations that don't need the
overhead of a function call in unoptimized code.

Tested powerpc64le-linux, pushed to trunk.

-- >8 --

libstdc++-v3/ChangeLog:

	* include/c_global/cstddef (byte): Add always_inline attribute
	to all operator overloads.
	(to_integer): Add always_inline attribute.
---
 libstdc++-v3/include/c_global/cstddef | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
  

Patch

diff --git a/libstdc++-v3/include/c_global/cstddef b/libstdc++-v3/include/c_global/cstddef
index 4970c2dfcfb..df2d88a2ce5 100644
--- a/libstdc++-v3/include/c_global/cstddef
+++ b/libstdc++-v3/include/c_global/cstddef
@@ -119,55 +119,66 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
     using __byte_op_t = typename __byte_operand<_IntegerType>::__type;
 
   template<typename _IntegerType>
+    [[__gnu__::__always_inline__]]
     constexpr __byte_op_t<_IntegerType>
     operator<<(byte __b, _IntegerType __shift) noexcept
     { return (byte)(unsigned char)((unsigned)__b << __shift); }
 
   template<typename _IntegerType>
+    [[__gnu__::__always_inline__]]
     constexpr __byte_op_t<_IntegerType>
     operator>>(byte __b, _IntegerType __shift) noexcept
     { return (byte)(unsigned char)((unsigned)__b >> __shift); }
 
+  [[__gnu__::__always_inline__]]
   constexpr byte
   operator|(byte __l, byte __r) noexcept
   { return (byte)(unsigned char)((unsigned)__l | (unsigned)__r); }
 
+  [[__gnu__::__always_inline__]]
   constexpr byte
   operator&(byte __l, byte __r) noexcept
   { return (byte)(unsigned char)((unsigned)__l & (unsigned)__r); }
 
+  [[__gnu__::__always_inline__]]
   constexpr byte
   operator^(byte __l, byte __r) noexcept
   { return (byte)(unsigned char)((unsigned)__l ^ (unsigned)__r); }
 
+  [[__gnu__::__always_inline__]]
   constexpr byte
   operator~(byte __b) noexcept
   { return (byte)(unsigned char)~(unsigned)__b; }
 
   template<typename _IntegerType>
+    [[__gnu__::__always_inline__]]
     constexpr __byte_op_t<_IntegerType>&
     operator<<=(byte& __b, _IntegerType __shift) noexcept
     { return __b = __b << __shift; }
 
   template<typename _IntegerType>
+    [[__gnu__::__always_inline__]]
     constexpr __byte_op_t<_IntegerType>&
     operator>>=(byte& __b, _IntegerType __shift) noexcept
     { return __b = __b >> __shift; }
 
+  [[__gnu__::__always_inline__]]
   constexpr byte&
   operator|=(byte& __l, byte __r) noexcept
   { return __l = __l | __r; }
 
+  [[__gnu__::__always_inline__]]
   constexpr byte&
   operator&=(byte& __l, byte __r) noexcept
   { return __l = __l & __r; }
 
+  [[__gnu__::__always_inline__]]
   constexpr byte&
   operator^=(byte& __l, byte __r) noexcept
   { return __l = __l ^ __r; }
 
   template<typename _IntegerType>
-    [[nodiscard]]
+    [[nodiscard,__gnu__::__always_inline__]]
     constexpr _IntegerType
     to_integer(__byte_op_t<_IntegerType> __b) noexcept
     { return _IntegerType(__b); }