qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: qemu-devel@nongnu.org
Cc: Alexander Graf <agraf@suse.de>,
	Aurelien Jarno <aurelien@aurel32.net>,
	Richard Henderson <rth@twiddle.net>
Subject: [Qemu-devel] [PATCH 2/3] target-s390x: optimize (negative-) abs computation
Date: Mon, 18 May 2015 15:39:59 +0200	[thread overview]
Message-ID: <1431956400-19091-2-git-send-email-aurelien@aurel32.net> (raw)
In-Reply-To: <1431956400-19091-1-git-send-email-aurelien@aurel32.net>

Now that movcond exists, it's easy to write (negative-) absolute value
using TCG code instead of an helper.

Cc: Richard Henderson <rth@twiddle.net>
Cc: Alexander Graf <agraf@suse.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
 target-s390x/helper.h     |  2 --
 target-s390x/int_helper.c | 22 ----------------------
 target-s390x/translate.c  | 16 ++++++++++++++--
 3 files changed, 14 insertions(+), 26 deletions(-)

diff --git a/target-s390x/helper.h b/target-s390x/helper.h
index 8d2c859..c4ec3f1 100644
--- a/target-s390x/helper.h
+++ b/target-s390x/helper.h
@@ -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_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(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(lam, TCG_CALL_NO_WG, void, env, i32, i64, i32)
 DEF_HELPER_4(mvcle, i32, env, i32, i64, i32)
diff --git a/target-s390x/int_helper.c b/target-s390x/int_helper.c
index cb8dd98..f53723d 100644
--- a/target-s390x/int_helper.c
+++ b/target-s390x/int_helper.c
@@ -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 */
 uint64_t HELPER(clz)(uint64_t v)
 {
diff --git a/target-s390x/translate.c b/target-s390x/translate.c
index c297938..5898adb 100644
--- a/target-s390x/translate.c
+++ b/target-s390x/translate.c
@@ -1304,7 +1304,13 @@ static ExitStatus help_branch(DisasContext *s, DisasCompare *c,
 
 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;
 }
 
@@ -2675,7 +2681,13 @@ static ExitStatus op_msdb(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;
 }
 
-- 
2.1.4

  reply	other threads:[~2015-05-18 13:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-18 13:39 [Qemu-devel] [PATCH 1/3] target-s390x: fix CC computation for LOAD POSITIVE instructions Aurelien Jarno
2015-05-18 13:39 ` Aurelien Jarno [this message]
2015-05-18 15:42   ` [Qemu-devel] [PATCH 2/3] target-s390x: optimize (negative-) abs computation Richard Henderson
2015-05-18 13:40 ` [Qemu-devel] [PATCH 3/3] target-s390x: remove unused helpers Aurelien Jarno
2015-05-18 15:42   ` Richard Henderson
2015-05-18 15:42 ` [Qemu-devel] [PATCH 1/3] target-s390x: fix CC computation for LOAD POSITIVE instructions Richard Henderson
2015-05-18 17:04 ` Alexander Graf

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=1431956400-19091-2-git-send-email-aurelien@aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=agraf@suse.de \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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).