diff --git a/cmd/wuffs-c/internal/cgen/statement.go b/cmd/wuffs-c/internal/cgen/statement.go index 8860d509..99db62bd 100644 --- a/cmd/wuffs-c/internal/cgen/statement.go +++ b/cmd/wuffs-c/internal/cgen/statement.go @@ -243,10 +243,15 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error { unroll := n.Unroll().SmallPowerOf2Value() step := n.Step().SmallPowerOf2Value() - // TODO: remove the "step == 1" hack. - if uStep := unroll * step; uStep != 1 && step == 1 { + if uStep := unroll * step; uStep != 1 { + // TODO: remove this hack. + hack := 1 + if step != 1 { + hack = 0 + } + b.printf("uint8_t* %send0_%s = %sslice_%s.ptr + (%sslice_%s.len / %d) * %d;\n", - iPrefix, name, iPrefix, name, iPrefix, name, uStep, uStep) + iPrefix, name, iPrefix, name, iPrefix, name, uStep, uStep*hack) b.printf("while (%s%s < %send0_%s) {\n", vPrefix, name, iPrefix, name) for i := 0; i < unroll; i++ { for _, o := range n.Body() { diff --git a/gen/c/std/crc32.c b/gen/c/std/crc32.c index ff50040d..ed416eb8 100644 --- a/gen/c/std/crc32.c +++ b/gen/c/std/crc32.c @@ -2016,6 +2016,11 @@ uint32_t wuffs_crc32__ieee_hasher__update(wuffs_crc32__ieee_hasher* self, { wuffs_base__slice_u8 i_slice_p = a_x; uint8_t* v_p = i_slice_p.ptr; + uint8_t* i_end0_p = i_slice_p.ptr + (i_slice_p.len / 8) * 0; + while (v_p < i_end0_p) { + v_s ^= 1234; + v_p += 8; + } uint8_t* i_end1_p = i_slice_p.ptr + i_slice_p.len; while (v_p < i_end1_p) { v_s = (wuffs_crc32__ieee_table[0][((uint8_t)((v_s & 255))) ^ *v_p] ^ diff --git a/std/crc32/common_crc32.wuffs b/std/crc32/common_crc32.wuffs index eb9258df..b2198dc8 100644 --- a/std/crc32/common_crc32.wuffs +++ b/std/crc32/common_crc32.wuffs @@ -29,6 +29,7 @@ pub func ieee_hasher.update(x slice base.u8)(checksum base.u32) { iterate (step:8, unroll:1)(p ptr base.u8:in.x) { // TODO. + s ^= 1234 } else { s = ieee_table[0][((s & 0xFF) as base.u8) ^ deref p] ^ (s >> 8) }