public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ipa/100100] New: missed optimization for dead code elimination at -O3 (vs. -O1, -Os, -O2)
@ 2021-04-15 12:53 zhendong.su at inf dot ethz.ch
2021-04-15 13:18 ` [Bug ipa/100100] " rguenth at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2021-04-15 12:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100100
Bug ID: 100100
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: ---
[538] % 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/11.0.1/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 11.0.1 20210415 (experimental) [master revision
4dd9e1c541e:7315804b0a0:b5f644a98b3f3543d3a8d2dfea7785c22879013f] (GCC)
[539] %
[539] % gcctk -O1 -S -o O1.s small.c
[540] % gcctk -O3 -S -o O3.s small.c
[541] %
[541] % wc O1.s O3.s
79 175 1126 O1.s
98 196 1466 O3.s
177 371 2592 total
[542] %
[542] % grep foo O1.s
[543] % grep foo O3.s
jmp foo
[544] %
[544] % cat small.c
extern void foo(void);
static int a, d, e, h, o, p;
static short b, c, f, *i = &b;
static char g;
static void l() {
d = 0;
for (; d < 4; d++)
for (; f; f++)
c = 0;
for (; c; c++)
;
}
static void k(unsigned short q) {
l();
for (; g; g++)
h = e == p;
}
static void j(int q) {
k(q);
unsigned char m = q;
o = m;
if (m)
foo();
}
void n() {
j(a);
*i = 0;
}
int main() {
n();
return 0;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug ipa/100100] missed optimization for dead code elimination at -O3 (vs. -O1, -Os, -O2)
2021-04-15 12:53 [Bug ipa/100100] New: missed optimization for dead code elimination at -O3 (vs. -O1, -Os, -O2) zhendong.su at inf dot ethz.ch
@ 2021-04-15 13:18 ` rguenth at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-15 13:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100100
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jamborm at gcc dot gnu.org
Version|unknown |11.0
Status|UNCONFIRMED |NEW
Keywords| |missed-optimization
Ever confirmed|0 |1
Last reconfirmed| |2021-04-15
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Different inlining somehow causes different CCP:
-;; Function n (n, funcdef_no=3, decl_uid=1980, cgraph_uid=4, symbol_order=14)
+;; Function j (j, funcdef_no=2, decl_uid=1977, cgraph_uid=3, symbol_order=13)
Adding destination of edge (0 -> 2) to worklist
Simulating block 2
Visiting statement:
-a.0_1 = a;
-which is likely CONSTANT
-Lattice value changed to CONSTANT 0. Adding SSA edges to worklist.
-marking stmt to be not simulated again
-
-Visiting statement:
-_6 = a.0_1 & 65535;
+_8 = q_2(D) & 65535;
which is likely CONSTANT
-Match-and-simplified a.0_1 & 65535 to 0
-Lattice value changed to CONSTANT 0. Adding SSA edges to worklist.
+Lattice value changed to CONSTANT 0x0 (0xffff). Adding SSA edges to worklist.
so we know 'a' is zero (after IPA) but at -O3 a is passed as parameter
(but IPA CP didn't figure out its constant value).
Still odd that the inlining decision is different.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-04-15 13:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-15 12:53 [Bug ipa/100100] New: missed optimization for dead code elimination at -O3 (vs. -O1, -Os, -O2) zhendong.su at inf dot ethz.ch
2021-04-15 13:18 ` [Bug ipa/100100] " 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).