public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/103031] New: [12 Regression] Missing static initializer folding with -frounding-math
@ 2021-11-01 20:44 jsm28 at gcc dot gnu.org
2021-11-01 20:47 ` [Bug middle-end/103031] " pinskia at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2021-11-01 20:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103031
Bug ID: 103031
Summary: [12 Regression] Missing static initializer folding
with -frounding-math
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: jsm28 at gcc dot gnu.org
CC: rguenth at gcc dot gnu.org
Target Milestone: ---
One of the recent fixes to avoid inappropriate constant folding with
-frounding-math caused the following test to produce an error when building
with -frounding-math. Static initializers in C are evaluated at translation
time, in the default rounding mode and with exceptions discarded;
-frounding-math should not affect this. Indeed, fold-const.c has
START_FOLD_INIT and END_FOLD_INIT that are supposed to be used for static
initializer folding to implement this, but apparently aren't being effective in
this case.
Test case:
double x = -1ULL;
Errors:
t.c:1:12: error: initializer element is not computable at load time
1 | double x = -1ULL;
| ^
Note: if the initializer is cast to double, things work fine; it's only the
case of implicit conversion that has the problem, so maybe something is handled
differently for folding an implicit conversion of a static initializer.
This breaks building glibc tests for some platforms:
https://sourceware.org/pipermail/libc-alpha/2021-October/132475.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/103031] [12 Regression] Missing static initializer folding with -frounding-math
2021-11-01 20:44 [Bug middle-end/103031] New: [12 Regression] Missing static initializer folding with -frounding-math jsm28 at gcc dot gnu.org
@ 2021-11-01 20:47 ` pinskia at gcc dot gnu.org
2021-11-02 7:43 ` [Bug c/103031] " rguenth at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-01 20:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103031
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=96862
Keywords| |rejects-valid
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The C++ front-end was changed to support this via PR 96862.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/103031] [12 Regression] Missing static initializer folding with -frounding-math
2021-11-01 20:44 [Bug middle-end/103031] New: [12 Regression] Missing static initializer folding with -frounding-math jsm28 at gcc dot gnu.org
2021-11-01 20:47 ` [Bug middle-end/103031] " pinskia at gcc dot gnu.org
@ 2021-11-02 7:43 ` rguenth at gcc dot gnu.org
2021-11-03 15:00 ` cvs-commit at gcc dot gnu.org
2021-11-03 15:01 ` jsm28 at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-11-02 7:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103031
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-11-02
Priority|P3 |P1
Status|UNCONFIRMED |NEW
Target Milestone|--- |12.0
Ever confirmed|0 |1
Component|middle-end |c
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
I suppose the frontend is calling fold_convert directly rather than
fold_build1_initializer (FLOAT_EXPR, ...).
The frontend ends up building this via
#0 0x0000000000d53d87 in convert_to_real_1 (
type=<real_type 0x7ffff6566348 double>, expr=<integer_cst 0x7ffff6544540>,
fold_p=true) at /home/rguenther/src/gcc3/gcc/convert.c:319
#1 0x0000000000d53f0a in convert_to_real (
type=<real_type 0x7ffff6566348 double>, expr=<integer_cst 0x7ffff6544540>)
at /home/rguenther/src/gcc3/gcc/convert.c:347
#2 0x0000000000b3cb90 in convert (type=<real_type 0x7ffff6566348 double>,
expr=<integer_cst 0x7ffff6544540>)
at /home/rguenther/src/gcc3/gcc/c/c-convert.c:138
#3 0x0000000000b9f602 in convert_and_check (loc=242464,
type=<real_type 0x7ffff6566348 double>, expr=<integer_cst 0x7ffff6544540>)
at /home/rguenther/src/gcc3/gcc/c-family/c-common.c:1767
#4 0x0000000000b1055e in convert_for_assignment (location=242464, expr_loc=0,
type=<real_type 0x7ffff6566348 double>, rhs=<integer_cst 0x7ffff6544540>,
origtype=<tree 0x0>, errtype=ic_init, null_pointer_constant=false,
fundecl=<tree 0x0>, function=<tree 0x0>, parmnum=0, warnopt=0)
at /home/rguenther/src/gcc3/gcc/c/c-typeck.c:7032
#5 0x0000000000b18c6e in digest_init (init_loc=242464,
type=<real_type 0x7ffff6566348 double>, init=<integer_cst 0x7ffff6544540>,
origtype=<tree 0x0>, null_pointer_constant=false, strict_string=true,
require_constant=1) at /home/rguenther/src/gcc3/gcc/c/c-typeck.c:8217
#6 0x0000000000b16df8 in store_init_value (init_loc=242464,
decl=<var_decl 0x7ffff7ff5c60 x>, init=<integer_cst 0x7ffff6544540>,
--Type <RET> for more, q to quit, c to continue without paging--
origtype=<tree 0x0>) at /home/rguenther/src/gcc3/gcc/c/c-typeck.c:7762
#7 0x0000000000ace0e7 in finish_decl (decl=<var_decl 0x7ffff7ff5c60 x>,
init_loc=242464, init=<integer_cst 0x7ffff6544540>, origtype=<tree 0x0>,
asmspec_tree=<tree 0x0>) at /home/rguenther/src/gcc3/gcc/c/c-decl.c:5363
maybe convert_for_assignment needs to do something similar as
START/END_FOLD_INIT around the convert_and_check or convert_for_assignment
is not the correct thing to call here. It's also odd that convert_to_real
says fold_p == true to convert_to_real_1 but that function doesn't actually
fold anything (maybe that's just all dead code). I'm quite sure that
initializer_constant_valid_p isn't the one that has to accept a FLOAT_EXPR
here.
C frontend maintainers need to sort this out.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/103031] [12 Regression] Missing static initializer folding with -frounding-math
2021-11-01 20:44 [Bug middle-end/103031] New: [12 Regression] Missing static initializer folding with -frounding-math jsm28 at gcc dot gnu.org
2021-11-01 20:47 ` [Bug middle-end/103031] " pinskia at gcc dot gnu.org
2021-11-02 7:43 ` [Bug c/103031] " rguenth at gcc dot gnu.org
@ 2021-11-03 15:00 ` cvs-commit at gcc dot gnu.org
2021-11-03 15:01 ` jsm28 at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-11-03 15:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103031
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Joseph Myers <jsm28@gcc.gnu.org>:
https://gcc.gnu.org/g:600dcd74b8e614c996b492d97878660faf484094
commit r12-4872-g600dcd74b8e614c996b492d97878660faf484094
Author: Joseph Myers <joseph@codesourcery.com>
Date: Wed Nov 3 14:58:25 2021 +0000
c: Fold implicit integer-to-floating conversions in static initializers
with -frounding-math [PR103031]
Recent fixes to avoid inappropriate folding of some conversions to
floating-point types with -frounding-math also prevented such folding
in C static initializers, when folding (in the default rounding mode,
exceptions discarded) is required for correctness.
Folding for static initializers is handled via functions in
fold-const.c calling START_FOLD_INIT and END_FOLD_INIT to adjust flags
such as flag_rounding_math that should not apply in static initializer
context, but no such function was being called for the folding of
these implicit conversions to the type of the object being
initialized, only for explicit conversions as part of the initializer.
Arrange for relevant folding (a fold call in convert, in particular)
to use this special initializer handling (via a new fold_init
function, in particular).
Because convert is used by language-independent code but defined in
each front end, this isn't as simple as just adding a new default
argument to it. Instead, I added a new convert_init function; that
then gets called by c-family code, and C and C++ need convert_init
implementations (the C++ one does nothing different from convert and
will never actually get called because the new convert_and_check
argument will never be true from C++), but other languages don't.
Bootstrapped with no regressions for x86_64-pc-linux-gnu.
gcc/
PR c/103031
* fold-const.c (fold_init): New function.
* fold-const.h (fold_init): New prototype.
gcc/c-family/
PR c/103031
* c-common.c (convert_and_check): Add argument init_const. Call
convert_init if init_const.
* c-common.h (convert_and_check): Update prototype.
(convert_init): New prototype.
gcc/c/
PR c/103031
* c-convert.c (c_convert): New function, based on convert.
(convert): Make into wrapper of c_convert.
(convert_init): New function.
* c-typeck.c (enum impl_conv): Add ic_init_const.
(convert_for_assignment): Handle ic_init_const like ic_init. Add
new argument to convert_and_check call.
(digest_init): Pass ic_init_const to convert_for_assignment for
initializers required to be constant.
gcc/cp/
PR c/103031
* cvt.c (convert_init): New function.
gcc/testsuite/
PR c/103031
* gcc.dg/init-rounding-math-1.c: New test.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/103031] [12 Regression] Missing static initializer folding with -frounding-math
2021-11-01 20:44 [Bug middle-end/103031] New: [12 Regression] Missing static initializer folding with -frounding-math jsm28 at gcc dot gnu.org
` (2 preceding siblings ...)
2021-11-03 15:00 ` cvs-commit at gcc dot gnu.org
@ 2021-11-03 15:01 ` jsm28 at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2021-11-03 15:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103031
Joseph S. Myers <jsm28 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #4 from Joseph S. Myers <jsm28 at gcc dot gnu.org> ---
Fixed for GCC 12.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-11-03 15:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-01 20:44 [Bug middle-end/103031] New: [12 Regression] Missing static initializer folding with -frounding-math jsm28 at gcc dot gnu.org
2021-11-01 20:47 ` [Bug middle-end/103031] " pinskia at gcc dot gnu.org
2021-11-02 7:43 ` [Bug c/103031] " rguenth at gcc dot gnu.org
2021-11-03 15:00 ` cvs-commit at gcc dot gnu.org
2021-11-03 15:01 ` jsm28 at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).