public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ipa/99862] New: [meta-issue] various missed optimizations for dead code elimination
@ 2021-04-01  7:59 zhendong.su at inf dot ethz.ch
  2021-04-01  8:01 ` [Bug ipa/99862] " zhendong.su at inf dot ethz.ch
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2021-04-01  7:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99862

            Bug ID: 99862
           Summary: [meta-issue] various missed optimizations for dead
                    code elimination
           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: ---

[561] % 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 20210401 (experimental) [master revision
e4bb1bd60a9:c23a685bf70:95d217ab52d31dc06fda42fc136dea165909e88b] (GCC) 
[562] % 
[562] % gcctk -O1 -S -o O1.s small.c
[563] % gcctk -O3 -S -o O3.s small.c
[564] % 
[564] % wc O1.s O3.s
  23   45  420 O1.s
  39   74  669 O3.s
  62  119 1089 total
[565] % 
[565] % grep foo O1.s
[566] % grep foo O3.s
        call    foo
[567] % 
[567] % cat small.c
extern void foo(void);
static int a, b;
static int c() {
  foo();
  while (1)
    while (b)
      foo();
}
void d() {
  if (a)
    c();
}
int main() {
  d();
  return 0;
}

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug ipa/99862] [meta-issue] various missed optimizations for dead code elimination
  2021-04-01  7:59 [Bug ipa/99862] New: [meta-issue] various missed optimizations for dead code elimination zhendong.su at inf dot ethz.ch
@ 2021-04-01  8:01 ` zhendong.su at inf dot ethz.ch
  2021-04-01  8:06 ` zhendong.su at inf dot ethz.ch
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2021-04-01  8:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99862

--- Comment #1 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
[578] % gcctk -O1 -S -o O1.s small.c
[579] % gcctk -O3 -S -o O3.s small.c
[580] % 
[580] % wc O1.s O3.s
  22   43  410 O1.s
  37   77  682 O3.s
  59  120 1092 total
[581] % 
[581] % grep foo O1.s
[582] % grep foo O3.s
        call    foo
[583] % 
[583] % cat small.c
extern void foo(void);
static int a, b;
static void c() {
  if (a) {
    foo();
    for (; b < 1; b++)
      ;
  }
}
int main() {
  c();
  c();
  return 0;
}

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug ipa/99862] [meta-issue] various missed optimizations for dead code elimination
  2021-04-01  7:59 [Bug ipa/99862] New: [meta-issue] various missed optimizations for dead code elimination zhendong.su at inf dot ethz.ch
  2021-04-01  8:01 ` [Bug ipa/99862] " zhendong.su at inf dot ethz.ch
@ 2021-04-01  8:06 ` zhendong.su at inf dot ethz.ch
  2021-04-02  0:28 ` egallager at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2021-04-01  8:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99862

--- Comment #2 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
[659] % gcctk -O1 -S -o O1.s small.c
[660] % gcctk -O3 -S -o O3.s small.c
[661] % 
[661] % wc O1.s O3.s
  40   86  599 O1.s
  68  138 1047 O3.s
 108  224 1646 total
[662] % 
[662] % grep foo O1.s
[663] % grep foo O3.s
        call    foo
[664] % 
[664] % cat small.c
extern void foo(void);
int a, b, *c;
static void d(int f) {
  if (f)
    foo();
}
static int e(int f) {
  int g[] = {2, 8, 2, 8, 2, 8, 2, 8, 2, 8, 2};
  int h[60];
  h[0] = g != c;
  if (b)
    while (a) {
      int *i[1] = {&h[6]};
    }
  return f;
}
static int *j(int *p) { return 0; }
int main () {
  int m = e(0);
  d(m);
  int l[8];
  if (j(l))
    while (1)
      ;
  return 0;
}

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug ipa/99862] [meta-issue] various missed optimizations for dead code elimination
  2021-04-01  7:59 [Bug ipa/99862] New: [meta-issue] various missed optimizations for dead code elimination zhendong.su at inf dot ethz.ch
  2021-04-01  8:01 ` [Bug ipa/99862] " zhendong.su at inf dot ethz.ch
  2021-04-01  8:06 ` zhendong.su at inf dot ethz.ch
@ 2021-04-02  0:28 ` egallager at gcc dot gnu.org
  2021-04-02 17:02 ` zhendong.su at inf dot ethz.ch
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: egallager at gcc dot gnu.org @ 2021-04-02  0:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99862

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |egallager at gcc dot gnu.org
           Keywords|                            |missed-optimization

--- Comment #3 from Eric Gallager <egallager at gcc dot gnu.org> ---
generally meta-bugs are created to collect other issues under their "Depends
On" field; do you have any other bug numbers to add here?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug ipa/99862] [meta-issue] various missed optimizations for dead code elimination
  2021-04-01  7:59 [Bug ipa/99862] New: [meta-issue] various missed optimizations for dead code elimination zhendong.su at inf dot ethz.ch
                   ` (2 preceding siblings ...)
  2021-04-02  0:28 ` egallager at gcc dot gnu.org
@ 2021-04-02 17:02 ` zhendong.su at inf dot ethz.ch
  2021-04-09 11:37 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2021-04-02 17:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99862

--- Comment #4 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
(In reply to Eric Gallager from comment #3)
> generally meta-bugs are created to collect other issues under their "Depends
> On" field; do you have any other bug numbers to add here?

Hi Eric, no, I don't, but all these instances are related in the sense that
they all show missed optimizations for dead code. Instead of filing them
separately, I thought it might work better if I file them together as a meta
issue. 

If you folks prefer these being filed separately, I'm also happy to do so. 

Please just let me know whichever works better; thanks. 

(See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99834#c2)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug ipa/99862] [meta-issue] various missed optimizations for dead code elimination
  2021-04-01  7:59 [Bug ipa/99862] New: [meta-issue] various missed optimizations for dead code elimination zhendong.su at inf dot ethz.ch
                   ` (3 preceding siblings ...)
  2021-04-02 17:02 ` zhendong.su at inf dot ethz.ch
@ 2021-04-09 11:37 ` rguenth at gcc dot gnu.org
  2021-04-09 11:39 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-09 11:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99862

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Zhendong Su from comment #0)
> [561] % 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 20210401 (experimental) [master revision
> e4bb1bd60a9:c23a685bf70:95d217ab52d31dc06fda42fc136dea165909e88b] (GCC) 
> [562] % 
> [562] % gcctk -O1 -S -o O1.s small.c
> [563] % gcctk -O3 -S -o O3.s small.c
> [564] % 
> [564] % wc O1.s O3.s
>   23   45  420 O1.s
>   39   74  669 O3.s
>   62  119 1089 total
> [565] % 
> [565] % grep foo O1.s
> [566] % grep foo O3.s
>         call    foo
> [567] % 
> [567] % cat small.c
> extern void foo(void);
> static int a, b;
> static int c() {
>   foo();
>   while (1)
>     while (b)
>       foo();
> }
> void d() {
>   if (a)
>     c();
> }
> int main() {
>   d();
>   return 0;
> }

I filed this as PR99991.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug ipa/99862] [meta-issue] various missed optimizations for dead code elimination
  2021-04-01  7:59 [Bug ipa/99862] New: [meta-issue] various missed optimizations for dead code elimination zhendong.su at inf dot ethz.ch
                   ` (4 preceding siblings ...)
  2021-04-09 11:37 ` rguenth at gcc dot gnu.org
@ 2021-04-09 11:39 ` rguenth at gcc dot gnu.org
  2021-04-09 11:42 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-09 11:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99862

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Zhendong Su from comment #1)
> [578] % gcctk -O1 -S -o O1.s small.c
> [579] % gcctk -O3 -S -o O3.s small.c
> [580] % 
> [580] % wc O1.s O3.s
>   22   43  410 O1.s
>   37   77  682 O3.s
>   59  120 1092 total
> [581] % 
> [581] % grep foo O1.s
> [582] % grep foo O3.s
>         call    foo
> [583] % 
> [583] % cat small.c
> extern void foo(void);
> static int a, b;
> static void c() {
>   if (a) {
>     foo();
>     for (; b < 1; b++)
>       ;
>   }
> }
> int main() {
>   c();
>   c();
>   return 0;
> }

This is another case of failing to elide a no longer called function.  We
end up partially inlining c() at -O3, inlining the if (a) head and thus
we eliminate the calls to c() in main rather than the call to foo in c().

I'd say the -O3 result is superior but still we fail to remove the
c.part() function definition from the assembly.  We have duplicates for this
case.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug ipa/99862] [meta-issue] various missed optimizations for dead code elimination
  2021-04-01  7:59 [Bug ipa/99862] New: [meta-issue] various missed optimizations for dead code elimination zhendong.su at inf dot ethz.ch
                   ` (5 preceding siblings ...)
  2021-04-09 11:39 ` rguenth at gcc dot gnu.org
@ 2021-04-09 11:42 ` rguenth at gcc dot gnu.org
  2021-04-09 11:53 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-09 11:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99862

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Zhendong Su from comment #2)
> [659] % gcctk -O1 -S -o O1.s small.c
> [660] % gcctk -O3 -S -o O3.s small.c
> [661] % 
> [661] % wc O1.s O3.s
>   40   86  599 O1.s
>   68  138 1047 O3.s
>  108  224 1646 total
> [662] % 
> [662] % grep foo O1.s
> [663] % grep foo O3.s
>         call    foo
> [664] % 
> [664] % cat small.c
> extern void foo(void);
> int a, b, *c;
> static void d(int f) {
>   if (f)
>     foo();
> }
> static int e(int f) {
>   int g[] = {2, 8, 2, 8, 2, 8, 2, 8, 2, 8, 2};
>   int h[60];
>   h[0] = g != c;
>   if (b)
>     while (a) {
>       int *i[1] = {&h[6]};
>     }
>   return f;
> }
> static int *j(int *p) { return 0; }
> int main () {
>   int m = e(0);
>   d(m);
>   int l[8];
>   if (j(l))
>     while (1)
>       ;
>   return 0;
> }

This is a case similar to PR99991, we create a IPA CP clone and fail to inline
that at -O3 while we are happy to IPA inline e() at -O1.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug ipa/99862] [meta-issue] various missed optimizations for dead code elimination
  2021-04-01  7:59 [Bug ipa/99862] New: [meta-issue] various missed optimizations for dead code elimination zhendong.su at inf dot ethz.ch
                   ` (6 preceding siblings ...)
  2021-04-09 11:42 ` rguenth at gcc dot gnu.org
@ 2021-04-09 11:53 ` rguenth at gcc dot gnu.org
  2021-04-09 11:59 ` zhendong.su at inf dot ethz.ch
  2021-04-10 10:12 ` egallager at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-09 11:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99862

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #7)
> (In reply to Zhendong Su from comment #2)
> > [659] % gcctk -O1 -S -o O1.s small.c
> > [660] % gcctk -O3 -S -o O3.s small.c
> > [661] % 
> > [661] % wc O1.s O3.s
> >   40   86  599 O1.s
> >   68  138 1047 O3.s
> >  108  224 1646 total
> > [662] % 
> > [662] % grep foo O1.s
> > [663] % grep foo O3.s
> >         call    foo
> > [664] % 
> > [664] % cat small.c
> > extern void foo(void);
> > int a, b, *c;
> > static void d(int f) {
> >   if (f)
> >     foo();
> > }
> > static int e(int f) {
> >   int g[] = {2, 8, 2, 8, 2, 8, 2, 8, 2, 8, 2};
> >   int h[60];
> >   h[0] = g != c;
> >   if (b)
> >     while (a) {
> >       int *i[1] = {&h[6]};
> >     }
> >   return f;
> > }
> > static int *j(int *p) { return 0; }
> > int main () {
> >   int m = e(0);
> >   d(m);
> >   int l[8];
> >   if (j(l))
> >     while (1)
> >       ;
> >   return 0;
> > }
> 
> This is a case similar to PR99991, we create a IPA CP clone and fail to
> inline
> that at -O3 while we are happy to IPA inline e() at -O1.

I filed PR99993 for it.

For the future please open separate bugs for separate testcases.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug ipa/99862] [meta-issue] various missed optimizations for dead code elimination
  2021-04-01  7:59 [Bug ipa/99862] New: [meta-issue] various missed optimizations for dead code elimination zhendong.su at inf dot ethz.ch
                   ` (7 preceding siblings ...)
  2021-04-09 11:53 ` rguenth at gcc dot gnu.org
@ 2021-04-09 11:59 ` zhendong.su at inf dot ethz.ch
  2021-04-10 10:12 ` egallager at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2021-04-09 11:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99862

--- Comment #9 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
> For the future please open separate bugs for separate testcases.

Thanks, Richard; will do.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug ipa/99862] [meta-issue] various missed optimizations for dead code elimination
  2021-04-01  7:59 [Bug ipa/99862] New: [meta-issue] various missed optimizations for dead code elimination zhendong.su at inf dot ethz.ch
                   ` (8 preceding siblings ...)
  2021-04-09 11:59 ` zhendong.su at inf dot ethz.ch
@ 2021-04-10 10:12 ` egallager at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: egallager at gcc dot gnu.org @ 2021-04-10 10:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99862

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |meta-bug

--- Comment #10 from Eric Gallager <egallager at gcc dot gnu.org> ---
ok now that this depends on other bugs I'm adding the "meta-bug" keyword

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-04-10 10:12 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-01  7:59 [Bug ipa/99862] New: [meta-issue] various missed optimizations for dead code elimination zhendong.su at inf dot ethz.ch
2021-04-01  8:01 ` [Bug ipa/99862] " zhendong.su at inf dot ethz.ch
2021-04-01  8:06 ` zhendong.su at inf dot ethz.ch
2021-04-02  0:28 ` egallager at gcc dot gnu.org
2021-04-02 17:02 ` zhendong.su at inf dot ethz.ch
2021-04-09 11:37 ` rguenth at gcc dot gnu.org
2021-04-09 11:39 ` rguenth at gcc dot gnu.org
2021-04-09 11:42 ` rguenth at gcc dot gnu.org
2021-04-09 11:53 ` rguenth at gcc dot gnu.org
2021-04-09 11:59 ` zhendong.su at inf dot ethz.ch
2021-04-10 10:12 ` egallager 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).