Skip to content

Commit 4973c80

Browse files
committed
cosim: fix right shift on neg number and remove redundant mask
referece from: ISO C99 (6.5.7/4) "The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated bits are filled with zeros. If E1 has an unsigned type, the value of the result is E1 × 2E2, reduced modulo one more than the maximum value representable in the result type. If E1 has a signed type and nonnegative value, and E1 × 2E2 is representable in the result type, then that is the resulting value; otherwise, the behavior is undefined." list the affectections. X means it is problematic and fixed by change operand type / redundant mask 1. vsll.v[vxi] -> X X 2. vsra.v[vxi] -> O O 3. vsrl.v[vxi] -> O X 4. vwsll.v[vxi] -> O O 5. vnsrl.w[vxi] -> O O 6. vnsra.w[vxi] -> O X 7. vssrl.v[vxi] -> O X 7. vssra.v[vxi] -> O X Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
1 parent cd692c4 commit 4973c80

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

riscv/insns/vnsra_wi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// vnsra.vi vd, vs2, zimm5
22
VI_VI_LOOP_NSHIFT
33
({
4-
vd = vs2 >> (zimm5 & (sew * 2 - 1) & 0x1f);
4+
vd = vs2 >> (zimm5 & (sew * 2 - 1));
55
})

riscv/insns/vsll_vi.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// vsll.vi vd, vs2, zimm5
2-
VI_VI_LOOP
2+
VI_VI_ULOOP
33
({
4-
vd = vs2 << (simm5 & (sew - 1) & 0x1f);
4+
vd = vs2 << (zimm5 & (sew - 1));
55
})

riscv/insns/vsll_vv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// vsll
2-
VI_VV_LOOP
2+
VI_VV_ULOOP
33
({
44
vd = vs2 << (vs1 & (sew - 1));
55
})

riscv/insns/vsll_vx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// vsll
2-
VI_VX_LOOP
2+
VI_VX_ULOOP
33
({
44
vd = vs2 << (rs1 & (sew - 1));
55
})

riscv/insns/vsrl_vi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// vsrl.vi vd, vs2, zimm5
22
VI_VI_ULOOP
33
({
4-
vd = vs2 >> (zimm5 & (sew - 1) & 0x1f);
4+
vd = vs2 >> (zimm5 & (sew - 1));
55
})

riscv/insns/vssra_vi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
VI_VI_LOOP
33
({
44
VRM xrm = P.VU.get_vround_mode();
5-
int sh = simm5 & (sew - 1) & 0x1f;
5+
int sh = simm5 & (sew - 1);
66
int128_t val = vs2;
77

88
INT_ROUNDING(val, xrm, sh);

riscv/insns/vssrl_vi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
VI_VI_ULOOP
33
({
44
VRM xrm = P.VU.get_vround_mode();
5-
int sh = zimm5 & (sew - 1) & 0x1f;
5+
int sh = zimm5 & (sew - 1);
66
uint128_t val = vs2;
77

88
INT_ROUNDING(val, xrm, sh);

0 commit comments

Comments
 (0)