提交 d3010781 编写于 作者: A Aurelien Jarno 提交者: Alexander Graf

target-s390x: optimize (negative-) abs computation

Now that movcond exists, it's easy to write (negative-) absolute value
using TCG code instead of an helper.
Signed-off-by: NAurelien Jarno <aurelien@aurel32.net>
Reviewed-by: NRichard Henderson <rth@twiddle.net>
Signed-off-by: NAlexander Graf <agraf@suse.de>
上级 2aaa1940
...@@ -17,8 +17,6 @@ DEF_HELPER_4(mvst, i64, env, i64, i64, i64) ...@@ -17,8 +17,6 @@ DEF_HELPER_4(mvst, i64, env, i64, i64, i64)
DEF_HELPER_5(ex, i32, env, i32, i64, i64, i64) DEF_HELPER_5(ex, i32, env, i32, i64, i64, i64)
DEF_HELPER_FLAGS_1(abs_i32, TCG_CALL_NO_RWG_SE, i32, s32) DEF_HELPER_FLAGS_1(abs_i32, TCG_CALL_NO_RWG_SE, i32, s32)
DEF_HELPER_FLAGS_1(nabs_i32, TCG_CALL_NO_RWG_SE, s32, s32) DEF_HELPER_FLAGS_1(nabs_i32, TCG_CALL_NO_RWG_SE, s32, s32)
DEF_HELPER_FLAGS_1(abs_i64, TCG_CALL_NO_RWG_SE, i64, s64)
DEF_HELPER_FLAGS_1(nabs_i64, TCG_CALL_NO_RWG_SE, s64, s64)
DEF_HELPER_FLAGS_4(stam, TCG_CALL_NO_WG, void, env, i32, i64, i32) DEF_HELPER_FLAGS_4(stam, TCG_CALL_NO_WG, void, env, i32, i64, i32)
DEF_HELPER_FLAGS_4(lam, TCG_CALL_NO_WG, void, env, i32, i64, i32) DEF_HELPER_FLAGS_4(lam, TCG_CALL_NO_WG, void, env, i32, i64, i32)
DEF_HELPER_4(mvcle, i32, env, i32, i64, i32) DEF_HELPER_4(mvcle, i32, env, i32, i64, i32)
......
...@@ -135,28 +135,6 @@ int32_t HELPER(nabs_i32)(int32_t val) ...@@ -135,28 +135,6 @@ int32_t HELPER(nabs_i32)(int32_t val)
} }
} }
/* absolute value 64-bit */
uint64_t HELPER(abs_i64)(int64_t val)
{
HELPER_LOG("%s: val 0x%" PRIx64 "\n", __func__, val);
if (val < 0) {
return -val;
} else {
return val;
}
}
/* negative absolute value 64-bit */
int64_t HELPER(nabs_i64)(int64_t val)
{
if (val < 0) {
return val;
} else {
return -val;
}
}
/* count leading zeros, for find leftmost one */ /* count leading zeros, for find leftmost one */
uint64_t HELPER(clz)(uint64_t v) uint64_t HELPER(clz)(uint64_t v)
{ {
......
...@@ -1310,7 +1310,13 @@ static ExitStatus help_branch(DisasContext *s, DisasCompare *c, ...@@ -1310,7 +1310,13 @@ static ExitStatus help_branch(DisasContext *s, DisasCompare *c,
static ExitStatus op_abs(DisasContext *s, DisasOps *o) static ExitStatus op_abs(DisasContext *s, DisasOps *o)
{ {
gen_helper_abs_i64(o->out, o->in2); TCGv_i64 z, n;
z = tcg_const_i64(0);
n = tcg_temp_new_i64();
tcg_gen_neg_i64(n, o->in2);
tcg_gen_movcond_i64(TCG_COND_LT, o->out, o->in2, z, n, o->in2);
tcg_temp_free_i64(n);
tcg_temp_free_i64(z);
return NO_EXIT; return NO_EXIT;
} }
...@@ -2680,7 +2686,13 @@ static ExitStatus op_msdb(DisasContext *s, DisasOps *o) ...@@ -2680,7 +2686,13 @@ static ExitStatus op_msdb(DisasContext *s, DisasOps *o)
static ExitStatus op_nabs(DisasContext *s, DisasOps *o) static ExitStatus op_nabs(DisasContext *s, DisasOps *o)
{ {
gen_helper_nabs_i64(o->out, o->in2); TCGv_i64 z, n;
z = tcg_const_i64(0);
n = tcg_temp_new_i64();
tcg_gen_neg_i64(n, o->in2);
tcg_gen_movcond_i64(TCG_COND_GE, o->out, o->in2, z, n, o->in2);
tcg_temp_free_i64(n);
tcg_temp_free_i64(z);
return NO_EXIT; return NO_EXIT;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册