std/crc64: re-write x86_sse42 implementation

name                           old speed      new speed       delta

wuffs_crc64_ecma_10k/clang14   5.84GB/s ± 0%  23.43GB/s ± 0%  +301.23%  (p=0.008 n=5+5)
wuffs_crc64_ecma_100k/clang14  6.18GB/s ± 0%  30.23GB/s ± 1%  +389.45%  (p=0.008 n=5+5)

wuffs_crc64_ecma_10k/gcc12     5.87GB/s ± 1%  24.02GB/s ± 0%  +309.21%  (p=0.008 n=5+5)
wuffs_crc64_ecma_100k/gcc12    6.21GB/s ± 0%  30.68GB/s ± 0%  +394.22%  (p=0.008 n=5+5)

$ time example-mzcat < linux-6.8.2.tar.xz > /dev/null
Before: user 0m7.604s
After:  user 0m7.432s
This commit is contained in:
Nigel Tao committed 2024-04-22 14:05:16 +10:00
1 parent e1f803324b
commit e541e0cf79
5 files changed
+343 -189

No files matched your search

+16 -3
View File
@@ -49,8 +49,7 @@ func (q *checker) optimizeIOMethodAdvance(receiver *a.Expr, advance *big.Int, ad
return q.optimizeIOMethodAdvanceExpr(receiver, advanceExpr, update)
}
// Check if receiver looks like "a[i .. j]" where i and j are constants and
// ((j - i) >= advance).
// Check if the receiver looks like "a[i .. j]".
if _, i, j, ok := receiver.IsSlice(); ok {
icv := (*big.Int)(nil)
if i == nil {
@@ -64,11 +63,25 @@ func (q *checker) optimizeIOMethodAdvance(receiver *a.Expr, advance *big.Int, ad
jcv = j.ConstValue()
}
if (icv != nil) && (jcv != nil) {
switch {
case (icv != nil) && (jcv != nil):
// OK if i and j are constants and ((j - i) >= advance).
n := big.NewInt(0).Sub(jcv, icv)
if n.Cmp(advance) >= 0 {
retOK = true
}
case (i != nil) && (j != nil) && (j.Operator() == t.IDXBinaryPlus):
// OK if j is (i + constant) and (constant >= advance).
n := (*big.Int)(nil)
if j.LHS().AsExpr().Eq(i) {
n = j.RHS().AsExpr().ConstValue()
} else if j.RHS().AsExpr().Eq(i) {
n = j.LHS().AsExpr().ConstValue()
}
if n != nil && (n.Cmp(advance) >= 0) {
retOK = true
}
}
}