Messages in this thread | | | From | David Laight <> | Subject | RE: how many memset(,0,) calls in kernel ? | Date | Mon, 13 Sep 2021 16:03:09 +0000 |
| |
> 36: b9 06 00 00 00 mov $0x6,%ecx > 3b: 4c 89 e7 mov %r12,%rdi > 3e: f3 ab rep stos %eax,%es:(%rdi) > > The last line does exactly "memset(%rdi, %eax, %ecx)". Just two bytes > for some code that modern processors are even able to optimize.
Hmmm I'd bet that 6 stores will be faster on ~everything. 'modern' processors do better than some older ones [1], but 6 writes isn't enough to get into the really fast paths. So you'll still take a few cycles of setup.
[1] P4 netburst had a ~40 clock setup for any 'rep' operation.
David
- Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
| |