Closed Coekjan closed 2 months ago
Mmmm, is that a fix or a workaround?
doesn't BEXT works on 32bits input?
I think this is a fix and not a workaround.
bext
on rv64 does not handle 32bits input. This pseudo code describes how it works:
let index = X(rs2) & (XLEN - 1);
X(rd) = (X(rs1) >> index) & 1;
In the first step, X(rs2) & (XLEN - 1)
is actually X(rs2) & (64 - 1)
in rv64. When rex.w
is not set, what we need to do is X(rs2) & (32 - 1)
instead.
Then why not using the 's0' scratch reg to do the mask and still use BEXT, that would still be 1 opcode less then the fallback?
Then why not using the 's0' scratch reg to do the mask and still use BEXT, that would still be 1 opcode less then the fallback?
This can be better. I will push a new version and then please review the changes again. Thanks!
Fixes #1652 .