public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Daniel Santos <daniel.santos@pobox.com>
To: Florian Weimer <fweimer@redhat.com>, gcc <gcc@gcc.gnu.org>
Subject: Re: Help with implementing Wine optimization experiment
Date: Wed, 17 Aug 2016 22:56:00 -0000	[thread overview]
Message-ID: <7d0aada7-1fe7-5576-1256-292ad5b74a38@pobox.com> (raw)
In-Reply-To: <1515c893-ed7e-2a32-ec46-7494e288c307@redhat.com>

On 08/15/2016 05:46 AM, Florian Weimer wrote:
> On 08/14/2016 08:23 AM, Daniel Santos wrote:
>>
>> ms_abi_push_regs:
>>     pop    %rax
>>     push   %rdi
>>     push   %rsi
>>     sub    $0xa8,%rsp
>>     movaps %xmm6,(%rsp)
>>     movaps %xmm7,0x10(%rsp)
>>     movaps %xmm8,0x20(%rsp)
>>     movaps %xmm9,0x30(%rsp)
>>     movaps %xmm10,0x40(%rsp)
>>     movaps %xmm11,0x50(%rsp)
>>     movaps %xmm12,0x60(%rsp)
>>     movaps %xmm13,0x70(%rsp)
>>     movaps %xmm14,0x80(%rsp)
>>     movaps %xmm15,0x90(%rsp)
>>     jmp   *(%rax)
>
> I think this will be quite slow because it breaks the return stack 
> optimization in the CPU.  I think you should push the return address 
> and use RET.
>
> Florian
>

Looks like I forgot to reply-all on my last reply, but thanks again for 
the advice here. Would there be any performance hit to reshuffling the 
push/pops to save the 8 byte alignment padding? My assumption is that 
the stack will always be 16-byte aligned with the 8-byte return address 
of the last call on it, so offset by 8 bytes. (Also, not sure that I 
need the .type directive, was copying other code in libgcc :)

     .text
     .global __msabi_save
     .hidden    __msabi_save

#ifdef __ELF__
     .type    __msabi_save,@function
#endif

/* TODO: implement vmovaps when supported?*/
__msabi_save:
#ifdef __x86_64__
     pop    %rax
     push   %rdi
     sub    $0xa0,%rsp
     movaps %xmm6,(%rsp)
     movaps %xmm7,0x10(%rsp)
     movaps %xmm8,0x20(%rsp)
     movaps %xmm9,0x30(%rsp)
     movaps %xmm10,0x40(%rsp)
     movaps %xmm11,0x50(%rsp)
     movaps %xmm12,0x60(%rsp)
     movaps %xmm13,0x70(%rsp)
     movaps %xmm14,0x80(%rsp)
     movaps %xmm15,0x90(%rsp)
     push   %rsi
     push   %rax
#endif /* __x86_64__ */
     ret

     .text
     .global __msabi_restore
     .hidden    __msabi_restore
#ifdef __ELF__
     .type    __msabi_restore,@function
#endif

__msabi_restore:
#ifdef __x86_64__
     pop    %rsi
     movaps (%rsp),%xmm6
     movaps 0x10(%rsp),%xmm7
     movaps 0x20(%rsp),%xmm8
     movaps 0x30(%rsp),%xmm9
     movaps 0x40(%rsp),%xmm10
     movaps 0x50(%rsp),%xmm11
     movaps 0x60(%rsp),%xmm12
     movaps 0x70(%rsp),%xmm13
     movaps 0x80(%rsp),%xmm14
     movaps 0x90(%rsp),%xmm15
     add    $0xa0,%rsp
     pop    %rdi
#endif /* __x86_64__ */
     ret

Thanks!
Daniel

  reply	other threads:[~2016-08-17 22:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-14  6:20 Daniel Santos
2016-08-14  7:46 ` Daniel Santos
2016-08-14  7:49 ` Trevor Saunders
2016-08-15  0:16   ` Jeff Law
2016-08-15 10:56     ` Richard Biener
2016-08-16  4:21       ` Daniel Santos
2016-08-15 10:47 ` Florian Weimer
2016-08-17 22:56   ` Daniel Santos [this message]
2016-08-15 11:36 ` André Hentschel
2016-08-16  3:13   ` Daniel Santos
2016-08-17 23:04 ` Daniel Santos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7d0aada7-1fe7-5576-1256-292ad5b74a38@pobox.com \
    --to=daniel.santos@pobox.com \
    --cc=fweimer@redhat.com \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).