3 ms·
Is the assembly the inner loop or the whole function? The function looks like it could be restructured into a tail call - the trailing swap is quite like the lo
by JonChesterfield 3y ago
Is the assembly the inner loop or the whole function? The function looks like it could be restructured into a tail call - the trailing swap is quite like the loop body - but I'd be surprised if a compiler managed that transform.
- orlp 3y agoThe assembly is only for the inner loop, I did not include the preamble/postamble of the functions. You can look at the full assembly here: https://cpp.godbolt.org/z/zzzTh47PG https://cpp.godbolt.org/z/zzzTh47PG. But the full assembly isn't a fair comparison right now because I did not bother to convert both functions to have the same signature (Andrey's version assumes the pivot is in the array and selects it in the function). Virtually all the time for any non-trivial input is spent in the inner loop though.