From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9911 invoked by alias); 1 Sep 2004 23:31:55 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 9904 invoked by uid 48); 1 Sep 2004 23:31:54 -0000 Date: Wed, 01 Sep 2004 23:31:00 -0000 From: "msharov at talentg dot com" To: gcc-bugs@gcc.gnu.org Message-ID: <20040901233152.17272.msharov@talentg.com> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug inline-asm/17272] New: Extra store emitted when concatenating inline assembly sections. X-Bugzilla-Reason: CC X-SW-Source: 2004-09/txt/msg00106.txt.bz2 List-Id: When two inline functions with assembly sections are concatenated, a superfluous store is emitted between the two calls. Consider the attached code, where inline functions padd and psub are called in succession from main(). The optimizer correctly recognizes that the first argument is the same for both calls and does not touch %dl once it is set. Then the there is that store between calls even though the compiler should know that both v1 and v2 are local and not volatile, and are not expected to be kept up to date after every instruction. It should also know that the value is overwritten again after only one instruction. Although the extra store is not in itself harmful, removing it would improve performance. ============================================================ inline void padd (const char* p, char* r) { asm ("addb %1, %0" : "=&r"(*r) : "r"(*p), "0"(*r)); } inline void psub (const char* p, char* r) { asm ("subb %1, %0" : "=&r"(*r) : "r"(*p), "0"(*r)); } int main (void) { char v1[8] = "v1"; char v2[8] = "v2"; padd (v1, v2); psub (v1, v2); return (v2[0]); } ============================================================ -O3 -march=athlon-mp ============================================================ main: pushl %ebp movl %esp, %ebp pushl %ebx subl $4, %esp movl .LC1, %eax movzbl .LC0, %edx andl $-16, %esp subl $16, %esp movl %eax, %ebx #APP addb %dl, %bl #NO_APP movb %bl, %al <<< Unneeded #APP subb %dl, %bl #NO_APP movb %bl, %al <<< Overwritten here movl -4(%ebp), %ebx leave movsbl %al,%eax ret ============================================================ -- Summary: Extra store emitted when concatenating inline assembly sections. Product: gcc Version: 3.4.1 Status: UNCONFIRMED Severity: minor Priority: P3 Component: inline-asm AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: msharov at talentg dot com CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: athlon-gnu-linux GCC host triplet: athlon-gnu-linux GCC target triplet: athlon-gnu-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17272