From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27164 invoked by alias); 1 Feb 2011 21:36:15 -0000 Received: (qmail 27149 invoked by uid 22791); 1 Feb 2011 21:36:14 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,SARE_SUB_OBFU_Q0,TW_CP,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; Tue, 01 Feb 2011 21:36:10 +0000 From: "tony.poppleton at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/47582] New: Combine chains of movl into movq 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: enhancement X-Bugzilla-Who: tony.poppleton at gmail dot com 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: Tue, 01 Feb 2011 21:36: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-02/txt/msg00200.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47582 Summary: Combine chains of movl into movq Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: rtl-optimization AssignedTo: unassigned@gcc.gnu.org ReportedBy: tony.poppleton@gmail.com The following C code (adapted from http://stackoverflow.com/questions/4544804/in-what-cases-should-i-use-memcpy-over-standard-operators-in-c) shows that adjacent sequences of movl could be combined into movq. extern float a[5]; extern float b[5]; int main() { #if defined(M1) a[0] = b[0]; a[1] = b[1]; a[2] = b[2]; a[3] = b[3]; a[4] = b[4]; #elif defined(M2) memcpy(a, b, 5*sizeof(float)); #endif } When compiled with "-O2 -fomit-frame-pointer" on GCC 4.3.5, 4.4.5, 4.5.2 and 4.6.0 (20110129), the following asm is produced for the -DM1 branch: movl b(%rip), %eax movl %eax, a(%rip) movl b+4(%rip), %eax movl %eax, a+4(%rip) movl b+8(%rip), %eax movl %eax, a+8(%rip) movl b+12(%rip), %eax movl %eax, a+12(%rip) movl b+16(%rip), %eax movl %eax, a+16(%rip) ret However for the -DM2 branch, the memcpy implementation shows that this can be done more efficiently: movq b(%rip), %rax movq %rax, a(%rip) movq b+8(%rip), %rax movq %rax, a+8(%rip) movl b+16(%rip), %eax movl %eax, a+16(%rip) ret I presume that the memcpy is being done in hand-written asm? If so, then once this enhancment is done, then presumably that portion of memcpy code could be converted to C code and be just as efficient.