From 4cdecf219b3f8165a24ca83bc92f0241e0832513 Mon Sep 17 00:00:00 2001 From: Albert Ou Date: Sat, 28 Sep 2019 19:22:11 +0800 Subject: 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 Signed-off-by: Chih-Min Chao --- riscv/insns/vnclip_vi.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'riscv/insns/vnclip_vi.h') diff --git a/riscv/insns/vnclip_vi.h b/riscv/insns/vnclip_vi.h index ca27593..287035e 100644 --- a/riscv/insns/vnclip_vi.h +++ b/riscv/insns/vnclip_vi.h @@ -4,14 +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 ({ - int64_t result = vs2; -// rounding - INT_ROUNDING(result, xrm, sew); + unsigned shift = zimm5 & ((sew * 2) - 1); + + // rounding + INT_ROUNDING(result, xrm, shift); - result = vsext(result, sew * 2) >> (zimm5 & ((sew * 2) < 32? (sew * 2) - 1: 31)); + result = result >> shift; -// saturation + // saturation if (result < int_min) { result = int_min; P.VU.vxsat = 1; -- cgit v1.1