Skip to content

Commit

Permalink
Make sure arm64 is using the optimized routines
Browse files Browse the repository at this point in the history
  • Loading branch information
chriso committed Apr 8, 2022
1 parent 75a824e commit 33db497
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions qsort/sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func Sort(data []byte, size int, swap func(int, int)) {
}

// No specialization available. Use the slower generic sorting routine.
if purego || size%8 != 0 || size > 32 {
if size%8 != 0 || size > 32 {
sort.Sort(newGeneric(data, size, swap))
return
}
Expand All @@ -37,11 +37,11 @@ func Sort(data []byte, size int, swap func(int, int)) {
// If no indirect swapping is required, try to use the hybrid partitioning scheme from
// https://blog.reverberate.org/2020/05/29/hoares-rebuttal-bubble-sorts-comeback.html
switch {
case swap == nil && size == 8 && cpu.X86.Has(x86.CMOV):
case swap == nil && !purego && size == 8 && cpu.X86.Has(x86.CMOV):
hybridQuicksort64(unsafeBytesTo64(data))
case swap == nil && size == 16 && cpu.X86.Has(x86.AVX):
case swap == nil && !purego && size == 16 && cpu.X86.Has(x86.AVX):
hybridQuicksort128(unsafeBytesTo128(data))
case swap == nil && size == 32 && cpu.X86.Has(x86.AVX2):
case swap == nil && !purego && size == 32 && cpu.X86.Has(x86.AVX2):
hybridQuicksort256(unsafeBytesTo256(data))
case size == 8:
quicksort64(unsafeBytesTo64(data), 0, smallCutoff, insertionsort64, hoarePartition64, swap)
Expand Down

0 comments on commit 33db497

Please sign in to comment.