Skip to content

Commit

Permalink
[RV64_DYNAREC] Fixed SET_ELEMENT_WIDTH (#2260)
Browse files Browse the repository at this point in the history
... also removed some unnecessary instructions in vector_loadmask
  • Loading branch information
ksco authored Jan 14, 2025
1 parent bcc497c commit d91461f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
3 changes: 0 additions & 3 deletions src/dynarec/rv64/dynarec_rv64_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -3035,7 +3035,6 @@ void vector_loadmask(dynarec_rv64_t* dyn, int ninst, int vreg, uint64_t imm, int
int scratch = fpu_get_scratch(dyn);
vector_vsetvli(dyn, ninst, s1, VECTOR_SEW64, VECTOR_LMUL1, 1);
VMV_V_I(scratch, 1);
VMV_S_X(vreg, xZR);
VSLIDE1UP_VX(vreg, scratch, xZR, VECTOR_UNMASKED);
vector_vsetvli(dyn, ninst, s1, sew, vlmul, multiple);
return;
Expand Down Expand Up @@ -3068,7 +3067,6 @@ void vector_loadmask(dynarec_rv64_t* dyn, int ninst, int vreg, uint64_t imm, int
vector_vsetvli(dyn, ninst, s1, VECTOR_SEW64, VECTOR_LMUL1, 1);
MOV64x(s1, 0x100000000ULL);
VMV_V_X(scratch, s1);
VMV_S_X(vreg, xZR);
VSLIDE1UP_VX(vreg, scratch, xZR, VECTOR_UNMASKED);
vector_vsetvli(dyn, ninst, s1, sew, vlmul, multiple);
return;
Expand Down Expand Up @@ -3104,7 +3102,6 @@ void vector_loadmask(dynarec_rv64_t* dyn, int ninst, int vreg, uint64_t imm, int
vector_vsetvli(dyn, ninst, s1, VECTOR_SEW64, VECTOR_LMUL1, 1);
MOV64x(s1, 0x100000001ULL);
VMV_V_X(scratch, s1);
VMV_S_X(vreg, xZR);
VSLIDE1UP_VX(vreg, scratch, xZR, VECTOR_UNMASKED);
vector_vsetvli(dyn, ninst, s1, sew, vlmul, multiple);
return;
Expand Down
20 changes: 10 additions & 10 deletions src/dynarec/rv64/dynarec_rv64_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -1147,16 +1147,16 @@
#define MODREG ((nextop & 0xC0) == 0xC0)

#ifndef SET_ELEMENT_WIDTH
#define SET_ELEMENT_WIDTH(s1, sew, set) \
do { \
if (sew == VECTOR_SEWANY && dyn->vector_sew != VECTOR_SEWNA) { \
dyn->vector_eew = dyn->vector_sew; \
} else if (sew == dyn->vector_sew) { \
dyn->vector_eew = dyn->vector_sew; \
} else { \
dyn->vector_eew = vector_vsetvli(dyn, ninst, s1, sew, VECTOR_LMUL1, 1); \
} \
if (set) dyn->vector_sew = dyn->vector_eew; \
#define SET_ELEMENT_WIDTH(s1, sew, set) \
do { \
if ((sew) == VECTOR_SEWANY && dyn->vector_sew != VECTOR_SEWNA) { \
dyn->vector_eew = dyn->vector_sew; \
} else if ((sew) == dyn->vector_sew) { \
dyn->vector_eew = dyn->vector_sew; \
} else { \
dyn->vector_eew = vector_vsetvli(dyn, ninst, s1, (sew), VECTOR_LMUL1, 1); \
} \
if (set) dyn->vector_sew = dyn->vector_eew; \
} while (0)
#endif

Expand Down
12 changes: 6 additions & 6 deletions src/dynarec/rv64/dynarec_rv64_pass0.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@
dynarec_log(LOG_NONE, "\n"); \
}

#define SET_ELEMENT_WIDTH(s1, sew, set) \
do { \
if (sew != VECTOR_SEWANY && set) \
dyn->vector_sew = sew; \
else if (dyn->vector_sew == VECTOR_SEWNA && set) \
dyn->vector_sew = VECTOR_SEW8; \
#define SET_ELEMENT_WIDTH(s1, sew, set) \
do { \
if ((sew) != VECTOR_SEWANY && (set)) \
dyn->vector_sew = (sew); \
else if (dyn->vector_sew == VECTOR_SEWNA && (set)) \
dyn->vector_sew = VECTOR_SEW8; \
} while (0)

0 comments on commit d91461f

Please sign in to comment.