public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/111336] New: Wrong code at -O2/3 since r14-2472-g14b10ff30ad
@ 2023-09-08 7:03 shaohua.li at inf dot ethz.ch
2023-09-08 7:35 ` [Bug tree-optimization/111336] [14 Regression] " xry111 at gcc dot gnu.org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: shaohua.li at inf dot ethz.ch @ 2023-09-08 7:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111336
Bug ID: 111336
Summary: Wrong code at -O2/3 since r14-2472-g14b10ff30ad
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
CC: hubicka at gcc dot gnu.org
Target Milestone: ---
gcc at -O2/3 produced the wrong code on the following testcase.
Bisected to r14-2472-g14b10ff30ad
Compiler explorer: https://godbolt.org/z/njdcv5aK8
$ cat a.c
int printf(const char *, ...);
int a, b;
long c = 3521733542;
int d[2];
int e(int f, int g) {
if (f == 0)
return 0;
if (f > 200)
return 0;
if (g)
return 5 * f;
return 0;
}
int main() {
int h = 0;
for (; e((int)c + 773233762, c + 60) + 773163185 + h < 2; h++)
d[h] = b;
printf("%X\n", a);
}
$
$ gcc -O0 a.c && ./a.out
0
$ gcc -O2 a.c && ./a.out
Segmentation fault
$
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/111336] [14 Regression] Wrong code at -O2/3 since r14-2472-g14b10ff30ad
2023-09-08 7:03 [Bug c/111336] New: Wrong code at -O2/3 since r14-2472-g14b10ff30ad shaohua.li at inf dot ethz.ch
@ 2023-09-08 7:35 ` xry111 at gcc dot gnu.org
2023-09-08 12:31 ` shaohua.li at inf dot ethz.ch
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-09-08 7:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111336
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Wrong code at -O2/3 since |[14 Regression] Wrong code
|r14-2472-g14b10ff30ad |at -O2/3 since
| |r14-2472-g14b10ff30ad
Status|UNCONFIRMED |NEW
Last reconfirmed| |2023-09-08
Ever confirmed|0 |1
Component|c |tree-optimization
--- Comment #1 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/111336] [14 Regression] Wrong code at -O2/3 since r14-2472-g14b10ff30ad
2023-09-08 7:03 [Bug c/111336] New: Wrong code at -O2/3 since r14-2472-g14b10ff30ad shaohua.li at inf dot ethz.ch
2023-09-08 7:35 ` [Bug tree-optimization/111336] [14 Regression] " xry111 at gcc dot gnu.org
@ 2023-09-08 12:31 ` shaohua.li at inf dot ethz.ch
2023-09-08 17:04 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: shaohua.li at inf dot ethz.ch @ 2023-09-08 12:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111336
Shaohua Li <shaohua.li at inf dot ethz.ch> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |yinyuefengyi at gmail dot com
--- Comment #2 from Shaohua Li <shaohua.li at inf dot ethz.ch> ---
I have another similar test case that even affects GCC-12 (bisected to
r12-6087-g51a24e4a984)
Compiler explorer: https://godbolt.org/z/d6hjfGqzj
I reported another bug111331, which also looks similar but has different
bisection point.
$ cat a.c
int printf(const char *, ...);
int a, b;
long c = 3521733542;
int d[2];
int e(int f, int g) {
if (f == 0)
return 0;
if (f > 200)
return 0;
if (g)
return 5000 * f;
return 0;
}
int main() {
int h = 0;
for (;e((int)c + 773233762, c + 773233760) + (int)c + 773228714 + h < 2; h++)
d[h] = b;
printf("%d\n", a);
}
$
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/111336] [14 Regression] Wrong code at -O2/3 since r14-2472-g14b10ff30ad
2023-09-08 7:03 [Bug c/111336] New: Wrong code at -O2/3 since r14-2472-g14b10ff30ad shaohua.li at inf dot ethz.ch
2023-09-08 7:35 ` [Bug tree-optimization/111336] [14 Regression] " xry111 at gcc dot gnu.org
2023-09-08 12:31 ` shaohua.li at inf dot ethz.ch
@ 2023-09-08 17:04 ` pinskia at gcc dot gnu.org
2023-09-08 17:12 ` xry111 at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-08 17:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111336
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note -fwrapv or -fno-ivopts causes the issue to disappear.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/111336] [14 Regression] Wrong code at -O2/3 since r14-2472-g14b10ff30ad
2023-09-08 7:03 [Bug c/111336] New: Wrong code at -O2/3 since r14-2472-g14b10ff30ad shaohua.li at inf dot ethz.ch
` (2 preceding siblings ...)
2023-09-08 17:04 ` pinskia at gcc dot gnu.org
@ 2023-09-08 17:12 ` xry111 at gcc dot gnu.org
2023-09-08 17:15 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-09-08 17:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111336
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |xry111 at gcc dot gnu.org
--- Comment #4 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #3)
> Note -fwrapv or -fno-ivopts causes the issue to disappear.
Does your patch for PR111331 work for this one too?
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/111336] [14 Regression] Wrong code at -O2/3 since r14-2472-g14b10ff30ad
2023-09-08 7:03 [Bug c/111336] New: Wrong code at -O2/3 since r14-2472-g14b10ff30ad shaohua.li at inf dot ethz.ch
` (3 preceding siblings ...)
2023-09-08 17:12 ` xry111 at gcc dot gnu.org
@ 2023-09-08 17:15 ` pinskia at gcc dot gnu.org
2023-09-08 17:16 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-08 17:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111336
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |14.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/111336] [14 Regression] Wrong code at -O2/3 since r14-2472-g14b10ff30ad
2023-09-08 7:03 [Bug c/111336] New: Wrong code at -O2/3 since r14-2472-g14b10ff30ad shaohua.li at inf dot ethz.ch
` (4 preceding siblings ...)
2023-09-08 17:15 ` pinskia at gcc dot gnu.org
@ 2023-09-08 17:16 ` pinskia at gcc dot gnu.org
2023-10-17 12:53 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-08 17:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111336
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Xi Ruoyao from comment #4)
> (In reply to Andrew Pinski from comment #3)
> > Note -fwrapv or -fno-ivopts causes the issue to disappear.
>
> Does your patch for PR111331 work for this one too?
No because it is unrelated, there was no min or max in the IR either.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/111336] [14 Regression] Wrong code at -O2/3 since r14-2472-g14b10ff30ad
2023-09-08 7:03 [Bug c/111336] New: Wrong code at -O2/3 since r14-2472-g14b10ff30ad shaohua.li at inf dot ethz.ch
` (5 preceding siblings ...)
2023-09-08 17:16 ` pinskia at gcc dot gnu.org
@ 2023-10-17 12:53 ` rguenth at gcc dot gnu.org
2023-10-17 14:02 ` rguenth at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-10-17 12:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111336
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P1
Last reconfirmed|2023-09-08 00:00:00 |2023-10-17
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/111336] [14 Regression] Wrong code at -O2/3 since r14-2472-g14b10ff30ad
2023-09-08 7:03 [Bug c/111336] New: Wrong code at -O2/3 since r14-2472-g14b10ff30ad shaohua.li at inf dot ethz.ch
` (6 preceding siblings ...)
2023-10-17 12:53 ` rguenth at gcc dot gnu.org
@ 2023-10-17 14:02 ` rguenth at gcc dot gnu.org
2023-10-20 13:15 ` cvs-commit at gcc dot gnu.org
2023-10-20 13:17 ` rguenth at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-10-17 14:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111336
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=110243
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Goes away with my fix for PR110243, so I think it's related or even the same.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/111336] [14 Regression] Wrong code at -O2/3 since r14-2472-g14b10ff30ad
2023-09-08 7:03 [Bug c/111336] New: Wrong code at -O2/3 since r14-2472-g14b10ff30ad shaohua.li at inf dot ethz.ch
` (7 preceding siblings ...)
2023-10-17 14:02 ` rguenth at gcc dot gnu.org
@ 2023-10-20 13:15 ` cvs-commit at gcc dot gnu.org
2023-10-20 13:17 ` rguenth at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-10-20 13:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111336
--- 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:44e7e4498c3cdc27e087ab80aa76dac41819702f
commit r14-4789-g44e7e4498c3cdc27e087ab80aa76dac41819702f
Author: Richard Biener <rguenther@suse.de>
Date: Fri Oct 20 14:08:46 2023 +0200
tree-optimization/110243 - IVOPTs introducing undefined overflow
The following addresses IVOPTs rewriting expressions in its
strip_offset without caring for definedness of overflow. Rather
than the earlier attempt of just using the proper
split_constant_offset from data-ref analysis the following adjusts
IVOPTs helper trying to minimize changes from this fix, possibly
easing backports.
PR tree-optimization/110243
PR tree-optimization/111336
* tree-ssa-loop-ivopts.cc (strip_offset_1): Rewrite
operations with undefined behavior on overflow to
unsigned arithmetic.
* gcc.dg/torture/pr110243.c: New testcase.
* gcc.dg/torture/pr111336.c: Likewise.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug tree-optimization/111336] [14 Regression] Wrong code at -O2/3 since r14-2472-g14b10ff30ad
2023-09-08 7:03 [Bug c/111336] New: Wrong code at -O2/3 since r14-2472-g14b10ff30ad shaohua.li at inf dot ethz.ch
` (8 preceding siblings ...)
2023-10-20 13:15 ` cvs-commit at gcc dot gnu.org
@ 2023-10-20 13:17 ` rguenth at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-10-20 13:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111336
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed. The dup tracks backporting.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2023-10-20 13:17 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-08 7:03 [Bug c/111336] New: Wrong code at -O2/3 since r14-2472-g14b10ff30ad shaohua.li at inf dot ethz.ch
2023-09-08 7:35 ` [Bug tree-optimization/111336] [14 Regression] " xry111 at gcc dot gnu.org
2023-09-08 12:31 ` shaohua.li at inf dot ethz.ch
2023-09-08 17:04 ` pinskia at gcc dot gnu.org
2023-09-08 17:12 ` xry111 at gcc dot gnu.org
2023-09-08 17:15 ` pinskia at gcc dot gnu.org
2023-09-08 17:16 ` pinskia at gcc dot gnu.org
2023-10-17 12:53 ` rguenth at gcc dot gnu.org
2023-10-17 14:02 ` rguenth at gcc dot gnu.org
2023-10-20 13:15 ` cvs-commit at gcc dot gnu.org
2023-10-20 13:17 ` 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).