From: Jakub Jelinek Date: Thu, 10 Jan 2019 10:56:56 +0000 (+0100) Subject: re PR tree-optimization/88775 (Optimize std::string assignment) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6cdf1946f6eed116552026cfeb44a669ee882ccf;p=gcc.git re PR tree-optimization/88775 (Optimize std::string assignment) 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 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 7ab044b093a..4e248d46f18 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2019-01-10 Jakub Jelinek + + 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 PR other/16615 diff --git a/libstdc++-v3/include/bits/stl_function.h b/libstdc++-v3/include/bits/stl_function.h index 0d6c388fc6d..358b9aa5e72 100644 --- a/libstdc++-v3/include/bits/stl_function.h +++ b/libstdc++-v3/include/bits/stl_function.h @@ -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; } };