public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/100188] New: missed optimization for dead code elimination at -O3 (vs. -O1)
@ 2021-04-21 16:44 zhendong.su at inf dot ethz.ch
  2021-04-22  7:39 ` [Bug ipa/100188] " rguenth at gcc dot gnu.org
  2023-08-18  1:52 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2021-04-21 16:44 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100188
           Summary: missed optimization for dead code elimination at -O3
                    (vs. -O1)
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

[529] % 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 20210421 (experimental) [master revision
7f9b7ccf0c1:344da81f015:5445da1a94bb4df752209e54f4aa21702609a20a] (GCC) 
[530] % 
[530] % gcctk -O1 -S -o O1.s small.c
[531] % gcctk -O3 -S -o O3.s small.c
[532] % 
[532] % wc O1.s O3.s
 14  31 324 O1.s
 35  72 615 O3.s
 49 103 939 total
[533] % 
[533] % grep foo O1.s
[534] % grep foo O3.s
        jmp     foo
[535] % 
[535] % cat small.c
extern void foo(void);
static int b = 1, c, *f;
static int a() { return 0; }
static void d(int j) {
  int g, *h[36] = {&g, &g}, **i[1] = {&h[0]};
  if (!j) {
    c = 0;
    foo();
  }
}
int main() {
  int k[8];
  d(b);
  if (a())
    f = &k[0];
  return 0;
}

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

* [Bug ipa/100188] missed optimization for dead code elimination at -O3 (vs. -O1)
  2021-04-21 16:44 [Bug tree-optimization/100188] New: missed optimization for dead code elimination at -O3 (vs. -O1) zhendong.su at inf dot ethz.ch
@ 2021-04-22  7:39 ` rguenth at gcc dot gnu.org
  2023-08-18  1:52 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-22  7:39 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
            Version|unknown                     |12.0
                 CC|                            |marxin at gcc dot gnu.org
   Last reconfirmed|                            |2021-04-22
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
          Component|tree-optimization           |ipa

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
At -O3 we inline less, keeping the call to d() in main().  We then fail to
constant propagate the const promoted 'b'.

Not sure why IPA CP doesn't get it (promotion happens too late?).

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

* [Bug ipa/100188] missed optimization for dead code elimination at -O3 (vs. -O1)
  2021-04-21 16:44 [Bug tree-optimization/100188] New: missed optimization for dead code elimination at -O3 (vs. -O1) zhendong.su at inf dot ethz.ch
  2021-04-22  7:39 ` [Bug ipa/100188] " rguenth at gcc dot gnu.org
@ 2023-08-18  1:52 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-18  1:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
> At -O3 we inline less, keeping the call to d() in main().  We then fail to
> constant propagate the const promoted 'b'.

So yes we do inline less kinda of. At -O3, we inline a into main in einline
(but not at -O1) and this somehow allows us to inline d into main during the
IPA inline phase. 


> Not sure why IPA CP doesn't get it (promotion happens too late?).

Yes promotion to constant of b happens after IPA CP. I wonder if could run
static-var twice once before even eiline ...

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

end of thread, other threads:[~2023-08-18  1:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-21 16:44 [Bug tree-optimization/100188] New: missed optimization for dead code elimination at -O3 (vs. -O1) zhendong.su at inf dot ethz.ch
2021-04-22  7:39 ` [Bug ipa/100188] " rguenth at gcc dot gnu.org
2023-08-18  1:52 ` pinskia 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).