lkml.org 
[lkml]   [2018]   [Nov]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Re: [PATCH] Little memset_explicit optimisation
On Mon, Nov 26, 2018 at 07:36:19PM +0000, David CARLIER wrote:
> Sorry I m not used yet at all to LKML rules.
>
> So here a slight difference in assembly generated between the two
> versions (amd64) :
> `
> .loc 1 7 7
> leaq -12(%rbp), %rax
> movq %rax, -8(%rbp)
> - .loc 1 11 2
> + .loc 1 9 6
> movq -8(%rbp), %rax
> movl $4, %edx
> movl $0, %esi
> movq %rax, %rdi
> call memset@PLT
> + movq %rax, -8(%rbp)
> .loc 1 13 23
> movq -8(%rbp), %rax
> movl (%rax), %eax

What is the advantage of having the added `movq %rax, -8(%rbp)` here?

The next instruction is `movq -8(%rbp), %rax` and nothing afterwords
uses the value stored in `-8(%rbp)`.

Also, is this compiled without optimization? Take a looks at the
assembly in a small test case with -O1 (making sure to use the target
variable so it isn't optimized out) and compare the assembly generated
with and without that assignment.

--
Cheers,
Joey Pabalinas
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2018-11-26 22:19    [W:0.092 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site