Skip to content

Commit

Permalink
mem: Add documentations for REP string insturctions
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Richey <joerichey@google.com>
  • Loading branch information
josephlr committed Jul 8, 2020
1 parent cb939ea commit 844b730
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/mem/x86_64.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
use super::c_int;

// On recent Intel processors, "rep movsb" and "rep stosb" have been enhanced to
// select the best microarchitecural implemenetation based on length and
// alignment. This allows for very fast memcmp/memset implementations.
// See "Intel® 64 and IA-32 Architectures Optimization Reference Manual"
// - Enhanced REP MOVSB and STOSB operation (ERMSB) (section 3.7.7)
// - Fast Short REP MOV (FSRM)
//
// While the "rep cmpsb" instructions have not seen similar optimizations, they
// are still faster than our simple fallback implementations for memcmp/bcmp.

#[inline(always)]
unsafe fn copy_forward(dest: *mut u8, src: *const u8, count: usize) {
asm!(
Expand Down

0 comments on commit 844b730

Please sign in to comment.