Remove some if's from deflate.decode_huffman_fast

name                             old speed     new speed     delta

wuffs_deflate_decode_1k/clang    145MB/s ± 0%  151MB/s ± 1%  +4.54%  (p=0.008 n=5+5)
wuffs_deflate_decode_10k/clang   234MB/s ± 0%  230MB/s ± 0%  -1.75%  (p=0.008 n=5+5)
wuffs_deflate_decode_100k/clang  263MB/s ± 0%  276MB/s ± 1%  +5.17%  (p=0.008 n=5+5)

wuffs_deflate_decode_1k/gcc      157MB/s ± 1%  157MB/s ± 0%    ~     (p=0.421 n=5+5)
wuffs_deflate_decode_10k/gcc     265MB/s ± 0%  259MB/s ± 0%  -2.16%  (p=0.008 n=5+5)
wuffs_deflate_decode_100k/gcc    313MB/s ± 0%  315MB/s ± 0%  +0.39%  (p=0.016 n=5+5)

wuffs_gzip_decode_10k/clang      216MB/s ± 0%  212MB/s ± 0%  -1.69%  (p=0.016 n=5+4)
wuffs_gzip_decode_100k/clang     241MB/s ± 0%  252MB/s ± 0%  +4.67%  (p=0.016 n=5+4)

wuffs_gzip_decode_10k/gcc        251MB/s ± 1%  248MB/s ± 1%  -1.05%  (p=0.008 n=5+5)
wuffs_gzip_decode_100k/gcc       285MB/s ± 1%  291MB/s ± 0%  +2.16%  (p=0.008 n=5+5)

wuffs_zlib_decode_10k/clang      213MB/s ± 0%  210MB/s ± 0%  -1.18%  (p=0.008 n=5+5)
wuffs_zlib_decode_100k/clang     239MB/s ± 0%  247MB/s ± 0%  +3.08%  (p=0.008 n=5+5)

wuffs_zlib_decode_10k/gcc        244MB/s ± 0%  247MB/s ± 0%  +1.15%  (p=0.008 n=5+5)
wuffs_zlib_decode_100k/gcc       282MB/s ± 0%  291MB/s ± 0%  +2.90%  (p=0.008 n=5+5)
This commit is contained in:
Nigel Tao committed 2018-12-01 10:26:09 +11:00
1 parent 776e82d542
commit 3e70383c6c
6 files changed
+52 -55

No files matched your search

+10 -4
View File
@@ -19,8 +19,13 @@ package main
// print-deflate-magic-numbers.go prints the std/deflate lcode_magic_numbers
// and dcode_magic_numbers values based on the tables in RFC 1951 secion 3.2.5.
//
// The lcode base numbers are biased by -3 so that (base_number_minus_3 +
// extra_bits) fits in the range [0, 255]. This makes a bitwise-and with 0xFF a
// no-op, in terms of computed value, but proves to the compiler that the
// result is within a certain range.
//
// The dcode base numbers are biased by -1 so that (base_number_minus_1 +
// extra_bits) fits in the range [0, 32767]. This makes a bitwise and with
// extra_bits) fits in the range [0, 32767]. This makes a bitwise-and with
// 0x7FFF a no-op, in terms of computed value, but proves to the compiler that
// the result is within a certain range. Furthermore, proving that (d + 1) > 0
// is trivial, for d of type u32[..something], compared to proving that d > 0,
@@ -41,16 +46,17 @@ func main() {
}
func main1() error {
// See the "base numbers" comment above.
biases := [2]uint32{3, 1}
for i := 0; i < 2; i++ {
bias := uint32(0)
if i != 0 {
fmt.Println()
bias = 1 // See the "dcode base numbers" comment above.
}
for j := 0; j < 32; j++ {
x := uint32(0x08000000)
if bn := baseNumbers[i][j]; bn != bad {
x = 0x40000000 | ((bn - bias) << 8) | (extraBits[i][j] << 4)
x = 0x40000000 | ((bn - biases[i]) << 8) | (extraBits[i][j] << 4)
}
fmt.Printf("0x%08X,", x)
if j&7 == 7 {
@@ -244,8 +244,8 @@ outer_loop:
table_entry = self->private_impl.f_huffs[0][top + (bits & mask)];
}
// length = base_number + extra_bits.
uint32_t length = (table_entry >> 8) & 0xFFFF;
// length = base_number_minus_3 + 3 + extra_bits.
uint32_t length = ((table_entry >> 8) & 0xFF) + 3;
{
uint32_t n = (table_entry >> 4) & 0x0F;
if (n) {
@@ -290,8 +290,8 @@ outer_loop:
table_entry = self->private_impl.f_huffs[1][top + (bits & mask)];
}
// dist_minus_1 = base_number_minus_1 + extra_bits + 1.
// distance = dist_minus_1 + 1.
// dist_minus_1 = base_number_minus_1 + extra_bits.
// distance = dist_minus_1 + 1.
uint32_t dist_minus_1 = (table_entry >> 8) & 0xFFFF;
{
uint32_t n = (table_entry >> 4) & 0x0F;