public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/48888] New: Creating a copy variable simplify assembly - i686-pc-linux-gnu
@ 2011-05-05 13:34 etienne_lorrain at yahoo dot fr
  2011-12-16  0:20 ` [Bug middle-end/48888] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: etienne_lorrain at yahoo dot fr @ 2011-05-05 13:34 UTC (permalink / raw)
  To: gcc-bugs

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
      }
  }


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

* [Bug middle-end/48888] Creating a copy variable simplify assembly - i686-pc-linux-gnu
  2011-05-05 13:34 [Bug rtl-optimization/48888] New: Creating a copy variable simplify assembly - i686-pc-linux-gnu etienne_lorrain at yahoo dot fr
@ 2011-12-16  0:20 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-12-16  0:20 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |missed-optimization
   Last reconfirmed|                            |2011-12-16
          Component|rtl-optimization            |middle-end
     Ever Confirmed|0                           |1
           Severity|normal                      |enhancement

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-12-16 00:18:53 UTC ---
Looks like TER is happening in one case but not the other.


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

end of thread, other threads:[~2011-12-16  0:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-05 13:34 [Bug rtl-optimization/48888] New: Creating a copy variable simplify assembly - i686-pc-linux-gnu etienne_lorrain at yahoo dot fr
2011-12-16  0:20 ` [Bug middle-end/48888] " 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).