From: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, aleksandar.rikalo@syrmia.com,
f4bug@amsat.org, jiaxun.yang@flygoat.com,
Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>,
hpoussin@reactos.org, chenhc@lemote.com, aurelien@aurel32.net
Subject: [PATCH v2 4/5] target/mips: Refactor helpers for fp comparison instructions
Date: Wed, 7 Oct 2020 22:37:20 +0200 [thread overview]
Message-ID: <1602103041-32017-5-git-send-email-aleksandar.qemu.devel@gmail.com> (raw)
In-Reply-To: <1602103041-32017-1-git-send-email-aleksandar.qemu.devel@gmail.com>
This change causes slighlty better performance of emulation of fp
comparison instructions via better compiler optimization of refactored
code. The functionality is otherwise unchanged.
Signed-off-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
---
target/mips/fpu_helper.c | 56 +++++++++++++++++++++++++++---------------------
1 file changed, 32 insertions(+), 24 deletions(-)
diff --git a/target/mips/fpu_helper.c b/target/mips/fpu_helper.c
index 6cc956c..8d48a5b 100644
--- a/target/mips/fpu_helper.c
+++ b/target/mips/fpu_helper.c
@@ -1780,11 +1780,12 @@ void helper_cmp_d_ ## op(CPUMIPSState *env, uint64_t fdt0, \
{ \
int c; \
c = cond; \
- update_fcr31(env, GETPC()); \
- if (c) \
+ if (c) { \
SET_FP_COND(cc, env->active_fpu); \
- else \
+ } else { \
CLEAR_FP_COND(cc, env->active_fpu); \
+ } \
+ update_fcr31(env, GETPC()); \
} \
void helper_cmpabs_d_ ## op(CPUMIPSState *env, uint64_t fdt0, \
uint64_t fdt1, int cc) \
@@ -1793,11 +1794,12 @@ void helper_cmpabs_d_ ## op(CPUMIPSState *env, uint64_t fdt0, \
fdt0 = float64_abs(fdt0); \
fdt1 = float64_abs(fdt1); \
c = cond; \
- update_fcr31(env, GETPC()); \
- if (c) \
+ if (c) { \
SET_FP_COND(cc, env->active_fpu); \
- else \
+ } else { \
CLEAR_FP_COND(cc, env->active_fpu); \
+ } \
+ update_fcr31(env, GETPC()); \
}
/*
@@ -1859,11 +1861,12 @@ void helper_cmp_s_ ## op(CPUMIPSState *env, uint32_t fst0, \
{ \
int c; \
c = cond; \
- update_fcr31(env, GETPC()); \
- if (c) \
+ if (c) { \
SET_FP_COND(cc, env->active_fpu); \
- else \
+ } else { \
CLEAR_FP_COND(cc, env->active_fpu); \
+ } \
+ update_fcr31(env, GETPC()); \
} \
void helper_cmpabs_s_ ## op(CPUMIPSState *env, uint32_t fst0, \
uint32_t fst1, int cc) \
@@ -1872,11 +1875,12 @@ void helper_cmpabs_s_ ## op(CPUMIPSState *env, uint32_t fst0, \
fst0 = float32_abs(fst0); \
fst1 = float32_abs(fst1); \
c = cond; \
- update_fcr31(env, GETPC()); \
- if (c) \
+ if (c) { \
SET_FP_COND(cc, env->active_fpu); \
- else \
+ } else { \
CLEAR_FP_COND(cc, env->active_fpu); \
+ } \
+ update_fcr31(env, GETPC()); \
}
/*
@@ -1944,15 +1948,17 @@ void helper_cmp_ps_ ## op(CPUMIPSState *env, uint64_t fdt0, \
fsth1 = fdt1 >> 32; \
cl = condl; \
ch = condh; \
- update_fcr31(env, GETPC()); \
- if (cl) \
+ if (cl) { \
SET_FP_COND(cc, env->active_fpu); \
- else \
+ } else { \
CLEAR_FP_COND(cc, env->active_fpu); \
- if (ch) \
+ } \
+ if (ch) { \
SET_FP_COND(cc + 1, env->active_fpu); \
- else \
+ } else { \
CLEAR_FP_COND(cc + 1, env->active_fpu); \
+ } \
+ update_fcr31(env, GETPC()); \
} \
void helper_cmpabs_ps_ ## op(CPUMIPSState *env, uint64_t fdt0, \
uint64_t fdt1, int cc) \
@@ -1965,15 +1971,17 @@ void helper_cmpabs_ps_ ## op(CPUMIPSState *env, uint64_t fdt0, \
fsth1 = float32_abs(fdt1 >> 32); \
cl = condl; \
ch = condh; \
- update_fcr31(env, GETPC()); \
- if (cl) \
+ if (cl) { \
SET_FP_COND(cc, env->active_fpu); \
- else \
+ } else { \
CLEAR_FP_COND(cc, env->active_fpu); \
- if (ch) \
+ } \
+ if (ch) { \
SET_FP_COND(cc + 1, env->active_fpu); \
- else \
+ } else { \
CLEAR_FP_COND(cc + 1, env->active_fpu); \
+ } \
+ update_fcr31(env, GETPC()); \
}
/*
@@ -2080,12 +2088,12 @@ uint64_t helper_r6_cmp_d_ ## op(CPUMIPSState *env, uint64_t fdt0, \
{ \
uint64_t c; \
c = cond; \
- update_fcr31(env, GETPC()); \
if (c) { \
return -1; \
} else { \
return 0; \
} \
+ update_fcr31(env, GETPC()); \
}
/*
@@ -2175,12 +2183,12 @@ uint32_t helper_r6_cmp_s_ ## op(CPUMIPSState *env, uint32_t fst0, \
{ \
uint64_t c; \
c = cond; \
- update_fcr31(env, GETPC()); \
if (c) { \
return -1; \
} else { \
return 0; \
} \
+ update_fcr31(env, GETPC()); \
}
/*
--
2.7.4
next prev parent reply other threads:[~2020-10-07 20:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-07 20:37 [PATCH v2 0/5] target/mips: Misc patches Aleksandar Markovic
2020-10-07 20:37 ` [PATCH v2 1/5] target/mips: Demacro helpers for <ABS|CHS>.<D|S|PS> Aleksandar Markovic
2020-10-09 14:39 ` Philippe Mathieu-Daudé
2020-10-07 20:37 ` [PATCH v2 2/5] target/mips: Demacro helpers for M<ADD|SUB>F.<D|S> Aleksandar Markovic
2020-10-09 14:42 ` Philippe Mathieu-Daudé
2020-10-07 20:37 ` [PATCH v2 3/5] target/mips: Demacro helpers for <MAX|MAXA|MIN|MINA>.<D|S> Aleksandar Markovic
2020-10-09 14:44 ` Philippe Mathieu-Daudé
2020-10-07 20:37 ` Aleksandar Markovic [this message]
2020-10-09 14:47 ` [PATCH v2 4/5] target/mips: Refactor helpers for fp comparison instructions Philippe Mathieu-Daudé
2020-10-16 20:17 ` Philippe Mathieu-Daudé
2020-10-07 20:37 ` [PATCH v2 5/5] MAINTAINERS: Remove myself Aleksandar Markovic
2020-10-08 7:21 ` chen huacai
2020-10-08 10:21 ` Philippe Mathieu-Daudé
2020-10-08 10:51 ` Philippe Mathieu-Daudé
2020-10-09 2:52 ` Jiaxun Yang
2020-10-09 15:00 ` [PATCH v2 0/5] target/mips: Misc patches Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1602103041-32017-5-git-send-email-aleksandar.qemu.devel@gmail.com \
--to=aleksandar.qemu.devel@gmail.com \
--cc=aleksandar.rikalo@syrmia.com \
--cc=aurelien@aurel32.net \
--cc=chenhc@lemote.com \
--cc=f4bug@amsat.org \
--cc=hpoussin@reactos.org \
--cc=jiaxun.yang@flygoat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).