gcc/libstdc++-v3/testsuite/experimental
Jonathan Wakely 3c21913415 libstdc++: Optimise GCD algorithms
The current std::gcd and std::chrono::duration::_S_gcd algorithms are
both recursive. This is potentially expensive to evaluate in constant
expressions, because each level of recursion makes a new copy of the
function to evaluate. The maximum number of steps is bounded
(proportional to the number of decimal digits in the smaller value) and
so unlikely to exceed the limit for constexpr nesting, but the memory
usage is still suboptimal. By using an iterative algorithm we avoid
that compile-time cost. Because looping in constexpr functions is not
allowed until C++14, we need to keep the recursive implementation in
duration::_S_gcd for C++11 mode.

For std::gcd we can also optimise runtime performance by using the
binary GCD algorithm.

libstdc++-v3/ChangeLog:

	* include/std/chrono (duration::_S_gcd): Use iterative algorithm
	for C++14 and later.
	* include/std/numeric (__detail::__gcd): Replace recursive
	Euclidean algorithm with iterative version of binary GCD algorithm.
	* testsuite/26_numerics/gcd/1.cc: Test additional inputs.
	* testsuite/26_numerics/gcd/gcd_neg.cc: Adjust dg-error lines.
	* testsuite/26_numerics/lcm/lcm_neg.cc: Likewise.
	* testsuite/experimental/numeric/gcd.cc: Test additional inputs.
	* testsuite/26_numerics/gcd/2.cc: New test.
2020-09-03 12:46:13 +01:00
..
algorithm Update copyright years. 2020-01-01 12:51:42 +01:00
any Update copyright years. 2020-01-01 12:51:42 +01:00
array Update copyright years. 2020-01-01 12:51:42 +01:00
chrono Update copyright years. 2020-01-01 12:51:42 +01:00
deque Update copyright years. 2020-01-01 12:51:42 +01:00
filesystem libstdc++: Remove accidental -std=gnu++17 from test 2020-07-31 18:02:10 +01:00
forward_list Update copyright years. 2020-01-01 12:51:42 +01:00
functional Update copyright years. 2020-01-01 12:51:42 +01:00
iterator Update copyright years. 2020-01-01 12:51:42 +01:00
list Update copyright years. 2020-01-01 12:51:42 +01:00
map Update copyright years. 2020-01-01 12:51:42 +01:00
memory Update copyright years. 2020-01-01 12:51:42 +01:00
memory_resource x86-vxworks malloc aligns to 8 bytes like solaris 2020-05-13 04:49:00 -03:00
net libstdc++: Make Networking TS work without gthreads [PR 89760] 2020-08-11 16:16:22 +01:00
numeric libstdc++: Optimise GCD algorithms 2020-09-03 12:46:13 +01:00
optional PR libstdc++/95915 2020-06-29 00:36:38 +03:00
polymorphic_allocator Update copyright years. 2020-01-01 12:51:42 +01:00
propagate_const Update copyright years. 2020-01-01 12:51:42 +01:00
random Update copyright years. 2020-01-01 12:51:42 +01:00
ratio Update copyright years. 2020-01-01 12:51:42 +01:00
set Update copyright years. 2020-01-01 12:51:42 +01:00
source_location Update copyright years. 2020-01-01 12:51:42 +01:00
string Update copyright years. 2020-01-01 12:51:42 +01:00
string_view Update copyright years. 2020-01-01 12:51:42 +01:00
system_error Update copyright years. 2020-01-01 12:51:42 +01:00
tuple Update copyright years. 2020-01-01 12:51:42 +01:00
type_erased_allocator Update copyright years. 2020-01-01 12:51:42 +01:00
type_traits PR libstdc++/95915 2020-06-29 00:36:38 +03:00
unordered_map Update copyright years. 2020-01-01 12:51:42 +01:00
unordered_set Update copyright years. 2020-01-01 12:51:42 +01:00
vector Update copyright years. 2020-01-01 12:51:42 +01:00
feat-char8_t.cc
feat-cxx14.cc
feat-lib-fund.cc
names.cc Update copyright years. 2020-01-01 12:51:42 +01:00