public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/111916] New: wrong code at -O1 and above on x86_64-linux-gnu (the generated code hangs)
@ 2023-10-22 5:52 zhendong.su at inf dot ethz.ch
2023-10-22 13:04 ` [Bug tree-optimization/111916] [14 Regression] " tkoenig at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2023-10-22 5:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111916
Bug ID: 111916
Summary: wrong code at -O1 and above on x86_64-linux-gnu (the
generated code hangs)
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: zhendong.su at inf dot ethz.ch
Target Milestone: ---
This appears to be a recent regression.
Compiler Explorer: https://godbolt.org/z/aEEKbdY6E
[563] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20231022 (experimental) (GCC)
[564] %
[564] % gcctk -O0 small.c; ./a.out
[565] %
[565] % gcctk -O1 small.c
[566] % timeout -s 9 5 ./a.out
Killed
[567] %
[567] % cat small.c
#pragma pack(1)
struct A {
int b : 4;
int c : 11;
int d : 2;
int e : 5;
} f;
int main() {
struct A g = {1, 1, 1, 1};
while (!g.b)
f = g;
return 0;
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/111916] [14 Regression] wrong code at -O1 and above on x86_64-linux-gnu (the generated code hangs)
2023-10-22 5:52 [Bug tree-optimization/111916] New: wrong code at -O1 and above on x86_64-linux-gnu (the generated code hangs) zhendong.su at inf dot ethz.ch
@ 2023-10-22 13:04 ` tkoenig at gcc dot gnu.org
2023-10-22 16:15 ` sjames at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2023-10-22 13:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111916
Thomas Koenig <tkoenig at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|wrong code at -O1 and above |[14 Regression] wrong code
|on x86_64-linux-gnu (the |at -O1 and above on
|generated code hangs) |x86_64-linux-gnu (the
| |generated code hangs)
CC| |tkoenig at gcc dot gnu.org
Keywords| |wrong-code
Target Milestone|--- |14.0
--- Comment #1 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Also occurs on POWER, so likely target-independent. Does not happen
for 13.2.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/111916] [14 Regression] wrong code at -O1 and above on x86_64-linux-gnu (the generated code hangs)
2023-10-22 5:52 [Bug tree-optimization/111916] New: wrong code at -O1 and above on x86_64-linux-gnu (the generated code hangs) zhendong.su at inf dot ethz.ch
2023-10-22 13:04 ` [Bug tree-optimization/111916] [14 Regression] " tkoenig at gcc dot gnu.org
@ 2023-10-22 16:15 ` sjames at gcc dot gnu.org
2023-10-22 16:25 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-10-22 16:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111916
--- Comment #2 from Sam James <sjames at gcc dot gnu.org> ---
I'll bisect.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/111916] [14 Regression] wrong code at -O1 and above on x86_64-linux-gnu (the generated code hangs)
2023-10-22 5:52 [Bug tree-optimization/111916] New: wrong code at -O1 and above on x86_64-linux-gnu (the generated code hangs) zhendong.su at inf dot ethz.ch
2023-10-22 13:04 ` [Bug tree-optimization/111916] [14 Regression] " tkoenig at gcc dot gnu.org
2023-10-22 16:15 ` sjames at gcc dot gnu.org
@ 2023-10-22 16:25 ` pinskia at gcc dot gnu.org
2023-10-22 16:48 ` [Bug tree-optimization/111916] [14 Regression] wrong code at -O1 and above on x86_64-linux-gnu (the generated code hangs) since r14-4612-g6decda1a35be5764101987c210b5693a0d914e58 sjames at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-22 16:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111916
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
CC| |pinskia at gcc dot gnu.org,
| |rguenth at gcc dot gnu.org
Last reconfirmed| |2023-10-22
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
Either r14-4677-g3aaf704bca3e01c72d9fe6de01ae5416dba6b5db or
r14-4612-g6decda1a35be5764101987c210b5693a0d914e58 .
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/111916] [14 Regression] wrong code at -O1 and above on x86_64-linux-gnu (the generated code hangs) since r14-4612-g6decda1a35be5764101987c210b5693a0d914e58
2023-10-22 5:52 [Bug tree-optimization/111916] New: wrong code at -O1 and above on x86_64-linux-gnu (the generated code hangs) zhendong.su at inf dot ethz.ch
` (2 preceding siblings ...)
2023-10-22 16:25 ` pinskia at gcc dot gnu.org
@ 2023-10-22 16:48 ` sjames at gcc dot gnu.org
2023-10-23 9:18 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-10-22 16:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111916
Sam James <sjames at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[14 Regression] wrong code |[14 Regression] wrong code
|at -O1 and above on |at -O1 and above on
|x86_64-linux-gnu (the |x86_64-linux-gnu (the
|generated code hangs) |generated code hangs) since
| |r14-4612-g6decda1a35be57641
| |01987c210b5693a0d914e58
--- Comment #4 from Sam James <sjames at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #3)
> Confirmed.
>
>
> Either r14-4677-g3aaf704bca3e01c72d9fe6de01ae5416dba6b5db or
> r14-4612-g6decda1a35be5764101987c210b5693a0d914e58 .
yep, r14-4612-g6decda1a35be5764101987c210b5693a0d914e58
6decda1a35be5764101987c210b5693a0d914e58 is the first bad commit
commit 6decda1a35be5764101987c210b5693a0d914e58
Author: Richard Biener <rguenther@suse.de>
Date: Thu Oct 12 11:34:57 2023 +0200
tree-optimization/111779 - Handle some BIT_FIELD_REFs in SRA
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/111916] [14 Regression] wrong code at -O1 and above on x86_64-linux-gnu (the generated code hangs) since r14-4612-g6decda1a35be5764101987c210b5693a0d914e58
2023-10-22 5:52 [Bug tree-optimization/111916] New: wrong code at -O1 and above on x86_64-linux-gnu (the generated code hangs) zhendong.su at inf dot ethz.ch
` (3 preceding siblings ...)
2023-10-22 16:48 ` [Bug tree-optimization/111916] [14 Regression] wrong code at -O1 and above on x86_64-linux-gnu (the generated code hangs) since r14-4612-g6decda1a35be5764101987c210b5693a0d914e58 sjames at gcc dot gnu.org
@ 2023-10-23 9:18 ` rguenth at gcc dot gnu.org
2023-10-23 12:08 ` rguenth at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-10-23 9:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111916
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org
Status|NEW |ASSIGNED
Version|unknown |14.0
Priority|P3 |P1
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
I will have a look.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/111916] [14 Regression] wrong code at -O1 and above on x86_64-linux-gnu (the generated code hangs) since r14-4612-g6decda1a35be5764101987c210b5693a0d914e58
2023-10-22 5:52 [Bug tree-optimization/111916] New: wrong code at -O1 and above on x86_64-linux-gnu (the generated code hangs) zhendong.su at inf dot ethz.ch
` (4 preceding siblings ...)
2023-10-23 9:18 ` rguenth at gcc dot gnu.org
@ 2023-10-23 12:08 ` rguenth at gcc dot gnu.org
2023-10-23 13:33 ` cvs-commit at gcc dot gnu.org
2023-10-23 13:33 ` rguenth at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-10-23 12:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111916
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jamborm at gcc dot gnu.org
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
ESRA does
int main ()
{
+ unsigned char g;
struct A g;
unsigned char _1;
unsigned char _2;
<bb 2> :
g = *.LC0;
+ g_6 = BIT_FIELD_REF <*.LC0, 8, 0>;
goto <bb 4>; [INV]
<bb 3> :
+ BIT_FIELD_REF <g, 8, 0> = g_6;
f = g;
<bb 4> :
- _1 = BIT_FIELD_REF <g, 8, 0>;
+ _1 = g_6;
_2 = _1 & 15;
if (_2 == 0)
goto <bb 3>; [INV]
which looks OK, but then SRA does
+ unsigned char SR.5;
+ unsigned char g;
unsigned char g;
struct A g;
unsigned char _1;
unsigned char _11;
<bb 2> [local count: 118111600]:
+ SR.5_10 = SR.5_2(D);
g = *.LC0;
- g_5 = BIT_FIELD_REF <*.LC0, 8, 0>;
+ g_14 = SR.5_10;
+ g_5 = SR.5_10;
_11 = g_5 & 15;
if (_11 == 0)
goto <bb 3>; [0.00%]
@@ -19,6 +33,8 @@
<bb 3> [local count: 955630224]:
BIT_FIELD_REF <g, 8, 0> = g_5;
+ g_16 = MEM <unsigned char> [(struct A *)&g];
+ MEM <unsigned char> [(struct A *)&g] = g_16;
f = g;
_1 = g_5 & 15;
goto <bb 3>; [100.00%]
which looks weird. First initialize_constant_pool_replacements inserts
SR.5 = BIT_FIELD_REF <*.LC0, 8, 0>;
which loosk OK, but then sra_modify_assign wrecks this, replacing the RHS
with 'SR.5', yielding
SR.5 = SR.5
this happens before the
/* Avoid modifying initializations of constant-pool replacements. */
if (racc && (racc->replacement_decl == lhs))
return SRA_AM_NONE;
code.
I can paper over with the following, but I wonder if sra_modify_expr needs
that very same check for constant-pool replacements?
diff --git a/gcc/tree-sra.cc b/gcc/tree-sra.cc
index f8dff8b27d7..efb52453250 100644
--- a/gcc/tree-sra.cc
+++ b/gcc/tree-sra.cc
@@ -4275,7 +4275,8 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator
*gsi)
if (TREE_CODE (rhs) == REALPART_EXPR || TREE_CODE (lhs) == REALPART_EXPR
|| TREE_CODE (rhs) == IMAGPART_EXPR || TREE_CODE (lhs) == IMAGPART_EXPR
- || TREE_CODE (rhs) == BIT_FIELD_REF || TREE_CODE (lhs) == BIT_FIELD_REF)
+ || (TREE_CODE (rhs) == BIT_FIELD_REF && !sra_handled_bf_read_p (rhs))
+ || TREE_CODE (lhs) == BIT_FIELD_REF)
{
modify_this_stmt = sra_modify_expr (gimple_assign_rhs1_ptr (stmt),
gsi, false);
I will test this now.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/111916] [14 Regression] wrong code at -O1 and above on x86_64-linux-gnu (the generated code hangs) since r14-4612-g6decda1a35be5764101987c210b5693a0d914e58
2023-10-22 5:52 [Bug tree-optimization/111916] New: wrong code at -O1 and above on x86_64-linux-gnu (the generated code hangs) zhendong.su at inf dot ethz.ch
` (5 preceding siblings ...)
2023-10-23 12:08 ` rguenth at gcc dot gnu.org
@ 2023-10-23 13:33 ` cvs-commit at gcc dot gnu.org
2023-10-23 13:33 ` rguenth at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-10-23 13:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111916
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:458db9b6149b2e9bef94ab76909eb914ed9f675a
commit r14-4866-g458db9b6149b2e9bef94ab76909eb914ed9f675a
Author: Richard Biener <rguenther@suse.de>
Date: Mon Oct 23 14:08:41 2023 +0200
tree-optimization/111916 - SRA of BIT_FIELD_REF of constant pool entries
The following adjusts a leftover BIT_FIELD_REF special-casing to only
cover the cases general code doesn't handle.
PR tree-optimization/111916
* tree-sra.cc (sra_modify_assign): Do not lower all
BIT_FIELD_REF reads that are sra_handled_bf_read_p.
* gcc.dg/torture/pr111916.c: New testcase.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug tree-optimization/111916] [14 Regression] wrong code at -O1 and above on x86_64-linux-gnu (the generated code hangs) since r14-4612-g6decda1a35be5764101987c210b5693a0d914e58
2023-10-22 5:52 [Bug tree-optimization/111916] New: wrong code at -O1 and above on x86_64-linux-gnu (the generated code hangs) zhendong.su at inf dot ethz.ch
` (6 preceding siblings ...)
2023-10-23 13:33 ` cvs-commit at gcc dot gnu.org
@ 2023-10-23 13:33 ` rguenth at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-10-23 13:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111916
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-10-23 13:33 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-22 5:52 [Bug tree-optimization/111916] New: wrong code at -O1 and above on x86_64-linux-gnu (the generated code hangs) zhendong.su at inf dot ethz.ch
2023-10-22 13:04 ` [Bug tree-optimization/111916] [14 Regression] " tkoenig at gcc dot gnu.org
2023-10-22 16:15 ` sjames at gcc dot gnu.org
2023-10-22 16:25 ` pinskia at gcc dot gnu.org
2023-10-22 16:48 ` [Bug tree-optimization/111916] [14 Regression] wrong code at -O1 and above on x86_64-linux-gnu (the generated code hangs) since r14-4612-g6decda1a35be5764101987c210b5693a0d914e58 sjames at gcc dot gnu.org
2023-10-23 9:18 ` rguenth at gcc dot gnu.org
2023-10-23 12:08 ` rguenth at gcc dot gnu.org
2023-10-23 13:33 ` cvs-commit at gcc dot gnu.org
2023-10-23 13:33 ` rguenth 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).