mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-10 23:25:29 +00:00
target/mips: Make the results of DIV_<U|S>.<B|H|W|D> the same as on hardware
MSA instructions DIV_<U|S>.<B|H|W|D> when dividing by zero, didn't return the same value when executed on a referent hardware (FPGA MIPS 64 r6, little endian) and when executed on QEMU, which is not a real bug, because the result when dividing by zero is UNPREDICTABLE [1] (page 141, 142). [1] MIPS Architecture for Programmers Volume IV-j: The MIPS64 SIMD Architecture Module, Revision 1.12 Backports commit d2a40a5f6938f30f44b536e997e1e89bb62b971c from qemu
This commit is contained in:
parent
1d6acaa604
commit
d712d3f226
|
@ -641,14 +641,15 @@ static inline int64_t msa_div_s_df(uint32_t df, int64_t arg1, int64_t arg2)
|
|||
if (arg1 == DF_MIN_INT(df) && arg2 == -1) {
|
||||
return DF_MIN_INT(df);
|
||||
}
|
||||
return arg2 ? arg1 / arg2 : 0;
|
||||
return arg2 ? arg1 / arg2
|
||||
: arg1 >= 0 ? -1 : 1;
|
||||
}
|
||||
|
||||
static inline int64_t msa_div_u_df(uint32_t df, int64_t arg1, int64_t arg2)
|
||||
{
|
||||
uint64_t u_arg1 = UNSIGNED(arg1, df);
|
||||
uint64_t u_arg2 = UNSIGNED(arg2, df);
|
||||
return u_arg2 ? u_arg1 / u_arg2 : 0;
|
||||
return arg2 ? u_arg1 / u_arg2 : -1;
|
||||
}
|
||||
|
||||
static inline int64_t msa_mod_s_df(uint32_t df, int64_t arg1, int64_t arg2)
|
||||
|
|
Loading…
Reference in a new issue