mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-29 16:21:07 +00:00
87c266d758
Complementing commit4a06ceea33
("sysdeps/ieee754/soft-fp: ignore maybe-uninitialized with -O [BZ #19444]") and commit27c5e756a2
("sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ #19444]") also fix compilation errors observed at -O1 in `__ddivl' and `__fdivl' with GCC 9 and RISC-V targets: In file included from ../soft-fp/soft-fp.h:318, from ../sysdeps/ieee754/soft-fp/s_fdivl.c:27: ../sysdeps/ieee754/soft-fp/s_fdivl.c: In function '__fdivl': ../soft-fp/op-2.h:108:9: error: 'R_f1' may be used uninitialized in this function [-Werror=maybe-uninitialized] 108 | : (X##_f1 << (2*_FP_W_TYPE_SIZE - (N)))) \ | ^ ../sysdeps/ieee754/soft-fp/s_fdivl.c:37:14: note: 'R_f1' was declared here 37 | FP_DECL_Q (R); | ^ ../soft-fp/op-common.h:39:3: note: in expansion of macro '_FP_FRAC_DECL_2' 39 | _FP_FRAC_DECL_##wc (X) | ^~~~~~~~~~~~~~ ../soft-fp/quad.h:226:24: note: in expansion of macro '_FP_DECL' 226 | # define FP_DECL_Q(X) _FP_DECL (2, X) | ^~~~~~~~ ../sysdeps/ieee754/soft-fp/s_fdivl.c:37:3: note: in expansion of macro 'FP_DECL_Q' 37 | FP_DECL_Q (R); | ^~~~~~~~~ ../soft-fp/op-2.h:109:8: error: 'R_f0' may be used uninitialized in this function [-Werror=maybe-uninitialized] 109 | | X##_f0) != 0)); \ | ^ ../sysdeps/ieee754/soft-fp/s_fdivl.c:37:14: note: 'R_f0' was declared here 37 | FP_DECL_Q (R); | ^ ../soft-fp/op-common.h:39:3: note: in expansion of macro '_FP_FRAC_DECL_2' 39 | _FP_FRAC_DECL_##wc (X) | ^~~~~~~~~~~~~~ ../soft-fp/quad.h:226:24: note: in expansion of macro '_FP_DECL' 226 | # define FP_DECL_Q(X) _FP_DECL (2, X) | ^~~~~~~~ ../sysdeps/ieee754/soft-fp/s_fdivl.c:37:3: note: in expansion of macro 'FP_DECL_Q' 37 | FP_DECL_Q (R); | ^~~~~~~~~ In file included from ../soft-fp/soft-fp.h:318, from ../sysdeps/ieee754/soft-fp/s_ddivl.c:31: ../sysdeps/ieee754/soft-fp/s_ddivl.c: In function '__ddivl': ../soft-fp/op-2.h:98:25: error: 'R_f1' may be used uninitialized in this function [-Werror=maybe-uninitialized] 98 | X##_f0 = (X##_f1 << (_FP_W_TYPE_SIZE - (N)) | X##_f0 >> (N) \ | ^~ ../sysdeps/ieee754/soft-fp/s_ddivl.c:41:14: note: 'R_f1' was declared here 41 | FP_DECL_Q (R); | ^ ../soft-fp/op-2.h:37:36: note: in definition of macro '_FP_FRAC_DECL_2' 37 | _FP_W_TYPE X##_f0 _FP_ZERO_INIT, X##_f1 _FP_ZERO_INIT | ^ ../soft-fp/quad.h:226:24: note: in expansion of macro '_FP_DECL' 226 | # define FP_DECL_Q(X) _FP_DECL (2, X) | ^~~~~~~~ ../sysdeps/ieee754/soft-fp/s_ddivl.c:41:3: note: in expansion of macro 'FP_DECL_Q' 41 | FP_DECL_Q (R); | ^~~~~~~~~ ../soft-fp/op-2.h:101:17: error: 'R_f0' may be used uninitialized in this function [-Werror=maybe-uninitialized] 101 | : (X##_f0 << (_FP_W_TYPE_SIZE - (N))) != 0)); \ | ^~ ../sysdeps/ieee754/soft-fp/s_ddivl.c:41:14: note: 'R_f0' was declared here 41 | FP_DECL_Q (R); | ^ ../soft-fp/op-2.h:37:14: note: in definition of macro '_FP_FRAC_DECL_2' 37 | _FP_W_TYPE X##_f0 _FP_ZERO_INIT, X##_f1 _FP_ZERO_INIT | ^ ../soft-fp/quad.h:226:24: note: in expansion of macro '_FP_DECL' 226 | # define FP_DECL_Q(X) _FP_DECL (2, X) | ^~~~~~~~ ../sysdeps/ieee754/soft-fp/s_ddivl.c:41:3: note: in expansion of macro 'FP_DECL_Q' 41 | FP_DECL_Q (R); | ^~~~~~~~~ cc1: all warnings being treated as errors make[2]: *** [.../sysd-rules:587: .../math/s_fdivl.o] Error 1 make[2]: *** Waiting for unfinished jobs.... cc1: all warnings being treated as errors make[2]: *** [.../sysd-rules:587: .../math/s_ddivl.o] Error 1 This comes from cases in _FP_DIV that return a result described as FP_CLS_ZERO or FP_CLS_INF and do not initialize the fractional part, which is then operated on unconditionally in FP_TRUNC_COOKED before being ignored by _FP_PACK_CANONICAL. Clearly at this optimization level GCC cannot guarantee to be able to determine that the fractional part is ultimately unused, so ignore the error as with the earlier commits referred, letting compilation proceed. [BZ #19444] * sysdeps/ieee754/soft-fp/s_ddivl.c (__ddivl): Ignore errors from `-Wmaybe-uninitialized'. * sysdeps/ieee754/soft-fp/s_fdivl.c (__fdivl): Likewise.
72 lines
2.2 KiB
C
72 lines
2.2 KiB
C
/* Divide long double (ldbl-128) values, narrowing the result to
|
|
double, using soft-fp.
|
|
Copyright (C) 2018-2019 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C 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
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
#define f32xdivf64x __hide_f32xdivf64x
|
|
#define f32xdivf128 __hide_f32xdivf128
|
|
#define f64divf64x __hide_f64divf64x
|
|
#define f64divf128 __hide_f64divf128
|
|
#include <math.h>
|
|
#undef f32xdivf64x
|
|
#undef f32xdivf128
|
|
#undef f64divf64x
|
|
#undef f64divf128
|
|
|
|
#include <math-narrow.h>
|
|
#include <libc-diag.h>
|
|
|
|
/* R_f[01] are not set in cases where they are not used in packing,
|
|
but the compiler does not see that they are set in all cases where
|
|
they are used, resulting in warnings that they may be used
|
|
uninitialized. The location of the warning differs in different
|
|
versions of GCC, it may be where R is defined using a macro or it
|
|
may be where the macro is defined. This happens only with -O1. */
|
|
DIAG_PUSH_NEEDS_COMMENT;
|
|
DIAG_IGNORE_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
|
|
#include <soft-fp.h>
|
|
#include <double.h>
|
|
#include <quad.h>
|
|
|
|
double
|
|
__ddivl (_Float128 x, _Float128 y)
|
|
{
|
|
FP_DECL_EX;
|
|
FP_DECL_Q (X);
|
|
FP_DECL_Q (Y);
|
|
FP_DECL_Q (R);
|
|
FP_DECL_D (RN);
|
|
double ret;
|
|
|
|
FP_INIT_ROUNDMODE;
|
|
FP_UNPACK_Q (X, x);
|
|
FP_UNPACK_Q (Y, y);
|
|
FP_DIV_Q (R, X, Y);
|
|
#if _FP_W_TYPE_SIZE < 64
|
|
FP_TRUNC_COOKED (D, Q, 2, 4, RN, R);
|
|
#else
|
|
FP_TRUNC_COOKED (D, Q, 1, 2, RN, R);
|
|
#endif
|
|
FP_PACK_D (ret, RN);
|
|
FP_HANDLE_EXCEPTIONS;
|
|
CHECK_NARROW_DIV (ret, x, y);
|
|
return ret;
|
|
}
|
|
DIAG_POP_NEEDS_COMMENT;
|
|
|
|
libm_alias_double_ldouble (div)
|