Skip to content

Commit

Permalink
Fix off-by-one error in get_shiftamount (#9)
Browse files Browse the repository at this point in the history
per "The RISC-V Instruction Set Manual Volume I Unprivileged Architecture Version 20240411",
Sec. 33.11.6. Vector Single-Width Shift Instructions
  • Loading branch information
danielschloms authored Aug 29, 2024
1 parent de2c47f commit 2972d9e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/vpu/softvector-element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ inline SVElement u_mul_u(const SVElement& target, const SVElement& op1, const SV
inline size_t get_shiftamount(size_t target_width_bits, const uint8_t* rhs) {
size_t numberofbits = 0;
size_t shiftamount = 0;
target_width_bits >>= 1;
while(target_width_bits) {
target_width_bits = target_width_bits >> 1;
shiftamount |= rhs[numberofbits/8] & (1 << numberofbits);
Expand All @@ -68,6 +69,7 @@ inline size_t get_shiftamount(size_t target_width_bits, const uint8_t* rhs) {
inline size_t get_shiftamount(size_t target_width_bits, uint64_t rhs) {
size_t numberofbits = 0;
size_t shiftamount = 0;
target_width_bits >>= 1;
while(target_width_bits) {
target_width_bits = target_width_bits >> 1;
shiftamount |= rhs & (1 << numberofbits);
Expand Down

0 comments on commit 2972d9e

Please sign in to comment.