diff options
Diffstat (limited to 'riscv/insns/vnclip_vx.h')
-rw-r--r-- | riscv/insns/vnclip_vx.h | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/riscv/insns/vnclip_vx.h b/riscv/insns/vnclip_vx.h index b66e830..068d866 100644 --- a/riscv/insns/vnclip_vx.h +++ b/riscv/insns/vnclip_vx.h @@ -4,19 +4,15 @@ int64_t int_max = (1 << (P.VU.vsew - 1)) - 1; int64_t int_min = -(1 << (P.VU.vsew - 1)); VI_VVXI_LOOP_NARROW ({ + int128_t result = vs2; + unsigned shift = rs1 & ((sew * 2) - 1); - int64_t result = vs2; -// rounding - INT_ROUNDING(result, xrm, sew); + // rounding + INT_ROUNDING(result, xrm, shift); -// unsigned shifting to rs1 - uint64_t unsigned_shift_amount = (uint64_t)(rs1 & ((sew * 2) - 1)); - if (unsigned_shift_amount >= (2 * sew)) { - unsigned_shift_amount = 2 * sew - 1; - } - result = vsext(result, sew * 2) >> unsigned_shift_amount; + result = result >> shift; -// saturation + // saturation if (result < int_min) { result = int_min; P.VU.vxsat = 1; |