@@ -109,6 +109,7 @@ pub unsafe fn set_bytes(dest: *mut u8, c: u8, count: usize) {
109
109
#[ inline( always) ]
110
110
#[ cfg( not( target_feature = "ermsb" ) ) ]
111
111
pub unsafe fn set_bytes ( mut dest : * mut u8 , c : u8 , count : usize ) {
112
+ let c = c as u64 * 0x0101_0101_0101_0101 ;
112
113
let ( pre_byte_count, qword_count, byte_count) = rep_param ( dest, count) ;
113
114
// Separating the blocks gives the compiler more freedom to reorder instructions.
114
115
// It also allows us to trivially skip the rep stosb, which is faster when memcpying
@@ -118,23 +119,23 @@ pub unsafe fn set_bytes(mut dest: *mut u8, c: u8, count: usize) {
118
119
"rep stosb" ,
119
120
inout( "ecx" ) pre_byte_count => _,
120
121
inout( "rdi" ) dest => dest,
121
- in( "al " ) c,
122
+ in( "rax " ) c,
122
123
options( nostack, preserves_flags)
123
124
) ;
124
125
}
125
126
asm ! (
126
127
"rep stosq" ,
127
128
inout( "rcx" ) qword_count => _,
128
129
inout( "rdi" ) dest => dest,
129
- in( "rax" ) ( c as u64 ) * 0x0101010101010101 ,
130
+ in( "rax" ) c ,
130
131
options( nostack, preserves_flags)
131
132
) ;
132
133
if byte_count > 0 {
133
134
asm ! (
134
135
"rep stosb" ,
135
136
inout( "ecx" ) byte_count => _,
136
137
inout( "rdi" ) dest => _,
137
- in( "al " ) c,
138
+ in( "rax " ) c,
138
139
options( nostack, preserves_flags)
139
140
) ;
140
141
}
0 commit comments