public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "etienne_lorrain at yahoo dot fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/48888] New: Creating a copy variable simplify assembly - i686-pc-linux-gnu
Date: Thu, 05 May 2011 13:34:00 -0000	[thread overview]
Message-ID: <bug-48888-4@http.gcc.gnu.org/bugzilla/> (raw)

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48888

           Summary: Creating a copy variable simplify assembly -
                    i686-pc-linux-gnu
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: etienne_lorrain@yahoo.fr


Hello,

Compiling the following C code on GCC-4.6.0 with or without BAD defined leads
to a different
assembly generated, more specifically 
$ /home/etienne/projet/toolchain/bin/gcc -Os -fomit-frame-pointer -S tmp.c -o
tmp.s -DBAD
generates near the end of tmp.s:
    movl    UI_function, %edx
    movb    %al, (%esp)
    call    *%edx
and compiling with:
$ /home/etienne/projet/toolchain/bin/gcc -Os -fomit-frame-pointer -S tmp.c -o
tmp.s
generates the simplest assembly:
    movb    %al, (%esp)
    call    *UI_function
$ /home/etienne/projet/toolchain/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/home/etienne/projet/toolchain/bin/gcc
COLLECT_LTO_WRAPPER=/home/etienne/projet/toolchain/libexec/gcc/i686-pc-linux-gnu/4.6.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../configure --prefix=/home/etienne/projet/toolchain
--enable-languages=c --with-gmp=/home/etienne/projet/toolchain
--disable-multilib --disable-threads --enable-tls
Thread model: single
gcc version 4.6.0 (GCC)

Unfortunately for me I need to post-process those "call *UI" to replace them by
"lcallw *UI",
and "lcallw *%edx" do not work - anyway I have the solution for those few
cases.
This problem is not new (seen at least in 4.5) and appears unfrequently, but it
seems that
something strange is going on, the two version should generate the same
assembly...

struct attribute_str {
    unsigned char underline     :1;
    unsigned char reverse       :1;
    unsigned char blink         :1;
    unsigned char other         :5;
    } __attribute__ ((packed)) UI_attributes_current;

struct user_interface_fct_str {
    void     (*setattribute) (struct attribute_str attr);
    void     (*putstr) (const char *str);
    } UI_function;

extern unsigned UI_parameter_nbcol;

void print (const char *src, unsigned active, unsigned row, unsigned col)
  {
  char displayed[UI_parameter_nbcol], *dst = displayed;

  if (!src)
      return;
  for (;;) {
      if (!active && *src == '<')
          *dst++ = '(';
        else
          *dst++ = *src;
      if (*src++ == '\0')
          break;
      }

  struct attribute_str saved_attr = UI_attributes_current;

  UI_function.putstr (displayed);

  if (memcmp (&saved_attr, &UI_attributes_current, sizeof (struct
attribute_str))) {
#ifdef BAD 
      UI_function.setattribute (saved_attr);
#else
      /* Write it this way else GCC-4.6.0 uses "movl
UI.function.setattribute,%edx ; call *%edx" */
      struct attribute_str newattr = saved_attr;
      UI_function.setattribute (newattr);
#endif
      }
  }


             reply	other threads:[~2011-05-05 13:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-05 13:34 etienne_lorrain at yahoo dot fr [this message]
2011-12-16  0:20 ` [Bug middle-end/48888] " 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-48888-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).