public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/112721] New: [14 Regression] Wrong code at -O1/s on x86_64-linux-gnu since r14-5831-gaae723d360c
@ 2023-11-27 8:04 shaohua.li at inf dot ethz.ch
2023-11-27 8:16 ` [Bug tree-optimization/112721] " jamborm at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: shaohua.li at inf dot ethz.ch @ 2023-11-27 8:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112721
Bug ID: 112721
Summary: [14 Regression] Wrong code at -O1/s on
x86_64-linux-gnu since r14-5831-gaae723d360c
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: shaohua.li at inf dot ethz.ch
CC: mjambor at suse dot cz
Target Milestone: ---
gcc at -O1/s produces the wrong code.
Bisected to r14-5831-gaae723d360c
Compiler explorer: https://godbolt.org/z/671M9YPPj
$ cat a.c
int printf(const char *, ...);
struct a {
int b;
};
int c, e;
long d;
unsigned *f(unsigned *g) {
for (; c;)
e = d;
return g;
}
int main() {
int *h;
struct a i = {8};
int *j = &i.b;
h = f(j);
*h = 0;
printf("%d\n", i.b);
}
$
$ gcc -O0 a.c && ./a.out
0
$ gcc -O1 a.c && ./a.out
8
$
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/112721] [14 Regression] Wrong code at -O1/s on x86_64-linux-gnu since r14-5831-gaae723d360c
2023-11-27 8:04 [Bug tree-optimization/112721] New: [14 Regression] Wrong code at -O1/s on x86_64-linux-gnu since r14-5831-gaae723d360c shaohua.li at inf dot ethz.ch
@ 2023-11-27 8:16 ` jamborm at gcc dot gnu.org
2023-11-27 8:55 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: jamborm at gcc dot gnu.org @ 2023-11-27 8:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112721
Martin Jambor <jamborm at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jamborm at gcc dot gnu.org
Last reconfirmed| |2023-11-27
Status|UNCONFIRMED |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |jamborm at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Martin Jambor <jamborm at gcc dot gnu.org> ---
Most likely the same reason as PR 112711. Mine.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/112721] [14 Regression] Wrong code at -O1/s on x86_64-linux-gnu since r14-5831-gaae723d360c
2023-11-27 8:04 [Bug tree-optimization/112721] New: [14 Regression] Wrong code at -O1/s on x86_64-linux-gnu since r14-5831-gaae723d360c shaohua.li at inf dot ethz.ch
2023-11-27 8:16 ` [Bug tree-optimization/112721] " jamborm at gcc dot gnu.org
@ 2023-11-27 8:55 ` pinskia at gcc dot gnu.org
2023-11-27 18:17 ` jamborm at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-27 8:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112721
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |14.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/112721] [14 Regression] Wrong code at -O1/s on x86_64-linux-gnu since r14-5831-gaae723d360c
2023-11-27 8:04 [Bug tree-optimization/112721] New: [14 Regression] Wrong code at -O1/s on x86_64-linux-gnu since r14-5831-gaae723d360c shaohua.li at inf dot ethz.ch
2023-11-27 8:16 ` [Bug tree-optimization/112721] " jamborm at gcc dot gnu.org
2023-11-27 8:55 ` pinskia at gcc dot gnu.org
@ 2023-11-27 18:17 ` jamborm at gcc dot gnu.org
2023-11-29 15:25 ` cvs-commit at gcc dot gnu.org
2023-11-29 15:27 ` jamborm at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jamborm at gcc dot gnu.org @ 2023-11-27 18:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112721
--- Comment #2 from Martin Jambor <jamborm at gcc dot gnu.org> ---
I have proposed a fix on the mailing list:
https://gcc.gnu.org/pipermail/gcc-patches/2023-November/638318.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/112721] [14 Regression] Wrong code at -O1/s on x86_64-linux-gnu since r14-5831-gaae723d360c
2023-11-27 8:04 [Bug tree-optimization/112721] New: [14 Regression] Wrong code at -O1/s on x86_64-linux-gnu since r14-5831-gaae723d360c shaohua.li at inf dot ethz.ch
` (2 preceding siblings ...)
2023-11-27 18:17 ` jamborm at gcc dot gnu.org
@ 2023-11-29 15:25 ` cvs-commit at gcc dot gnu.org
2023-11-29 15:27 ` jamborm at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-11-29 15:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112721
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Jambor <jamborm@gcc.gnu.org>:
https://gcc.gnu.org/g:302461ad9a04d82fee904bddac69811d13d5bb6a
commit r14-5971-g302461ad9a04d82fee904bddac69811d13d5bb6a
Author: Martin Jambor <mjambor@suse.cz>
Date: Wed Nov 29 16:24:33 2023 +0100
tree-sra: Avoid returns of references to SRA candidates
The enhancement to address PR 109849 contained an importsnt thinko,
and that any reference that is passed to a function and does not
escape, must also not happen to be aliased by the return value of the
function. This has quickly transpired as bugs PR 112711 and PR
112721.
Just as IPA-modref does a good enough job to allow us to rely on the
escaped set of variables, it sems to be doing well also on updating
EAF_NOT_RETURNED_DIRECTLY call argument flag which happens to address
exactly the situation we need to avoid. Of course, if a call
statement ignores any returned value, we also do not need to check the
flag.
Hopefully this does not pessimize things too much, I have verified
that the PR 109849 testcae remains quick and so should also the
benchmark it is derived from.
gcc/ChangeLog:
2023-11-27 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/112711
PR tree-optimization/112721
* tree-sra.cc (build_access_from_call_arg): New parameter
CAN_BE_RETURNED, disqualify any candidate passed by reference if it
is
true. Adjust leading comment.
(scan_function): Pass appropriate value to CAN_BE_RETURNED of
build_access_from_call_arg.
gcc/testsuite/ChangeLog:
2023-11-29 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/112711
PR tree-optimization/112721
* g++.dg/tree-ssa/pr112711.C: New test.
* gcc.dg/tree-ssa/pr112721.c: Likewise.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/112721] [14 Regression] Wrong code at -O1/s on x86_64-linux-gnu since r14-5831-gaae723d360c
2023-11-27 8:04 [Bug tree-optimization/112721] New: [14 Regression] Wrong code at -O1/s on x86_64-linux-gnu since r14-5831-gaae723d360c shaohua.li at inf dot ethz.ch
` (3 preceding siblings ...)
2023-11-29 15:25 ` cvs-commit at gcc dot gnu.org
@ 2023-11-29 15:27 ` jamborm at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jamborm at gcc dot gnu.org @ 2023-11-29 15:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112721
Martin Jambor <jamborm at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #4 from Martin Jambor <jamborm at gcc dot gnu.org> ---
Fixed
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-11-29 15:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-27 8:04 [Bug tree-optimization/112721] New: [14 Regression] Wrong code at -O1/s on x86_64-linux-gnu since r14-5831-gaae723d360c shaohua.li at inf dot ethz.ch
2023-11-27 8:16 ` [Bug tree-optimization/112721] " jamborm at gcc dot gnu.org
2023-11-27 8:55 ` pinskia at gcc dot gnu.org
2023-11-27 18:17 ` jamborm at gcc dot gnu.org
2023-11-29 15:25 ` cvs-commit at gcc dot gnu.org
2023-11-29 15:27 ` jamborm 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).