public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method
@ 2011-01-26 16:54 tony.poppleton at gmail dot com
  2011-01-27  7:08 ` [Bug rtl-optimization/47477] " hjl.tools at gmail dot com
                   ` (27 more replies)
  0 siblings, 28 replies; 29+ messages in thread
From: tony.poppleton at gmail dot com @ 2011-01-26 16:54 UTC (permalink / raw)
  To: gcc-bugs

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.


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

end of thread, other threads:[~2015-06-26 20:35 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
2011-01-27  7:08 ` [Bug rtl-optimization/47477] " hjl.tools at gmail dot com
2011-01-27 11:51 ` rguenth at gcc dot gnu.org
2011-01-27 17:34 ` jakub at gcc dot gnu.org
2011-01-27 17:58 ` jakub at gcc dot gnu.org
2011-01-27 19:43 ` tony.poppleton at gmail dot com
2011-01-28 11:31 ` rguenth at gcc dot gnu.org
2011-01-29 20:37 ` jakub at gcc dot gnu.org
2011-02-08 14:40 ` rguenth at gcc dot gnu.org
2011-02-08 14:41 ` rguenth at gcc dot gnu.org
2011-02-21 16:19 ` jakub at gcc dot gnu.org
2012-01-02 11:36 ` [Bug rtl-optimization/47477] [4.6/4.7/4.8 " jakub at gcc dot gnu.org
2012-03-06 12:48 ` jakub at gcc dot gnu.org
2012-11-30 16:27 ` jakub at gcc dot gnu.org
2013-03-22 14:46 ` [Bug rtl-optimization/47477] [4.6/4.7/4.8/4.9 " jakub at gcc dot gnu.org
2013-04-10  1:44 ` tony.poppleton at gmail dot com
2013-05-31 11:03 ` [Bug rtl-optimization/47477] [4.7/4.8/4.9 " jakub at gcc dot gnu.org
2013-10-16  9:49 ` jakub at gcc dot gnu.org
2013-10-22 13:40 ` jakub at gcc dot gnu.org
2013-10-22 14:18 ` ktietz at gcc dot gnu.org
2013-10-22 14:56 ` jakub at gcc dot gnu.org
2014-05-22  9:07 ` [Bug rtl-optimization/47477] [4.7/4.8/4.9/4.10 " rguenth at gcc dot gnu.org
2014-12-19 13:40 ` [Bug rtl-optimization/47477] [4.8/4.9/5 " jakub at gcc dot gnu.org
2015-02-13 20:18 ` law at gcc dot gnu.org
2015-02-13 20:20 ` [Bug rtl-optimization/47477] [4.8/4.9 " law at redhat dot com
2015-02-17  5:22 ` law at redhat dot com
2015-06-23  8:20 ` rguenth at gcc dot gnu.org
2015-06-26 20:13 ` [Bug rtl-optimization/47477] [4.9 " jakub at gcc dot gnu.org
2015-06-26 20:35 ` jakub 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).