This commit is contained in:
Jakub Jelinek 2022-11-21 11:17:13 +01:00
parent 146fdc1878
commit 0af622a16d
4 changed files with 140 additions and 4 deletions

1
.gitignore vendored
View File

@ -79,3 +79,4 @@
/isl-0.24.tar.bz2 /isl-0.24.tar.bz2
/newlib-cygwin-a8526cb52bedabd4d6ba4b227a5185627f871aa1.tar.xz /newlib-cygwin-a8526cb52bedabd4d6ba4b227a5185627f871aa1.tar.xz
/nvptx-tools-472b6e78b3ba918d727698f79911360b7c808247.tar.xz /nvptx-tools-472b6e78b3ba918d727698f79911360b7c808247.tar.xz
/gcc-12.2.1-20221121.tar.xz

View File

@ -1,10 +1,10 @@
%global DATE 20221103 %global DATE 20221121
%global gitrev fa08f2733eed2cb77bf0d6bd86a74399be68b5a2 %global gitrev b3f5a0d53b84ed27cf00cfa2b9c3e2c78935c07d
%global gcc_version 12.2.1 %global gcc_version 12.2.1
%global gcc_major 12 %global gcc_major 12
# Note, gcc_release must be integer, if you want to add suffixes to # Note, gcc_release must be integer, if you want to add suffixes to
# %%{release}, append them after %%{gcc_release} on Release: line. # %%{release}, append them after %%{gcc_release} on Release: line.
%global gcc_release 3 %global gcc_release 4
%global nvptx_tools_gitrev 472b6e78b3ba918d727698f79911360b7c808247 %global nvptx_tools_gitrev 472b6e78b3ba918d727698f79911360b7c808247
%global newlib_cygwin_gitrev a8526cb52bedabd4d6ba4b227a5185627f871aa1 %global newlib_cygwin_gitrev a8526cb52bedabd4d6ba4b227a5185627f871aa1
%global _unpackaged_files_terminate_build 0 %global _unpackaged_files_terminate_build 0
@ -275,6 +275,7 @@ Patch8: gcc12-no-add-needed.patch
Patch9: gcc12-Wno-format-security.patch Patch9: gcc12-Wno-format-security.patch
Patch10: gcc12-rh1574936.patch Patch10: gcc12-rh1574936.patch
Patch11: gcc12-d-shared-libphobos.patch Patch11: gcc12-d-shared-libphobos.patch
Patch12: gcc12-pr107468.patch
Patch100: gcc12-fortran-fdec-duplicates.patch Patch100: gcc12-fortran-fdec-duplicates.patch
Patch101: gcc12-fortran-flogical-as-integer.patch Patch101: gcc12-fortran-flogical-as-integer.patch
@ -802,6 +803,7 @@ so that there cannot be any synchronization problems.
%patch10 -p0 -b .rh1574936~ %patch10 -p0 -b .rh1574936~
%endif %endif
%patch11 -p0 -b .d-shared-libphobos~ %patch11 -p0 -b .d-shared-libphobos~
%patch12 -p0 -b .pr107468~
%if 0%{?rhel} >= 9 %if 0%{?rhel} >= 9
%patch100 -p1 -b .fortran-fdec-duplicates~ %patch100 -p1 -b .fortran-fdec-duplicates~
@ -3213,6 +3215,15 @@ end
%endif %endif
%changelog %changelog
* Mon Nov 21 2022 Jakub Jelinek <jakub@redhat.com> 12.2.1-4
- update from releases/gcc-12 branch
- PRs c++/104066, c++/105774, c++/106829, c++/107358, c/41041, c/106981,
c/107001, libstdc++/95048, libstdc++/103295, target/104688,
target/107183, target/107304, target/107404, target/107713,
target/107748, tree-optimization/107121, tree-optimization/107206
- fix up std::from_chars behavior in rounding modes other than FE_TONEAREST
(PR libstdc++/107468)
* Thu Nov 3 2022 Jakub Jelinek <jakub@redhat.com> 12.2.1-3 * Thu Nov 3 2022 Jakub Jelinek <jakub@redhat.com> 12.2.1-3
- update from releases/gcc-12 branch - update from releases/gcc-12 branch
- PRs c++/93259, c++/105774, c++/106759, c++/106829, c++/106893, c++/106925, - PRs c++/93259, c++/105774, c++/106759, c++/106829, c++/106893, c++/106925,

124
gcc12-pr107468.patch Normal file
View File

@ -0,0 +1,124 @@
libstdc++: Update from latest fast_float [PR107468]
The following patch is a cherry-pick from
https://github.com/fastfloat/fast_float/pull/153
to restrict fast_float Clinger's fast path to when rounding mode
is FE_TONEAREST.
Using std::fegetround showed in benchmarks too slow, so instead
it uses a check with 2 float additions and comparison to verify
if rounding is FE_TONEAREST.
2022-11-20 Jakub Jelinek <jakub@redhat.com>
PR libstdc++/107468
* src/c++17/fast_float/fast_float.h (detail::rounds_to_nearest): New
function, taken from https://github.com/fastfloat/fast_float/pull/153.
(from_chars_advanced): Only use Clinger's fast path if
detail::rounds_to_nearest().
* testsuite/20_util/from_chars/pr107468.cc: New test.
--- libstdc++-v3/src/c++17/fast_float/fast_float.h.jj 2022-04-28 15:56:18.315632888 +0200
+++ libstdc++-v3/src/c++17/fast_float/fast_float.h 2022-11-20 18:53:49.570830249 +0100
@@ -2842,6 +2842,48 @@ from_chars_result parse_infnan(const cha
return answer;
}
+/**
+ * Returns true if the floating-pointing rounding mode is to 'nearest'.
+ * It is the default on most system. This function is meant to be inexpensive.
+ * Credit : @mwalcott3
+ */
+fastfloat_really_inline bool rounds_to_nearest() noexcept {
+ // See
+ // A fast function to check your floating-point rounding mode
+ // https://lemire.me/blog/2022/11/16/a-fast-function-to-check-your-floating-point-rounding-mode/
+ //
+ // This function is meant to be equivalent to :
+ // prior: #include <cfenv>
+ // return fegetround() == FE_TONEAREST;
+ // However, it is expected to be much faster than the fegetround()
+ // function call.
+ //
+ // The volatile keywoard prevents the compiler from computing the function
+ // at compile-time.
+ // There might be other ways to prevent compile-time optimizations (e.g., asm).
+ // The value does not need to be std::numeric_limits<float>::min(), any small
+ // value so that 1 + x should round to 1 would do (after accounting for excess
+ // precision, as in 387 instructions).
+ static volatile float fmin = std::numeric_limits<float>::min();
+ float fmini = fmin; // we copy it so that it gets loaded at most once.
+ //
+ // Explanation:
+ // Only when fegetround() == FE_TONEAREST do we have that
+ // fmin + 1.0f == 1.0f - fmin.
+ //
+ // FE_UPWARD:
+ // fmin + 1.0f > 1
+ // 1.0f - fmin == 1
+ //
+ // FE_DOWNWARD or FE_TOWARDZERO:
+ // fmin + 1.0f == 1
+ // 1.0f - fmin < 1
+ //
+ // Note: This may fail to be accurate if fast-math has been
+ // enabled, as rounding conventions may not apply.
+ return (fmini + 1.0f == 1.0f - fmini);
+}
+
} // namespace detail
template<typename T>
@@ -2870,7 +2912,7 @@ from_chars_result from_chars_advanced(co
answer.ec = std::errc(); // be optimistic
answer.ptr = pns.lastmatch;
// Next is Clinger's fast path.
- if (binary_format<T>::min_exponent_fast_path() <= pns.exponent && pns.exponent <= binary_format<T>::max_exponent_fast_path() && pns.mantissa <=binary_format<T>::max_mantissa_fast_path() && !pns.too_many_digits) {
+ if (binary_format<T>::min_exponent_fast_path() <= pns.exponent && pns.exponent <= binary_format<T>::max_exponent_fast_path() && pns.mantissa <=binary_format<T>::max_mantissa_fast_path() && !pns.too_many_digits && detail::rounds_to_nearest()) {
value = T(pns.mantissa);
if (pns.exponent < 0) { value = value / binary_format<T>::exact_power_of_ten(-pns.exponent); }
else { value = value * binary_format<T>::exact_power_of_ten(pns.exponent); }
--- libstdc++-v3/testsuite/20_util/from_chars/pr107468.cc.jj
+++ libstdc++-v3/testsuite/20_util/from_chars/pr107468.cc
@@ -0,0 +1,42 @@
+// Copyright (C) 2022 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do run { target c++17 } }
+// { dg-add-options ieee }
+
+#include <charconv>
+#include <string>
+#include <cfenv>
+#include <testsuite_hooks.h>
+
+int
+main()
+{
+ // FP from_char not available otherwise.
+#if __cpp_lib_to_chars >= 201611L \
+ && _GLIBCXX_USE_C99_FENV_TR1 \
+ && defined(FE_DOWNWARD) \
+ && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
+ // PR libstdc++/107468
+ float f;
+ char buf[] = "3.355447e+07";
+ std::fesetround(FE_DOWNWARD);
+ auto [ptr, ec] = std::from_chars(buf, buf + sizeof(buf) - 1, f, std::chars_format::scientific);
+ VERIFY( ec == std::errc() && ptr == buf + sizeof(buf) - 1 );
+ VERIFY( f == 33554472.0f );
+#endif
+}

View File

@ -1,4 +1,4 @@
SHA512 (gcc-12.2.1-20221103.tar.xz) = d9bf5b5c15b91bbdb3f39f4841e3370191fbc89c0d0cd4723609b9e94fbc1969895737435833c4c884d1035e7b7c597e3209316c40f18aac3366d62caa9791f6 SHA512 (gcc-12.2.1-20221121.tar.xz) = 6fef1438e77d8b7e7aeddea6d2d6a82c37d2e93f65ad9007f04206e1a368dd70597cef01188de4ee9bbfe1811a129303ce10b49cb9758a2b44abe4f0312d073a
SHA512 (isl-0.24.tar.bz2) = aab3bddbda96b801d0f56d2869f943157aad52a6f6e6a61745edd740234c635c38231af20bc3f1a08d416a5e973a90e18249078ed8e4ae2f1d5de57658738e95 SHA512 (isl-0.24.tar.bz2) = aab3bddbda96b801d0f56d2869f943157aad52a6f6e6a61745edd740234c635c38231af20bc3f1a08d416a5e973a90e18249078ed8e4ae2f1d5de57658738e95
SHA512 (newlib-cygwin-a8526cb52bedabd4d6ba4b227a5185627f871aa1.tar.xz) = b099246fe4a5d0a372cdaee5da49083df5b2f4440a4e83961600cdf22d37da50c99ce9ae46b769f188a67034ee038cf863260988fc9d594e8e5fb3905a381dec SHA512 (newlib-cygwin-a8526cb52bedabd4d6ba4b227a5185627f871aa1.tar.xz) = b099246fe4a5d0a372cdaee5da49083df5b2f4440a4e83961600cdf22d37da50c99ce9ae46b769f188a67034ee038cf863260988fc9d594e8e5fb3905a381dec
SHA512 (nvptx-tools-472b6e78b3ba918d727698f79911360b7c808247.tar.xz) = 91690321bf96460c3b3e229199a6f752ed1c27c6933d4345dc7e237dc068f604ad211bb3a0373e14d4f332bee05b6227d6933e14e0b475ffdfea8b511ab735e6 SHA512 (nvptx-tools-472b6e78b3ba918d727698f79911360b7c808247.tar.xz) = 91690321bf96460c3b3e229199a6f752ed1c27c6933d4345dc7e237dc068f604ad211bb3a0373e14d4f332bee05b6227d6933e14e0b475ffdfea8b511ab735e6