Skip rep movsb in copy_backward if possible
There is currently no measureable performance difference in benchmarks but it likely will make a difference in real workloads.
This commit is contained in:
parent
30e0c1f4c2
commit
04c223f0df
1 changed files with 6 additions and 0 deletions
|
|
@ -73,15 +73,21 @@ pub unsafe fn copy_backward(dest: *mut u8, src: *const u8, count: usize) {
|
|||
// We can't separate this block due to std/cld
|
||||
asm!(
|
||||
"std",
|
||||
"test %ecx, %ecx",
|
||||
"jz 1f",
|
||||
"rep movsb",
|
||||
"1:",
|
||||
"sub $7, %rsi",
|
||||
"sub $7, %rdi",
|
||||
"mov {qword_count}, %rcx",
|
||||
"rep movsq",
|
||||
"test {pre_byte_count:e}, {pre_byte_count:e}",
|
||||
"jz 1f",
|
||||
"add $7, %rsi",
|
||||
"add $7, %rdi",
|
||||
"mov {pre_byte_count:e}, %ecx",
|
||||
"rep movsb",
|
||||
"1:",
|
||||
"cld",
|
||||
pre_byte_count = in(reg) pre_byte_count,
|
||||
qword_count = in(reg) qword_count,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue