From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9707 invoked by alias); 26 Jan 2011 16:43:21 -0000 Received: (qmail 9684 invoked by uid 22791); 26 Jan 2011 16:43:18 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 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; Wed, 26 Jan 2011 16:43:14 +0000 From: "tony.poppleton at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method 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: 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: Wed, 26 Jan 2011 16:54: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-01/txt/msg02849.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477 Summary: [4.6 regression] Sub-optimal mov at end of method Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization AssignedTo: unassigned@gcc.gnu.org ReportedBy: tony.poppleton@gmail.com Host: Linux x86-64 Whilst investigating PR35926, I noticed a slight inefficiency in code generated by 4.6.0 (20110115) versus that of 4.5.1. Duplicating the C code here from that PR for easy reference: typedef struct toto_s *toto_t; toto_t add (toto_t a, toto_t b) { int64_t tmp = (int64_t)(intptr_t)a + ((int64_t)(intptr_t)b&~1L); return (toto_t)(intptr_t) tmp; } The ASM generated by 4.6.0 with flags -O3 is: .file "PR35926.c" .text .p2align 4,,15 .globl add .type add, @function add: .LFB0: .cfi_startproc pushl %ebx .cfi_def_cfa_offset 8 .cfi_offset 3, -8 movl 12(%esp), %eax movl 8(%esp), %ecx popl %ebx .cfi_def_cfa_offset 4 .cfi_restore 3 andl $-2, %eax addl %eax, %ecx <==== order of regs inverted movl %ecx, %eax <==== resulting in unnecessary movl ret .cfi_endproc .LFE0: .size add, .-add .ident "GCC: (GNU) 4.6.0 20110115 (experimental)" .section .note.GNU-stack,"",@progbits In 4.5.1, the last bit is one instruction shorter, with just: addl %ecx, %eax ret A bug search revealed a similar sounding PR44249, however that is a regression in 4.5 too apparently, yet this only affects 4.6.