crc32: add notw macro
instead of materializing a constant 0xffffffff, do a NOT and then zero-extend the result. my qemu doesn't support the zext.w instruction, so we have to do two shifts instead. these can potentially be fused into a single instruction by the processor.
This commit is contained in:
parent
6d1413c754
commit
cc18d535a5
15
crc32.s
15
crc32.s
@ -127,6 +127,14 @@ iloop2:
|
||||
|
||||
#............................................
|
||||
|
||||
.macro notw rd, rs
|
||||
not \rd, \rs
|
||||
#zext.w \rd, \rd
|
||||
#add.uw \rd, \rs, 0
|
||||
slli \rd, \rd, 32
|
||||
srli \rd, \rd, 32
|
||||
.endm
|
||||
|
||||
# inputs:
|
||||
# a0: crc
|
||||
# a1: buf
|
||||
@ -142,9 +150,7 @@ crc_update:
|
||||
mv t2, s1
|
||||
mv t3, s2
|
||||
# invert crc
|
||||
li t0, -1
|
||||
srli t0, t0, 32
|
||||
xor a0, a0, t0
|
||||
notw a0, a0
|
||||
|
||||
mv s0, a0 # crc
|
||||
mv s1, a1 # buffer
|
||||
@ -174,6 +180,5 @@ udone:
|
||||
# invert crc
|
||||
#li t0, -1
|
||||
#srli t0, t0, 32
|
||||
li t0, 0xFFFFFFFF
|
||||
xor a0, a0, t0
|
||||
notw a0, a0
|
||||
ret
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user