public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "zhendong.su at inf dot ethz.ch" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ipa/99373] unused static function not being removed in some cases after optimization
Date: Fri, 05 Mar 2021 00:00:46 +0000	[thread overview]
Message-ID: <bug-99373-4-0SId8um3PK@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99373-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
The following might be the same/related. The dead call is eliminated if b is
changed to:

static int b(int *c) {
    foo();
    d++;
}

[623] % gcctk -O3 -S small.c
[624] %
[624] % cat small.c
extern void foo(void);

static int a, d;

static int b(int *c) {
  while (1) {
    foo();
    d++;
  }
}

int main () {
  a && b(&a);
  return 0;
}
[625] %
[625] % cat small.s
        .file   "small.c"
        .text
        .section        .text.startup,"ax",@progbits
        .p2align 4
        .globl  main
        .type   main, @function
main:
.LFB1:  
        .cfi_startproc
        movl    a(%rip), %edx
        testl   %edx, %edx
        jne     .L7
        xorl    %eax, %eax
        ret
.L7:
        pushq   %rax
        .cfi_def_cfa_offset 16
.L3:
        call    foo
        addl    $1, d(%rip)
        jmp     .L3
        .cfi_endproc
.LFE1:  
        .size   main, .-main
        .local  d
        .comm   d,4,4
        .local  a
        .comm   a,4,4
        .ident  "GCC: (GNU) 11.0.1 20210304 (experimental) [master revision
cdfc2f6a6dc:ab3cea6cccd:f3641ac70eb0ae9f8983b7ddb1660c92439565de]"
        .section        .note.GNU-stack,"",@progbits

  parent reply	other threads:[~2021-03-05  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-03 23:11 [Bug ipa/99373] New: [missed optimization] dead code not eliminated from short circuiting zhendong.su at inf dot ethz.ch
2021-03-04  0:06 ` [Bug ipa/99373] unused static function not being removed in some cases after optimization pinskia at gcc dot gnu.org
2021-03-04  8:44 ` rguenth at gcc dot gnu.org
2021-03-05  0:00 ` zhendong.su at inf dot ethz.ch [this message]
2023-01-10 18:25 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-99373-4-0SId8um3PK@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).