public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "aldot at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/65534] New: tailcall not optimized away
Date: Tue, 24 Mar 2015 02:19:00 -0000	[thread overview]
Message-ID: <bug-65534-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 65534
           Summary: tailcall not optimized away
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: aldot at gcc dot gnu.org
                CC: hubicka at ucw dot cz, rguenth at gcc dot gnu.org

Maybe this could be optimized by a thunk or by creating the alias automatically
or the like? Or is tailcall supposed to do this already?

trunk@221345
$ gcc -Os -c missed-opt.c -o missed-opt.plain.o
$ gcc -Os -c missed-opt.c -o missed-opt.manual.o -DOPTIMIZE_MANUALLY
$ size missed-opt.*.o
   text       data        bss        dec        hex    filename
     86          0          0         86         56    missed-opt.manual.o
    104          0          0        104         68    missed-opt.plain.o

$ cat missed-opt.c ; echo EOF
static int fd = -1;
extern void dummy0(void);
extern void dummy1(int);
extern void setutent(void) __attribute__ ((__nothrow__ ));
extern __typeof (setutent) setutent __asm__ ("" "__GI_setutent")
    __attribute__ ((visibility ("hidden")));
extern void getutent(void) __attribute__ ((__nothrow__ ));
extern __typeof (getutent) getutent __asm__ ("" "__GI_getutent")
    __attribute__ ((visibility ("hidden")));
static void __setutent_unlocked(void) {
    if (fd < 0) {
        dummy0();
        if (fd < 0) {
            dummy0();
            if (fd < 0)
                return;
        }
        return;
    }
    dummy1(fd);
}
#ifndef OPTIMIZE_MANUALLY
void setutent(void) {
    ((void)0);
    __setutent_unlocked();
    ((void)0);
}
#else
extern __typeof (__setutent_unlocked) setutent
    __attribute__ ((alias ("__setutent_unlocked")));
#endif
extern __typeof (setutent) __EI_setutent __asm__("" "setutent");
extern __typeof (setutent) __EI_setutent
    __attribute__((alias ("" "__GI_setutent")));

static void __getutent_unlocked(void) {
    if (fd < 0)
        __setutent_unlocked();
}

#ifndef OPTIMIZE_MANUALLY
void getutent(void) {
    ((void)0);
    __getutent_unlocked();
    ((void)0);
}
#else
extern __typeof (__getutent_unlocked) getutent
    __attribute__ ((alias ("__getutent_unlocked")));
#endif
extern __typeof (getutent) __EI_getutent __asm__("" "getutent");
extern __typeof (getutent) __EI_getutent
    __attribute__((alias ("" "__GI_getutent")));

EOF


             reply	other threads:[~2015-03-23 23:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-24  2:19 aldot at gcc dot gnu.org [this message]
2015-03-24  7:12 ` [Bug middle-end/65534] " hubicka at ucw dot cz
2015-03-24  7:21 ` hubicka at gcc dot gnu.org
2015-07-09 13:21 ` aldot at gcc dot gnu.org
2021-05-04 12:31 ` rguenth at gcc dot gnu.org
2023-03-31 11:56 ` marxin 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-65534-4@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).