Skip to content

Commit 844b730

Browse files
committed
mem: Add documentations for REP string insturctions
Signed-off-by: Joe Richey <[email protected]>
1 parent cb939ea commit 844b730

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/mem/x86_64.rs

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
use super::c_int;
22

3+
// On recent Intel processors, "rep movsb" and "rep stosb" have been enhanced to
4+
// select the best microarchitecural implemenetation based on length and
5+
// alignment. This allows for very fast memcmp/memset implementations.
6+
// See "Intel® 64 and IA-32 Architectures Optimization Reference Manual"
7+
// - Enhanced REP MOVSB and STOSB operation (ERMSB) (section 3.7.7)
8+
// - Fast Short REP MOV (FSRM)
9+
//
10+
// While the "rep cmpsb" instructions have not seen similar optimizations, they
11+
// are still faster than our simple fallback implementations for memcmp/bcmp.
12+
313
#[inline(always)]
414
unsafe fn copy_forward(dest: *mut u8, src: *const u8, count: usize) {
515
asm!(

0 commit comments

Comments
 (0)