aboutsummaryrefslogtreecommitdiff
path: root/riscv/insns/vnclip_vv.h
diff options
context:
space:
mode:
authorAlbert Ou <aou@eecs.berkeley.edu>2019-09-28 19:22:11 +0800
committerChih-Min Chao <chihmin.chao@sifive.com>2019-11-11 19:02:34 -0800
commit4cdecf219b3f8165a24ca83bc92f0241e0832513 (patch)
treece421b76972945989a42757951a4ae14cb88f770 /riscv/insns/vnclip_vv.h
parent590abe0960e9604f439d572c75abb440bbeaeadd (diff)
downloadspike-4cdecf219b3f8165a24ca83bc92f0241e0832513.zip
spike-4cdecf219b3f8165a24ca83bc92f0241e0832513.tar.gz
spike-4cdecf219b3f8165a24ca83bc92f0241e0832513.tar.bz2
rvv: fix the rounding bit position for vnclip instructions.
1. The rounding increment should be derived from the shift amount, not SEW. 2. Use 128bit to store temporary result to handle shift = 63 case in rv64 Signed-off-by: Albert Ou <aou@eecs.berkeley.edu> Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
Diffstat (limited to 'riscv/insns/vnclip_vv.h')
-rw-r--r--riscv/insns/vnclip_vv.h17
1 files changed, 6 insertions, 11 deletions
diff --git a/riscv/insns/vnclip_vv.h b/riscv/insns/vnclip_vv.h
index 7bcb4cb..4ec0f40 100644
--- a/riscv/insns/vnclip_vv.h
+++ b/riscv/insns/vnclip_vv.h
@@ -4,20 +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 = vs1 & ((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)(vs1 & ((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;