From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12526 invoked by alias); 5 May 2011 13:34:00 -0000 Received: (qmail 12375 invoked by uid 22791); 5 May 2011 13:33:57 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_OV X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 05 May 2011 13:33:38 +0000 From: "etienne_lorrain at yahoo dot fr" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/48888] New: Creating a copy variable simplify assembly - i686-pc-linux-gnu X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: etienne_lorrain at yahoo dot fr X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Thu, 05 May 2011 13:34:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-05/txt/msg00454.txt.bz2 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 } }