mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
std/crc64: fix x86_sse42 k1' magic number
This commit is contained in:
1 parent
77541659f3
commit
58d2a80691
4 files changed
+28
-18
No files matched your search
@@ -60,7 +60,7 @@ const px = "100000100110000010001110110110111"
|
||||
// P(x)' = 0x1_11011011_01110001_00000110_01000001
|
||||
const pxdash = "111011011011100010000011001000001"
|
||||
|
||||
var spaces = strings.Repeat(" ", 1024)
|
||||
var spaces = strings.Repeat(" ", 9999)
|
||||
|
||||
func debugf(format string, a ...interface{}) {
|
||||
if false { // Change false to true to show the long divisions.
|
||||
|
||||
@@ -23,7 +23,7 @@ package main
|
||||
//
|
||||
// Output:
|
||||
// Px' = 0x92D8_AF2B_AF0E_1E85
|
||||
// k1' = 0xF83B_4090_32DA_5F76
|
||||
// k1' = 0x6AE3_EFBB_9DD4_41F3
|
||||
// k2' = 0x081F_6054_A784_2DF4
|
||||
// k3' = 0xE05D_D497_CA39_3AE4
|
||||
// k4' = 0xDABE_95AF_C787_5F40
|
||||
@@ -40,7 +40,7 @@ import (
|
||||
// P(x) = 0b1_01000010_11110000_11100001_11101011_10101001_11101010_00110110_10010011
|
||||
const px = "10100001011110000111000011110101110101001111010100011011010010011"
|
||||
|
||||
var spaces = strings.Repeat(" ", 1024)
|
||||
var spaces = strings.Repeat(" ", 9999)
|
||||
|
||||
func debugf(format string, a ...interface{}) {
|
||||
if false { // Change false to true to show the long divisions.
|
||||
@@ -68,7 +68,7 @@ func calcKn(name string, power int) {
|
||||
b := []byte(numerator)
|
||||
i := 0
|
||||
debugf(" %s\n", numerator)
|
||||
for i+len(px) <= len(numerator) {
|
||||
for i+len(px) < len(numerator) {
|
||||
for j := 0; j < len(px); j++ {
|
||||
b[i+j] ^= 1 & px[j]
|
||||
}
|
||||
@@ -87,7 +87,7 @@ func calcMu(name string) {
|
||||
b := []byte(numerator)
|
||||
i := 0
|
||||
debugf(" %s\n", numerator)
|
||||
for i+len(px) <= len(numerator) {
|
||||
for i+len(px) < len(numerator) {
|
||||
for j := 0; j < len(px); j++ {
|
||||
b[i+j] ^= 1 & px[j]
|
||||
}
|
||||
|
||||
@@ -138,23 +138,30 @@ pri func ieee_hasher.up_x86_sse42!(x: roslice base.u8),
|
||||
// https://play.golang.org/p/wH1q6GfhKOE
|
||||
//
|
||||
// The k6' constant from the Gopal paper is unused.
|
||||
//
|
||||
// The rkN names match the numbers at
|
||||
// https://github.com/intel/isa-l/blob/7b30857e20b84e5afab1a28291189b9dc571110d/crc/crc32_gzip_refl_by16_10.asm#L475-L499
|
||||
//
|
||||
// The "+§" means a harmless off-by-one difference compared to Intel's numbers.
|
||||
// https://danlark.org/2021/03/08/how-a-bug-in-the-linux-crc-32-checksum-turned-out-not-to-be-a-bug/
|
||||
// https://github.com/google/wuffs/commit/b24e046670396d7ef22ccf499051340b9288419b
|
||||
|
||||
pri const IEEE_X86_SSE42_K1K2 : roarray[16] base.u8 = [
|
||||
0xD4, 0x2B, 0x44, 0x54, 0x01, 0x00, 0x00, 0x00, // k1' = 0x1_5444_2BD4
|
||||
0x96, 0x15, 0xE4, 0xC6, 0x01, 0x00, 0x00, 0x00, // k2' = 0x1_C6E4_1596
|
||||
0xD4, 0x2B, 0x44, 0x54, 0x01, 0x00, 0x00, 0x00, // k1' = 0x1_5444_2BD4 = rk16
|
||||
0x96, 0x15, 0xE4, 0xC6, 0x01, 0x00, 0x00, 0x00, // k2' = 0x1_C6E4_1596 = rk15
|
||||
]
|
||||
|
||||
pri const IEEE_X86_SSE42_K3K4 : roarray[16] base.u8 = [
|
||||
0xD0, 0x97, 0x19, 0x75, 0x01, 0x00, 0x00, 0x00, // k3' = 0x1_7519_97D0
|
||||
0x9E, 0x00, 0xAA, 0xCC, 0x00, 0x00, 0x00, 0x00, // k4' = 0x0_CCAA_009E
|
||||
0xD0, 0x97, 0x19, 0x75, 0x01, 0x00, 0x00, 0x00, // k3' = 0x1_7519_97D0 = rk2
|
||||
0x9E, 0x00, 0xAA, 0xCC, 0x00, 0x00, 0x00, 0x00, // k4' = 0x0_CCAA_009E = rk1
|
||||
]
|
||||
|
||||
pri const IEEE_X86_SSE42_K5ZZ : roarray[16] base.u8 = [
|
||||
0x24, 0x61, 0xCD, 0x63, 0x01, 0x00, 0x00, 0x00, // k5' = 0x1_63CD_6124
|
||||
0x24, 0x61, 0xCD, 0x63, 0x01, 0x00, 0x00, 0x00, // k5' = 0x1_63CD_6124 = rk6
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Unused
|
||||
]
|
||||
|
||||
pri const IEEE_X86_SSE42_PXMU : roarray[16] base.u8 = [
|
||||
0x41, 0x06, 0x71, 0xDB, 0x01, 0x00, 0x00, 0x00, // Px' = 0x1_DB71_0641
|
||||
0x41, 0x16, 0x01, 0xF7, 0x01, 0x00, 0x00, 0x00, // μ' = 0x1_F701_1641
|
||||
0x41, 0x06, 0x71, 0xDB, 0x01, 0x00, 0x00, 0x00, // Px' = 0x1_DB71_0641 = rk8+§
|
||||
0x41, 0x16, 0x01, 0xF7, 0x01, 0x00, 0x00, 0x00, // μ' = 0x1_F701_1641 = rk7+§
|
||||
]
|
||||
@@ -133,18 +133,21 @@ pri const SHUFFLE_8F80 : roarray[16] base.u8 = [
|
||||
|
||||
// These constants are reproduced by
|
||||
// script/print-crc64-x86-sse42-magic-numbers.go
|
||||
//
|
||||
// The rkN names match the numbers at
|
||||
// https://github.com/intel/isa-l/blob/7b30857e20b84e5afab1a28291189b9dc571110d/crc/crc64_ecma_refl_by16_10.asm#L33-L56
|
||||
|
||||
// pri const ECMA_X86_SSE42_K1K2 : roarray[16] base.u8 = [
|
||||
// 0x76, 0x5F, 0xDA, 0x32, 0x90, 0x40, 0x3B, 0xF8, // k1' = 0xF83B_4090_32DA_5F76
|
||||
// 0xF4, 0x2D, 0x84, 0xA7, 0x54, 0x60, 0x1F, 0x08, // k2' = 0x081F_6054_A784_2DF4
|
||||
// 0xF3, 0x41, 0xD4, 0x9D, 0xBB, 0xEF, 0xE3, 0x6A, // k1' = 0x6AE3_EFBB_9DD4_41F3 = rk16
|
||||
// 0xF4, 0x2D, 0x84, 0xA7, 0x54, 0x60, 0x1F, 0x08, // k2' = 0x081F_6054_A784_2DF4 = rk15
|
||||
// ]
|
||||
|
||||
pri const ECMA_X86_SSE42_K3K4 : roarray[16] base.u8 = [
|
||||
0xE4, 0x3A, 0x39, 0xCA, 0x97, 0xD4, 0x5D, 0xE0, // k3' = 0xE05D_D497_CA39_3AE4
|
||||
0x40, 0x5F, 0x87, 0xC7, 0xAF, 0x95, 0xBE, 0xDA, // k4' = 0xDABE_95AF_C787_5F40
|
||||
0xE4, 0x3A, 0x39, 0xCA, 0x97, 0xD4, 0x5D, 0xE0, // k3' = 0xE05D_D497_CA39_3AE4 = rk2
|
||||
0x40, 0x5F, 0x87, 0xC7, 0xAF, 0x95, 0xBE, 0xDA, // k4' = 0xDABE_95AF_C787_5F40 = rk1
|
||||
]
|
||||
|
||||
pri const ECMA_X86_SSE42_PXMU : roarray[16] base.u8 = [
|
||||
0x85, 0x1E, 0x0E, 0xAF, 0x2B, 0xAF, 0xD8, 0x92, // Px' = 0x92D8_AF2B_AF0E_1E85
|
||||
0xD5, 0x63, 0x29, 0x17, 0x6C, 0x46, 0x3E, 0x9C, // μ' = 0x9C3E_466C_1729_63D5
|
||||
0x85, 0x1E, 0x0E, 0xAF, 0x2B, 0xAF, 0xD8, 0x92, // Px' = 0x92D8_AF2B_AF0E_1E85 = rk8
|
||||
0xD5, 0x63, 0x29, 0x17, 0x6C, 0x46, 0x3E, 0x9C, // μ' = 0x9C3E_466C_1729_63D5 = rk7
|
||||
]
|
||||
Reference in new issue
Block a user