re PR tree-optimization/88775 (Optimize std::string assignment)
authorJakub Jelinek <jakub@redhat.com>
Thu, 10 Jan 2019 10:56:56 +0000 (11:56 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 10 Jan 2019 10:56:56 +0000 (11:56 +0100)
PR tree-optimization/88775
* include/bits/stl_function.h (greater<_Tp*>::operator(),
less<_Tp*>::operator(), greater_equal<_Tp*>::operator(),
less_equal<_Tp*>::operator()): Use __builtin_is_constant_evaluated
instead of __builtin_constant_p if available.  Don't bother with
the pointer comparison in C++11 and earlier.

From-SVN: r267800

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_function.h

index 7ab044b093a835cde34f2da17db0635773a65c1f..4e248d46f182dacc4e33bf1e892ca8a50198cdf2 100644 (file)
@@ -1,3 +1,12 @@
+2019-01-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/88775
+       * include/bits/stl_function.h (greater<_Tp*>::operator(),
+       less<_Tp*>::operator(), greater_equal<_Tp*>::operator(),
+       less_equal<_Tp*>::operator()): Use __builtin_is_constant_evaluated
+       instead of __builtin_constant_p if available.  Don't bother with
+       the pointer comparison in C++11 and earlier.
+
 2019-01-09  Sandra Loosemore  <sandra@codesourcery.com>
 
        PR other/16615
index 0d6c388fc6d4fb37ac3ca3126001b921f6ee9f27..358b9aa5e720426c43c1564220b0a781cc8fcef6 100644 (file)
@@ -413,8 +413,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       _GLIBCXX14_CONSTEXPR bool
       operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW
       {
-       if (__builtin_constant_p (__x > __y))
+#if __cplusplus >= 201402L
+#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
+       if (__builtin_is_constant_evaluated())
+#else
+       if (__builtin_constant_p(__x > __y))
+#endif
          return __x > __y;
+#endif
        return (__UINTPTR_TYPE__)__x > (__UINTPTR_TYPE__)__y;
       }
     };
@@ -426,8 +432,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       _GLIBCXX14_CONSTEXPR bool
       operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW
       {
-       if (__builtin_constant_p (__x < __y))
+#if __cplusplus >= 201402L
+#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
+       if (__builtin_is_constant_evaluated())
+#else
+       if (__builtin_constant_p(__x < __y))
+#endif
          return __x < __y;
+#endif
        return (__UINTPTR_TYPE__)__x < (__UINTPTR_TYPE__)__y;
       }
     };
@@ -439,8 +451,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       _GLIBCXX14_CONSTEXPR bool
       operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW
       {
-       if (__builtin_constant_p (__x >= __y))
+#if __cplusplus >= 201402L
+#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
+       if (__builtin_is_constant_evaluated())
+#else
+       if (__builtin_constant_p(__x >= __y))
+#endif
          return __x >= __y;
+#endif
        return (__UINTPTR_TYPE__)__x >= (__UINTPTR_TYPE__)__y;
       }
     };
@@ -452,8 +470,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       _GLIBCXX14_CONSTEXPR bool
       operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW
       {
-       if (__builtin_constant_p (__x <= __y))
+#if __cplusplus >= 201402L
+#ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
+       if (__builtin_is_constant_evaluated())
+#else
+       if (__builtin_constant_p(__x <= __y))
+#endif
          return __x <= __y;
+#endif
        return (__UINTPTR_TYPE__)__x <= (__UINTPTR_TYPE__)__y;
       }
     };