public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/110640] New: Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13
@ 2023-07-12 12:45 shaohua.li at inf dot ethz.ch
2023-07-12 13:55 ` [Bug c/110640] [13/14 Regression] " rguenth at gcc dot gnu.org
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: shaohua.li at inf dot ethz.ch @ 2023-07-12 12:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110640
Bug ID: 110640
Summary: Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: shaohua.li at inf dot ethz.ch
Target Milestone: ---
This looks like a regression since GCC-13. gcc produces wrong code at -O2/3.
Compiler explorer: https://godbolt.org/z/5MWe6eK8M
$ cat a.c
unsigned short a = 65535;
int b, f, g;
int *c = &b;
long d;
short e;
static int *h(int);
void i() { h(a); }
int *h(int j) {
unsigned char k;
for (; e != 8; e = e + 4)
k = 0;
for (; (unsigned char)(j-181249535) + k <= 1; k++) {
*c = d;
for (; f; f++)
;
}
return &g;
}
int main() { i(); }
$
$ gcc-tk -O0 a.c && ./a.out
$
$ gcc-tk -O2 a.c
$ ./a.out
Killed
$ gcc-tk -O3 a.c
$ ./a.out
Killed
$
$ gcc-tk -v
Using built-in specs.
COLLECT_GCC=gcc-tk
COLLECT_LTO_WRAPPER=/zdata/shaoli/compilers/ccbuilder-compilers/gcc-322d17ae51ea0137167424e0018d7fa355948f9f/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --disable-multilib --disable-bootstrap
--enable-languages=c,c++
--prefix=/zdata/shaoli/compilers/ccbuilder-compilers/gcc-322d17ae51ea0137167424e0018d7fa355948f9f
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230711 (experimental) (GCC)
$
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c/110640] [13/14 Regression] Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13
2023-07-12 12:45 [Bug c/110640] New: Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13 shaohua.li at inf dot ethz.ch
@ 2023-07-12 13:55 ` rguenth at gcc dot gnu.org
2023-07-12 13:56 ` [Bug tree-optimization/110640] " rguenth at gcc dot gnu.org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-12 13:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110640
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |13.2
Summary|Wrong code at -O2/3 on |[13/14 Regression] Wrong
|x86_64-linux-gnu since |code at -O2/3 on
|GCC-13 |x86_64-linux-gnu since
| |GCC-13
Keywords| |needs-bisection, wrong-code
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/110640] [13/14 Regression] Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13
2023-07-12 12:45 [Bug c/110640] New: Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13 shaohua.li at inf dot ethz.ch
2023-07-12 13:55 ` [Bug c/110640] [13/14 Regression] " rguenth at gcc dot gnu.org
@ 2023-07-12 13:56 ` rguenth at gcc dot gnu.org
2023-07-12 16:19 ` pinskia at gcc dot gnu.org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-12 13:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110640
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rguenth at gcc dot gnu.org
Last reconfirmed| |2023-07-12
Component|c |tree-optimization
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed. Adding -fno-tree-vrp avoids the issue.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/110640] [13/14 Regression] Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13
2023-07-12 12:45 [Bug c/110640] New: Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13 shaohua.li at inf dot ethz.ch
2023-07-12 13:55 ` [Bug c/110640] [13/14 Regression] " rguenth at gcc dot gnu.org
2023-07-12 13:56 ` [Bug tree-optimization/110640] " rguenth at gcc dot gnu.org
@ 2023-07-12 16:19 ` pinskia at gcc dot gnu.org
2023-07-13 8:51 ` rguenth at gcc dot gnu.org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-12 16:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110640
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
> Confirmed. Adding -fno-tree-vrp avoids the issue.
Using -fdisable-tree-vrp1 avoids the issue ...
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/110640] [13/14 Regression] Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13
2023-07-12 12:45 [Bug c/110640] New: Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13 shaohua.li at inf dot ethz.ch
` (2 preceding siblings ...)
2023-07-12 16:19 ` pinskia at gcc dot gnu.org
@ 2023-07-13 8:51 ` rguenth at gcc dot gnu.org
2023-07-27 9:27 ` rguenth at gcc dot gnu.org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-13 8:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110640
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
We end up with
<bb 10> [local count: 78745003]:
<bb 11> [local count: 78745003]:
*c.5_6 = _7;
f.7_32 = f;
if (f.7_32 != 0)
goto <bb 12>; [89.00%]
else
goto <bb 10>; [11.00%]
<bb 12> [local count: 70083053]:
f = 0;
goto <bb 10>; [100.00%]
disabling loop header copying (-fdisable-tree-ch2) also avoids the issue.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/110640] [13/14 Regression] Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13
2023-07-12 12:45 [Bug c/110640] New: Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13 shaohua.li at inf dot ethz.ch
` (3 preceding siblings ...)
2023-07-13 8:51 ` rguenth at gcc dot gnu.org
@ 2023-07-27 9:27 ` rguenth at gcc dot gnu.org
2023-07-30 14:49 ` shaohua.li at inf dot ethz.ch
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-27 9:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110640
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|13.2 |13.3
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 13.2 is being released, retargeting bugs to GCC 13.3.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/110640] [13/14 Regression] Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13
2023-07-12 12:45 [Bug c/110640] New: Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13 shaohua.li at inf dot ethz.ch
` (4 preceding siblings ...)
2023-07-27 9:27 ` rguenth at gcc dot gnu.org
@ 2023-07-30 14:49 ` shaohua.li at inf dot ethz.ch
2023-07-31 7:15 ` rguenth at gcc dot gnu.org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: shaohua.li at inf dot ethz.ch @ 2023-07-30 14:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110640
--- Comment #5 from Shaohua Li <shaohua.li at inf dot ethz.ch> ---
Bisect to r12-1653-gcb448ade74d
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/110640] [13/14 Regression] Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13
2023-07-12 12:45 [Bug c/110640] New: Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13 shaohua.li at inf dot ethz.ch
` (5 preceding siblings ...)
2023-07-30 14:49 ` shaohua.li at inf dot ethz.ch
@ 2023-07-31 7:15 ` rguenth at gcc dot gnu.org
2023-12-13 17:03 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-31 7:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110640
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|needs-bisection |
Priority|P3 |P2
CC| |aldyh at gcc dot gnu.org,
| |amacleod at redhat dot com
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/110640] [13/14 Regression] Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13
2023-07-12 12:45 [Bug c/110640] New: Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13 shaohua.li at inf dot ethz.ch
` (6 preceding siblings ...)
2023-07-31 7:15 ` rguenth at gcc dot gnu.org
@ 2023-12-13 17:03 ` jakub at gcc dot gnu.org
2023-12-14 7:37 ` [Bug tree-optimization/110640] [13 Regression] Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13 since r12-1653-gcb448ade74d rguenth at gcc dot gnu.org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-12-13 17:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110640
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
This doesn't reproduce on the trunk since
r14-4790-g9692309ed6b625f0fb358c0e230404b5603f69a6 anymore. Was that a fix for
this or just made it latent?
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/110640] [13 Regression] Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13 since r12-1653-gcb448ade74d
2023-07-12 12:45 [Bug c/110640] New: Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13 shaohua.li at inf dot ethz.ch
` (7 preceding siblings ...)
2023-12-13 17:03 ` jakub at gcc dot gnu.org
@ 2023-12-14 7:37 ` rguenth at gcc dot gnu.org
2023-12-14 7:39 ` rguenth at gcc dot gnu.org
2023-12-14 7:41 ` cvs-commit at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-12-14 7:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110640
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |14.0
Summary|[13/14 Regression] Wrong |[13 Regression] Wrong code
|code at -O2/3 on |at -O2/3 on
|x86_64-linux-gnu since |x86_64-linux-gnu since
|GCC-13 since |GCC-13 since
|r12-1653-gcb448ade74d |r12-1653-gcb448ade74d
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org
Depends on| |111445
Status|NEW |ASSIGNED
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #6)
> This doesn't reproduce on the trunk since
> r14-4790-g9692309ed6b625f0fb358c0e230404b5603f69a6 anymore. Was that a fix
> for this or just made it latent?
It does look similar enough:
<bb 7> [local count: 118111600]:
k_11 = k_38 + 1;
- _13 = (unsigned char) j_12(D);
- _14 = _13 + 1;
- _15 = (int) _14;
+ _13 = _26;
+ _14 = _28;
+ _15 = _29;
_16 = (int) k_11;
- _17 = _15 + _16;
+ _17 = _29 + 1;
I'll add this testcase as well.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111445
[Bug 111445] [12 Regression] Wrong code at -Os on x86_64-linux-gnu since
r12-1077-g57bf3751511
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/110640] [13 Regression] Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13 since r12-1653-gcb448ade74d
2023-07-12 12:45 [Bug c/110640] New: Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13 shaohua.li at inf dot ethz.ch
` (8 preceding siblings ...)
2023-12-14 7:37 ` [Bug tree-optimization/110640] [13 Regression] Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13 since r12-1653-gcb448ade74d rguenth at gcc dot gnu.org
@ 2023-12-14 7:39 ` rguenth at gcc dot gnu.org
2023-12-14 7:41 ` cvs-commit at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-12-14 7:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110640
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Known to work| |13.2.1
Resolution|--- |FIXED
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Verified fixed on the branch (patch was backported).
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug tree-optimization/110640] [13 Regression] Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13 since r12-1653-gcb448ade74d
2023-07-12 12:45 [Bug c/110640] New: Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13 shaohua.li at inf dot ethz.ch
` (9 preceding siblings ...)
2023-12-14 7:39 ` rguenth at gcc dot gnu.org
@ 2023-12-14 7:41 ` cvs-commit at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-14 7:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110640
--- Comment #9 from GCC 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:9e20779a7d8e14e77df6efaeadc6bf3a001336ef
commit r14-6532-g9e20779a7d8e14e77df6efaeadc6bf3a001336ef
Author: Richard Biener <rguenther@suse.de>
Date: Thu Dec 14 08:40:00 2023 +0100
tree-optimization/110640 - testcase for fixed bug
PR tree-optimization/110640
* gcc.dg/torture/pr110640.c: New testcase.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-12-14 7:41 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-12 12:45 [Bug c/110640] New: Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13 shaohua.li at inf dot ethz.ch
2023-07-12 13:55 ` [Bug c/110640] [13/14 Regression] " rguenth at gcc dot gnu.org
2023-07-12 13:56 ` [Bug tree-optimization/110640] " rguenth at gcc dot gnu.org
2023-07-12 16:19 ` pinskia at gcc dot gnu.org
2023-07-13 8:51 ` rguenth at gcc dot gnu.org
2023-07-27 9:27 ` rguenth at gcc dot gnu.org
2023-07-30 14:49 ` shaohua.li at inf dot ethz.ch
2023-07-31 7:15 ` rguenth at gcc dot gnu.org
2023-12-13 17:03 ` jakub at gcc dot gnu.org
2023-12-14 7:37 ` [Bug tree-optimization/110640] [13 Regression] Wrong code at -O2/3 on x86_64-linux-gnu since GCC-13 since r12-1653-gcb448ade74d rguenth at gcc dot gnu.org
2023-12-14 7:39 ` rguenth at gcc dot gnu.org
2023-12-14 7:41 ` cvs-commit 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).