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
This commit is contained in:
Jakub Jelinek 2019-01-10 11:56:56 +01:00 committed by Jakub Jelinek
parent dbf02a2cd6
commit 6cdf1946f6
2 changed files with 37 additions and 4 deletions

View 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

View 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;
}
};