File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 1
1
use super :: c_int;
2
2
3
+ // On most modern Intel and AMD processors, "rep movsq" and "rep stosq" have
4
+ // been enhanced to perform better than an simple qword loop, making them ideal
5
+ // for implementing memcpy/memset. Note that "rep cmps" has received no such
6
+ // enhancement, so it is not used to implement memcmp.
7
+ //
8
+ // On certain recent Intel processors, "rep movsb" and "rep stosb" have been
9
+ // further enhanced to automatically select the best microarchitectural
10
+ // implementation based on length and alignment. See the following features from
11
+ // the "Intel® 64 and IA-32 Architectures Optimization Reference Manual":
12
+ // - ERMSB - Enhanced REP MOVSB and STOSB (Ivy Bridge and later)
13
+ // - FSRM - Fast Short REP MOV (Ice Lake and later)
14
+ // - Fast Zero-Length MOVSB (On no current hardware)
15
+ // - Fast Short STOSB (On no current hardware)
16
+ // However, to avoid run-time feature detection, we don't use these byte-based
17
+ // instructions for most of the copying, preferring the qword variants.
18
+
3
19
#[ cfg_attr( all( feature = "mem" , not( feature = "mangled-names" ) ) , no_mangle) ]
4
20
pub unsafe extern "C" fn memcpy ( dest : * mut u8 , src : * const u8 , count : usize ) -> * mut u8 {
5
21
asm ! (
You can’t perform that action at this time.
0 commit comments