diff --git a/makefile b/makefile index 9805cae..7ac27c0 100644 --- a/makefile +++ b/makefile @@ -16,6 +16,9 @@ release: test.cpp magyarsort.h release_ypsu: ypsu.cpp magyarsort.h g++ ypsu.cpp -DNDEBUG -std=c++17 -O2 -o ypsu.out +release3_ypsu: ypsu.cpp magyarsort.h + g++ ypsu.cpp -DNDEBUG -std=c++17 -O3 -o ypsu.out + release_ypsu_assert: ypsu.cpp magyarsort.h g++ ypsu.cpp -std=c++17 -O2 -o ypsu.out diff --git a/thiersort2.h b/thiersort2.h index 04d06ee..b47b04c 100644 --- a/thiersort2.h +++ b/thiersort2.h @@ -24,8 +24,12 @@ static inline uint32_t witch_bucket(uint32_t key) { /* This approach uses 12 bits from a 32 bit float to map onto a byte bucket index */ th2_fu as; as.f = (float) key; + uint32_t witch_base = (key <= 2) ? 0 : (as.u >> 23) - 128; // 0, [127..159] -> [0..31] return witch_base * 8 + ((as.u >> (23 - 3)) & 7); + /* Alternative (but I measure it being worse): + return (as.u >> 23); + */ } /**