From: Mateja Marjanovic <mateja.marjano...@rt-rk.com> In case of dividing integers by zero, the result is unpredictable [1], but according to the hardware, the result is not zero, but the dividend.
[1] MIPS® Architecture for Programmers Volume IV-j: The MIPS64® SIMD Architecture Module, Revision 1.12 Signed-off-by: Mateja Marjanovic <mateja.marjano...@rt-rk.com> --- target/mips/msa_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/mips/msa_helper.c b/target/mips/msa_helper.c index 46a5aac..bdfbc95 100644 --- a/target/mips/msa_helper.c +++ b/target/mips/msa_helper.c @@ -659,14 +659,14 @@ static inline int64_t msa_mod_s_df(uint32_t df, int64_t arg1, int64_t arg2) if (arg1 == DF_MIN_INT(df) && arg2 == -1) { return 0; } - return arg2 ? arg1 % arg2 : 0; + return arg2 ? arg1 % arg2 : arg1; } static inline int64_t msa_mod_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 u_arg2 ? u_arg1 % u_arg2 : u_arg1; } #define SIGNED_EVEN(a, df) \ -- 2.7.4