public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/111472] New: Wrong code at -Os on x86_64-linux-gnu since
@ 2023-09-19 7:38 shaohua.li at inf dot ethz.ch
2023-09-19 7:45 ` [Bug tree-optimization/111472] Wrong code at -Os on x86_64-linux-gnu since r11-4563-gd0d8b5d836 xry111 at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: shaohua.li at inf dot ethz.ch @ 2023-09-19 7:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111472
Bug ID: 111472
Summary: Wrong code at -Os on x86_64-linux-gnu since
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: amacleod at redhat dot com
Target Milestone: ---
gcc at -Os produced the wrong code.
Bisected to r11-4563-gd0d8b5d836
Compiler explorer: https://godbolt.org/z/EPznGbaje
With -fwrapv the issue goes away.
$ cat a.c
int printf(const char *, ...);
int a, b, e, f;
short c = -1, i;
char g;
int h[4][1] = {8, 5, 8, 5};
int main() {
int *j = &e, *k = &f;
unsigned short d = c;
i = d >> b;
*j = i;
g = 0;
for (; g <= 3; g++)
*k = h[(unsigned char)(1 + e) + g][0];
printf("%d\n", f);
}
$
$ gcc -O0 a.c && ./a.out
5
$ gcc -Os a.c && ./a.out
Segmentation fault
$
$ gcc -fsanitize=undefined a.c && ./a.out
5
$
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/111472] Wrong code at -Os on x86_64-linux-gnu since r11-4563-gd0d8b5d836
2023-09-19 7:38 [Bug c/111472] New: Wrong code at -Os on x86_64-linux-gnu since shaohua.li at inf dot ethz.ch
@ 2023-09-19 7:45 ` xry111 at gcc dot gnu.org
2023-09-19 7:47 ` shaohua.li at inf dot ethz.ch
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-09-19 7:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111472
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|c |tree-optimization
--- Comment #1 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
Another ivopts issue.
Note that if something is different with different -O levels it's almost never
a "c" bug. The "c" in component only covers C frontend which only contains
very straightforward optimizations.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/111472] Wrong code at -Os on x86_64-linux-gnu since r11-4563-gd0d8b5d836
2023-09-19 7:38 [Bug c/111472] New: Wrong code at -Os on x86_64-linux-gnu since shaohua.li at inf dot ethz.ch
2023-09-19 7:45 ` [Bug tree-optimization/111472] Wrong code at -Os on x86_64-linux-gnu since r11-4563-gd0d8b5d836 xry111 at gcc dot gnu.org
@ 2023-09-19 7:47 ` shaohua.li at inf dot ethz.ch
2023-09-19 7:48 ` [Bug tree-optimization/111472] [11/12/13/14 Regression] " xry111 at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: shaohua.li at inf dot ethz.ch @ 2023-09-19 7:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111472
--- Comment #2 from Shaohua Li <shaohua.li at inf dot ethz.ch> ---
(In reply to Xi Ruoyao from comment #1)
> Another ivopts issue.
>
> Note that if something is different with different -O levels it's almost
> never a "c" bug. The "c" in component only covers C frontend which only
> contains very straightforward optimizations.
Thanks for the explanation!
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/111472] [11/12/13/14 Regression] Wrong code at -Os on x86_64-linux-gnu since r11-4563-gd0d8b5d836
2023-09-19 7:38 [Bug c/111472] New: Wrong code at -Os on x86_64-linux-gnu since shaohua.li at inf dot ethz.ch
2023-09-19 7:45 ` [Bug tree-optimization/111472] Wrong code at -Os on x86_64-linux-gnu since r11-4563-gd0d8b5d836 xry111 at gcc dot gnu.org
2023-09-19 7:47 ` shaohua.li at inf dot ethz.ch
@ 2023-09-19 7:48 ` xry111 at gcc dot gnu.org
2023-09-19 7:48 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-09-19 7:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111472
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Summary|Wrong code at -Os on |[11/12/13/14 Regression]
|x86_64-linux-gnu since |Wrong code at -Os on
|r11-4563-gd0d8b5d836 |x86_64-linux-gnu since
| |r11-4563-gd0d8b5d836
CC| |xry111 at gcc dot gnu.org
Last reconfirmed| |2023-09-19
Status|UNCONFIRMED |NEW
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/111472] [11/12/13/14 Regression] Wrong code at -Os on x86_64-linux-gnu since r11-4563-gd0d8b5d836
2023-09-19 7:38 [Bug c/111472] New: Wrong code at -Os on x86_64-linux-gnu since shaohua.li at inf dot ethz.ch
` (2 preceding siblings ...)
2023-09-19 7:48 ` [Bug tree-optimization/111472] [11/12/13/14 Regression] " xry111 at gcc dot gnu.org
@ 2023-09-19 7:48 ` pinskia at gcc dot gnu.org
2023-11-06 20:31 ` amacleod at redhat dot com
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-19 7:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111472
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Target Milestone|--- |11.5
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/111472] [11/12/13/14 Regression] Wrong code at -Os on x86_64-linux-gnu since r11-4563-gd0d8b5d836
2023-09-19 7:38 [Bug c/111472] New: Wrong code at -Os on x86_64-linux-gnu since shaohua.li at inf dot ethz.ch
` (3 preceding siblings ...)
2023-09-19 7:48 ` pinskia at gcc dot gnu.org
@ 2023-11-06 20:31 ` amacleod at redhat dot com
2023-11-06 20:35 ` amacleod at redhat dot com
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: amacleod at redhat dot com @ 2023-11-06 20:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111472
--- Comment #3 from Andrew Macleod <amacleod at redhat dot com> ---
I'm not sure that this didn't uncover something elsewhere, possibly ivopts
since that pass seems to be generating something different and I think there
were some fixes put in there on trunk?.
Regardless, this currently works on trunk. Can we run a regression on trunk and
see what patch fixed it?
Andrew
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/111472] [11/12/13/14 Regression] Wrong code at -Os on x86_64-linux-gnu since r11-4563-gd0d8b5d836
2023-09-19 7:38 [Bug c/111472] New: Wrong code at -Os on x86_64-linux-gnu since shaohua.li at inf dot ethz.ch
` (4 preceding siblings ...)
2023-11-06 20:31 ` amacleod at redhat dot com
@ 2023-11-06 20:35 ` amacleod at redhat dot com
2023-11-06 20:37 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: amacleod at redhat dot com @ 2023-11-06 20:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111472
--- Comment #4 from Andrew Macleod <amacleod at redhat dot com> ---
(In reply to Andrew Macleod from comment #3)
> I'm not sure that this didn't uncover something elsewhere, possibly ivopts
> since that pass seems to be generating something different and I think there
> were some fixes put in there on trunk?.
>
> Regardless, this currently works on trunk. Can we run a regression on trunk
> and see what patch fixed it?
>
> Andrew
And still fails on GCC13, so it appears to have been a trunk patch that fixed
it.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/111472] [11/12/13/14 Regression] Wrong code at -Os on x86_64-linux-gnu since r11-4563-gd0d8b5d836
2023-09-19 7:38 [Bug c/111472] New: Wrong code at -Os on x86_64-linux-gnu since shaohua.li at inf dot ethz.ch
` (5 preceding siblings ...)
2023-11-06 20:35 ` amacleod at redhat dot com
@ 2023-11-06 20:37 ` pinskia at gcc dot gnu.org
2024-03-07 22:24 ` [Bug tree-optimization/111472] [11/12/13 " law at gcc dot gnu.org
2024-05-08 12:15 ` [Bug tree-optimization/111472] [11 " rguenth at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-06 20:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111472
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Macleod from comment #3)
> I'm not sure that this didn't uncover something elsewhere, possibly ivopts
> since that pass seems to be generating something different and I think there
> were some fixes put in there on trunk?.
>
> Regardless, this currently works on trunk. Can we run a regression on trunk
> and see what patch fixed it?
Most likely r14-4789-g44e7e4498c (aka PR 110243).
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/111472] [11/12/13 Regression] Wrong code at -Os on x86_64-linux-gnu since r11-4563-gd0d8b5d836
2023-09-19 7:38 [Bug c/111472] New: Wrong code at -Os on x86_64-linux-gnu since shaohua.li at inf dot ethz.ch
` (6 preceding siblings ...)
2023-11-06 20:37 ` pinskia at gcc dot gnu.org
@ 2024-03-07 22:24 ` law at gcc dot gnu.org
2024-05-08 12:15 ` [Bug tree-optimization/111472] [11 " rguenth at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-07 22:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111472
Jeffrey A. Law <law at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |law at gcc dot gnu.org
Summary|[11/12/13/14 Regression] |[11/12/13 Regression] Wrong
|Wrong code at -Os on |code at -Os on
|x86_64-linux-gnu since |x86_64-linux-gnu since
|r11-4563-gd0d8b5d836 |r11-4563-gd0d8b5d836
--- Comment #6 from Jeffrey A. Law <law at gcc dot gnu.org> ---
Close. It was the next revision my bisection landed on as the fix:
commit 9692309ed6b625f0fb358c0e230404b5603f69a6 (refs/bisect/bad)
Author: Richard Biener <rguenther@suse.de>
Date: Fri Oct 20 15:08:49 2023 +0200
tree-optimization/111445 - simple_iv simplification fault
The following fixes a missed check in the simple_iv attempt
to simplify (signed T)((unsigned T) base + step) where it
allows a truncating inner conversion leading to wrong code.
PR tree-optimization/111445
* tree-scalar-evolution.cc (simple_iv_with_niters):
Add missing check for a sign-conversion.
* gcc.dg/torture/pr111445.c: New testcase.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/111472] [11 Regression] Wrong code at -Os on x86_64-linux-gnu since r11-4563-gd0d8b5d836
2023-09-19 7:38 [Bug c/111472] New: Wrong code at -Os on x86_64-linux-gnu since shaohua.li at inf dot ethz.ch
` (7 preceding siblings ...)
2024-03-07 22:24 ` [Bug tree-optimization/111472] [11/12/13 " law at gcc dot gnu.org
@ 2024-05-08 12:15 ` rguenth at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-08 12:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111472
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |12.3.1, 13.2.1
Known to fail| |12.3.0, 13.2.0
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org
Status|NEW |ASSIGNED
Last reconfirmed|2023-09-19 00:00:00 |2024-5-8
Priority|P3 |P2
Summary|[11/12/13 Regression] Wrong |[11 Regression] Wrong code
|code at -Os on |at -Os on x86_64-linux-gnu
|x86_64-linux-gnu since |since r11-4563-gd0d8b5d836
|r11-4563-gd0d8b5d836 |
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Re-confirmed on the 11 branch, fixed/avoided on newer branches by the backport
of referenced bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-05-08 12:15 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-19 7:38 [Bug c/111472] New: Wrong code at -Os on x86_64-linux-gnu since shaohua.li at inf dot ethz.ch
2023-09-19 7:45 ` [Bug tree-optimization/111472] Wrong code at -Os on x86_64-linux-gnu since r11-4563-gd0d8b5d836 xry111 at gcc dot gnu.org
2023-09-19 7:47 ` shaohua.li at inf dot ethz.ch
2023-09-19 7:48 ` [Bug tree-optimization/111472] [11/12/13/14 Regression] " xry111 at gcc dot gnu.org
2023-09-19 7:48 ` pinskia at gcc dot gnu.org
2023-11-06 20:31 ` amacleod at redhat dot com
2023-11-06 20:35 ` amacleod at redhat dot com
2023-11-06 20:37 ` pinskia at gcc dot gnu.org
2024-03-07 22:24 ` [Bug tree-optimization/111472] [11/12/13 " law at gcc dot gnu.org
2024-05-08 12:15 ` [Bug tree-optimization/111472] [11 " 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).