News for hackers. Stuff that matters.
Re:Does a compiler use all x86 instructions? (2010) by rwmj on Wednesday August 24, 2016 @12:47PM (#12353345)
And the counterpoint is that some instructions that are commonly believed to be slow (eg. the string instructions like rep movs, lods, stos), are in fact fast on modern processors.
Re:Does a compiler use all x86 instructions? (2010) by nneonneo on Wednesday August 24, 2016 @12:51PM (#12353367)
Now I'm curious - do you have performance numbers somewhere for this? The rep instructions can actually be shorter than a call to str*, so if rep is actually fast enough then it might make a nice optimization.
Re:Does a compiler use all x86 instructions? (2010) by rwmj on Wednesday August 24, 2016 @12:57PM (#12353406)
It depends if the strings are aligned or not, the size of the copy, and also on the generation of processor. There are some good answers here:

http://stackoverflow.com/a/9177369

https://stackoverflow.com/questions/12359228/reliable-inform...

https://stackoverflow.com/questions/8425022/performance-of-x...

Re:Does a compiler use all x86 instructions? (2010) by veddan on Wednesday August 24, 2016 @01:15PM (#12353559)
Reasonably modern versions of GCC will emit various rep instructions in some cases.

Some code I just compiled with GCC 6.1.1 had several snippets like this emitted for zeroing with memset:

    xor eax,eax
    ...
    rep stos QWORD PTR es:[rdi],rax
and some rep movs for memcpy/memmove.
Re:Does a compiler use all x86 instructions? (2010) by chkras on Wednesday August 24, 2016 @03:11PM (#12354473)
really? I wonder if the timing of rep and string instructions have improved at all?
Re:Does a compiler use all x86 instructions? (2010) by userbinator on Wednesday August 24, 2016 @08:45PM (#12356238)
They operate on cacheline-sized pieces ever since the P6.