Messages in this thread | | | Date | Mon, 26 Nov 2018 11:18:35 -1000 | From | Joey Pabalinas <> | Subject | Re: 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] | |