|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, we used three rotations. This was simple, but was aggressively
inlined by gcc at higher optimization levels, massively bloating the code.
Now, we take the front of the array, which is to be rotated to the end, and
using a series of swaps, move it progressively closer to the end. When we
can no longer perform a swap of the required size because we're too close
to the end, we view the remaining operation as a rotate to the right with
a smaller shift size. We repeat as necessary.
This generates somewhat smaller code than the three reverses, even at -Os.
It also shows up to a 25% overall performance improvement for grailsort on
some inputs.
|