public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ipa/100220] New: missed optimization for dead code elimination at -O3 (vs. -O1, -Os, -O2)
@ 2021-04-22 19:25 zhendong.su at inf dot ethz.ch
2021-09-25 9:49 ` [Bug ipa/100220] " pinskia at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2021-04-22 19:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100220
Bug ID: 100220
Summary: missed optimization for dead code elimination at -O3
(vs. -O1, -Os, -O2)
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ipa
Assignee: unassigned at gcc dot gnu.org
Reporter: zhendong.su at inf dot ethz.ch
CC: marxin at gcc dot gnu.org
Target Milestone: ---
[638] % 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/12.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--prefix=/local/suz-local/software/local/gcc-trunk --enable-languages=c,c++
--disable-werror --enable-multilib --with-system-zlib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210422 (experimental) [master revision
3cf04d1afa8:0e51007a40c:d42088e453042f4f8ba9190a7e29efd937ea2181] (GCC)
[639] %
[639] % gcctk -O1 -S -o O1.s small.c
[640] % gcctk -O3 -S -o O3.s small.c
[641] %
[641] % wc O1.s O3.s
62 135 857 O1.s
93 200 1337 O3.s
155 335 2194 total
[642] %
[642] % grep foo O1.s
[643] % grep foo O3.s
call foo
[644] %
[644] % cat small.c
extern void foo(void);
int b, c, d, e, *h;
static int *f = &e;
static int a() { return 1; }
static void g() {
if (!*f)
for (; 1; d++)
;
foo();
}
static void i() {
int j, l = 0, k[24] = {0}, *m[2] = {&k[4], &l}, n[27];
h = n;
if (a() & n[0])
for (; c; c--)
;
int p[8];
h = p;
p[0] && (h = &j);
e = 0;
}
static void o() {
int *q, **r = &q, ***s[1];
s[0] = &r;
i();
g();
}
int main() {
if (b)
o();
return 0;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug ipa/100220] missed optimization for dead code elimination at -O3 (vs. -O1, -Os, -O2)
2021-04-22 19:25 [Bug ipa/100220] New: missed optimization for dead code elimination at -O3 (vs. -O1, -Os, -O2) zhendong.su at inf dot ethz.ch
@ 2021-09-25 9:49 ` pinskia at gcc dot gnu.org
2022-01-11 9:57 ` [Bug ipa/100220] missed optimization for dead code elimination at -O3 (vs. -O1, -Os, -O2) (inlining differences) rguenth at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-25 9:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100220
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2021-09-25
CC| |hubicka at gcc dot gnu.org
Status|UNCONFIRMED |NEW
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
-O3 changes inlining just so slightly and not inlining as much any more;
/* -O3 parameters. */
{ OPT_LEVELS_3_PLUS, OPT__param_max_inline_insns_auto_, NULL, 30 },
{ OPT_LEVELS_3_PLUS, OPT__param_early_inlining_insns_, NULL, 14 },
{ OPT_LEVELS_3_PLUS, OPT__param_inline_heuristics_hint_percent_, NULL, 600
},
{ OPT_LEVELS_3_PLUS, OPT__param_inline_min_speedup_, NULL, 15 },
{ OPT_LEVELS_3_PLUS, OPT__param_max_inline_insns_single_, NULL, 200 },
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug ipa/100220] missed optimization for dead code elimination at -O3 (vs. -O1, -Os, -O2) (inlining differences)
2021-04-22 19:25 [Bug ipa/100220] New: missed optimization for dead code elimination at -O3 (vs. -O1, -Os, -O2) zhendong.su at inf dot ethz.ch
2021-09-25 9:49 ` [Bug ipa/100220] " pinskia at gcc dot gnu.org
@ 2022-01-11 9:57 ` rguenth at gcc dot gnu.org
2022-01-11 10:54 ` hubicka at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-11 9:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100220
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Indeed similar interaction between inlining, static var const promotion and IPA
CP / inline heuristics
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug ipa/100220] missed optimization for dead code elimination at -O3 (vs. -O1, -Os, -O2) (inlining differences)
2021-04-22 19:25 [Bug ipa/100220] New: missed optimization for dead code elimination at -O3 (vs. -O1, -Os, -O2) zhendong.su at inf dot ethz.ch
2021-09-25 9:49 ` [Bug ipa/100220] " pinskia at gcc dot gnu.org
2022-01-11 9:57 ` [Bug ipa/100220] missed optimization for dead code elimination at -O3 (vs. -O1, -Os, -O2) (inlining differences) rguenth at gcc dot gnu.org
@ 2022-01-11 10:54 ` hubicka at gcc dot gnu.org
2023-08-18 2:30 ` pinskia at gcc dot gnu.org
2024-05-16 9:05 ` rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: hubicka at gcc dot gnu.org @ 2022-01-11 10:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100220
Jan Hubicka <hubicka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Depends on| |100314
--- Comment #3 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
Here the stack frame size of i is stimated to 244 bytes
void i ()
{
int p[8];
int n[27];
int k[24];
int l;
int j;
int _1;
int _2;
int _3;
int c.2_4;
int _5;
<bb 2> [local count: 236223200]:
l = 0;
k = {};
h = &n;
_1 = n[0];
_2 = _1 & 1;
if (_2 != 0)
goto <bb 8>; [50.00%]
else
goto <bb 5>; [50.00%]
<bb 8> [local count: 118111600]:
goto <bb 4>; [100.00%]
<bb 3> [local count: 955630225]:
_3 = c.2_4 + -1;
c = _3;
<bb 4> [local count: 1073741824]:
c.2_4 = c;
if (c.2_4 != 0)
goto <bb 3>; [89.00%]
else
goto <bb 5>; [11.00%]
<bb 5> [local count: 236223200]:
h = &p;
_5 = p[0];
if (_5 != 0)
goto <bb 6>; [50.00%]
else
goto <bb 7>; [50.00%]
<bb 6> [local count: 118111600]:
h = &j;
<bb 7> [local count: 236223200]:
e = 0;
j ={v} {CLOBBER};
l ={v} {CLOBBER};
k ={v} {CLOBBER};
n ={v} {CLOBBER};
p ={v} {CLOBBER};
return;
}
so it indeed has larger arrays. k is initialized but never used (so it is
missed DSE). n is used in stupid way:
h = &n;
_1 = n[0];
where h is write only static var, but we do not know that during early opts (we
could try our luck and schedule one extra writeonly detection before early
optimization passes, but I am not sure it is worth).
I would say that main issue is also missed DSE
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100314
[Bug 100314] missed optimization for dead code elimination at -O3 (vs. -O1)
(inlining differences due to missed dse)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug ipa/100220] missed optimization for dead code elimination at -O3 (vs. -O1, -Os, -O2) (inlining differences)
2021-04-22 19:25 [Bug ipa/100220] New: missed optimization for dead code elimination at -O3 (vs. -O1, -Os, -O2) zhendong.su at inf dot ethz.ch
` (2 preceding siblings ...)
2022-01-11 10:54 ` hubicka at gcc dot gnu.org
@ 2023-08-18 2:30 ` pinskia at gcc dot gnu.org
2024-05-16 9:05 ` rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-18 2:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100220
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |needs-bisection
Known to work| |13.1.0
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Seems to be fixed in GCC 13.1.0.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug ipa/100220] missed optimization for dead code elimination at -O3 (vs. -O1, -Os, -O2) (inlining differences)
2021-04-22 19:25 [Bug ipa/100220] New: missed optimization for dead code elimination at -O3 (vs. -O1, -Os, -O2) zhendong.su at inf dot ethz.ch
` (3 preceding siblings ...)
2023-08-18 2:30 ` pinskia at gcc dot gnu.org
@ 2024-05-16 9:05 ` rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-16 9:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100220
Bug 100220 depends on bug 100314, which changed state.
Bug 100314 Summary: missed optimization for dead code elimination at -O3 (vs. -O1) (inlining differences due to missed dse)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100314
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-05-16 9:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-22 19:25 [Bug ipa/100220] New: missed optimization for dead code elimination at -O3 (vs. -O1, -Os, -O2) zhendong.su at inf dot ethz.ch
2021-09-25 9:49 ` [Bug ipa/100220] " pinskia at gcc dot gnu.org
2022-01-11 9:57 ` [Bug ipa/100220] missed optimization for dead code elimination at -O3 (vs. -O1, -Os, -O2) (inlining differences) rguenth at gcc dot gnu.org
2022-01-11 10:54 ` hubicka at gcc dot gnu.org
2023-08-18 2:30 ` pinskia at gcc dot gnu.org
2024-05-16 9:05 ` 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).