diff --git a/riscv/decode.h b/riscv/decode.h index e0d1a5bf..d004d11d 100644 --- a/riscv/decode.h +++ b/riscv/decode.h @@ -386,6 +386,15 @@ static inline bool is_overlapped(const int astart, const int asize, #define VI_CHECK_SS \ require(!is_overlapped(insn.rd(), P.VU.vlmul, insn.rs2(), P.VU.vlmul)); +#define VI_CHECK_MSS(is_vs1) \ + if (P.VU.vlmul > 1) { \ + require(!is_overlapped(insn.rd(), 1, insn.rs2(), P.VU.vlmul)); \ + require((insn.rs2() & (P.VU.vlmul - 1)) == 0); \ + if (is_vs1) {\ + require(!is_overlapped(insn.rd(), 1, insn.rs1(), P.VU.vlmul)); \ + require((insn.rs1() & (P.VU.vlmul - 1)) == 0); \ + } \ + } #define VI_CHECK_SD \ require(!is_overlapped(insn.rd(), P.VU.vlmul, insn.rs2(), P.VU.vlmul * 2)); @@ -604,6 +613,7 @@ static inline bool is_overlapped(const int astart, const int asize, // comparision result to masking register #define VI_VV_LOOP_CMP(BODY) \ + VI_CHECK_MSS(true); \ VI_LOOP_CMP_BASE \ if (sew == e8){ \ VV_PARAMS(e8); \ @@ -621,6 +631,7 @@ static inline bool is_overlapped(const int astart, const int asize, VI_LOOP_CMP_END #define VI_VX_LOOP_CMP(BODY) \ + VI_CHECK_MSS(false); \ VI_LOOP_CMP_BASE \ if (sew == e8){ \ VX_PARAMS(e8); \ @@ -638,6 +649,7 @@ static inline bool is_overlapped(const int astart, const int asize, VI_LOOP_CMP_END #define VI_VI_LOOP_CMP(BODY) \ + VI_CHECK_MSS(false); \ VI_LOOP_CMP_BASE \ if (sew == e8){ \ VI_PARAMS(e8); \ @@ -655,6 +667,7 @@ static inline bool is_overlapped(const int astart, const int asize, VI_LOOP_CMP_END #define VI_VV_ULOOP_CMP(BODY) \ + VI_CHECK_MSS(true); \ VI_LOOP_CMP_BASE \ if (sew == e8){ \ VV_U_PARAMS(e8); \ @@ -672,6 +685,7 @@ static inline bool is_overlapped(const int astart, const int asize, VI_LOOP_CMP_END #define VI_VX_ULOOP_CMP(BODY) \ + VI_CHECK_MSS(false); \ VI_LOOP_CMP_BASE \ if (sew == e8){ \ VX_U_PARAMS(e8); \ @@ -689,6 +703,7 @@ static inline bool is_overlapped(const int astart, const int asize, VI_LOOP_CMP_END #define VI_VI_ULOOP_CMP(BODY) \ + VI_CHECK_MSS(false); \ VI_LOOP_CMP_BASE \ if (sew == e8){ \ VI_U_PARAMS(e8); \ @@ -1242,6 +1257,7 @@ VI_LOOP_END // carry/borrow bit loop #define VI_VV_LOOP_CARRY(BODY) \ + VI_CHECK_MSS(true); \ VI_LOOP_BASE \ if (sew == e8){ \ VV_CARRY_PARAMS(e8) \ @@ -1259,6 +1275,7 @@ VI_LOOP_END } \ #define VI_XI_LOOP_CARRY(BODY) \ + VI_CHECK_MSS(false); \ VI_LOOP_BASE \ if (sew == e8){ \ XI_CARRY_PARAMS(e8) \ @@ -1597,7 +1614,8 @@ for (reg_t i = 0; i < vlmax; ++i) { \ DEBUG_RVV_FP_VF; \ VI_VFP_LOOP_END -#define VI_VFP_LOOP_CMP(BODY) \ +#define VI_VFP_LOOP_CMP(BODY, is_vs1) \ + VI_CHECK_MSS(is_vs1); \ VI_VFP_LOOP_CMP_BASE \ BODY; \ set_fp_exceptions; \ diff --git a/riscv/insns/vmfeq_vf.h b/riscv/insns/vmfeq_vf.h index cedf4b97..f0e71091 100644 --- a/riscv/insns/vmfeq_vf.h +++ b/riscv/insns/vmfeq_vf.h @@ -2,4 +2,4 @@ VI_VFP_LOOP_CMP ({ res = f32_eq(vs2, rs1); -}) +}, false) diff --git a/riscv/insns/vmfeq_vv.h b/riscv/insns/vmfeq_vv.h index 7e76cacd..1be3a690 100644 --- a/riscv/insns/vmfeq_vv.h +++ b/riscv/insns/vmfeq_vv.h @@ -2,4 +2,4 @@ VI_VFP_LOOP_CMP ({ res = f32_eq(vs2, vs1); -}) +}, true) diff --git a/riscv/insns/vmfge_vf.h b/riscv/insns/vmfge_vf.h index 52531cba..1c68366d 100644 --- a/riscv/insns/vmfge_vf.h +++ b/riscv/insns/vmfge_vf.h @@ -2,4 +2,4 @@ VI_VFP_LOOP_CMP ({ res = f32_le(rs1, vs2); -}) +}, false) diff --git a/riscv/insns/vmfgt_vf.h b/riscv/insns/vmfgt_vf.h index 46ec5d41..09791856 100644 --- a/riscv/insns/vmfgt_vf.h +++ b/riscv/insns/vmfgt_vf.h @@ -2,4 +2,4 @@ VI_VFP_LOOP_CMP ({ res = f32_lt(rs1, vs2); -}) +}, false) diff --git a/riscv/insns/vmfle_vf.h b/riscv/insns/vmfle_vf.h index 998b93b2..90607ec0 100644 --- a/riscv/insns/vmfle_vf.h +++ b/riscv/insns/vmfle_vf.h @@ -2,4 +2,4 @@ VI_VFP_LOOP_CMP ({ res = f32_le(vs2, rs1); -}) +}, false) diff --git a/riscv/insns/vmfle_vv.h b/riscv/insns/vmfle_vv.h index 2268542f..6ccdfec4 100644 --- a/riscv/insns/vmfle_vv.h +++ b/riscv/insns/vmfle_vv.h @@ -2,4 +2,4 @@ VI_VFP_LOOP_CMP ({ res = f32_le(vs2, vs1); -}) +}, true) diff --git a/riscv/insns/vmflt_vf.h b/riscv/insns/vmflt_vf.h index 70847a1d..6b71a4af 100644 --- a/riscv/insns/vmflt_vf.h +++ b/riscv/insns/vmflt_vf.h @@ -2,4 +2,4 @@ VI_VFP_LOOP_CMP ({ res = f32_lt(vs2, rs1); -}) +}, false) diff --git a/riscv/insns/vmflt_vv.h b/riscv/insns/vmflt_vv.h index 97784c09..a2ed8e32 100644 --- a/riscv/insns/vmflt_vv.h +++ b/riscv/insns/vmflt_vv.h @@ -2,4 +2,4 @@ VI_VFP_LOOP_CMP ({ res = f32_lt(vs2, vs1); -}) +}, true) diff --git a/riscv/insns/vmfne_vf.h b/riscv/insns/vmfne_vf.h index ac2eced0..ef636780 100644 --- a/riscv/insns/vmfne_vf.h +++ b/riscv/insns/vmfne_vf.h @@ -2,4 +2,4 @@ VI_VFP_LOOP_CMP ({ res = !f32_eq(vs2, rs1); -}) +}, false) diff --git a/riscv/insns/vmfne_vv.h b/riscv/insns/vmfne_vv.h index 3fa8bebe..8378a23a 100644 --- a/riscv/insns/vmfne_vv.h +++ b/riscv/insns/vmfne_vv.h @@ -2,4 +2,4 @@ VI_VFP_LOOP_CMP ({ res = !f32_eq(vs2, vs1); -}) +}, true)