public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/64907] New: Suboptimal code (saving rbx on stack in order to save another reg in rbx)
@ 2015-02-02 18:36 vda.linux at googlemail dot com
  2015-02-02 19:09 ` [Bug rtl-optimization/64907] " hjl.tools at gmail dot com
  0 siblings, 1 reply; 2+ messages in thread
From: vda.linux at googlemail dot com @ 2015-02-02 18:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64907

            Bug ID: 64907
           Summary: Suboptimal code (saving rbx on stack in order to save
                    another reg in rbx)
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vda.linux at googlemail dot com

void put_16bit(unsigned short v);
void put_32bit(unsigned v)
{
        put_16bit(v);
        put_16bit(v >> 16);
}

With gcc 4.7.2 the above compiles to the following assembly:

put_32bit:
        pushq   %rbx
        movl    %edi, %ebx
        andl    $65535, %edi
        call    put_16bit
        movl    %ebx, %edi
        popq    %rbx
        shrl    $16, %edi
        jmp     put_16bit

Code saves %rbx on stack only in order to save %edi to %ebx.
A simpler alternative is to just save %rdi on stack:

put_32bit:
        pushq   %rdi
        andl    $65535, %edi
        call    put_16bit
        popq    %rdi
        shrl    $16, %edi
        jmp     put_16bit


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

* [Bug rtl-optimization/64907] Suboptimal code (saving rbx on stack in order to save another reg in rbx)
  2015-02-02 18:36 [Bug rtl-optimization/64907] New: Suboptimal code (saving rbx on stack in order to save another reg in rbx) vda.linux at googlemail dot com
@ 2015-02-02 19:09 ` hjl.tools at gmail dot com
  0 siblings, 0 replies; 2+ messages in thread
From: hjl.tools at gmail dot com @ 2015-02-02 19:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64907

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-02-02
                 CC|                            |vmakarov at redhat dot com
            Version|4.7.2                       |5.0
     Ever confirmed|0                           |1

--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
Still happens with 5.0.


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

end of thread, other threads:[~2015-02-02 19:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-02 18:36 [Bug rtl-optimization/64907] New: Suboptimal code (saving rbx on stack in order to save another reg in rbx) vda.linux at googlemail dot com
2015-02-02 19:09 ` [Bug rtl-optimization/64907] " hjl.tools at gmail dot com

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).