summaryrefslogtreecommitdiffstats
path: root/target/s390x/cc_helper.c
diff options
context:
space:
mode:
authorRichard Henderson2020-12-14 23:13:53 +0100
committerCornelia Huck2020-12-21 18:11:33 +0100
commitff26d287bddc189fd5a084cc96078da1257b0826 (patch)
treeb3933690ae362e092a809e2aa234002e1125818a /target/s390x/cc_helper.c
parentqga/commands-posix: Send CCW address on s390x with the fsinfo data (diff)
downloadqemu-ff26d287bddc189fd5a084cc96078da1257b0826.tar.gz
qemu-ff26d287bddc189fd5a084cc96078da1257b0826.tar.xz
qemu-ff26d287bddc189fd5a084cc96078da1257b0826.zip
target/s390x: Improve cc computation for ADD LOGICAL
The resulting cc is only dependent on the result and the carry-out. So save those things rather than the inputs. Carry-out for 64-bit inputs is had via tcg_gen_add2_i64 directly into cc_src. Carry-out for 32-bit inputs is had via extraction from a normal 64-bit add (with zero-extended inputs). Reviewed-by: David Hildenbrand <david@redhat.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20201214221356.68039-2-richard.henderson@linaro.org> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Diffstat (limited to 'target/s390x/cc_helper.c')
-rw-r--r--target/s390x/cc_helper.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/target/s390x/cc_helper.c b/target/s390x/cc_helper.c
index 5432aeeed4..59da4d1cc2 100644
--- a/target/s390x/cc_helper.c
+++ b/target/s390x/cc_helper.c
@@ -123,6 +123,12 @@ static uint32_t cc_calc_nz(uint64_t dst)
return !!dst;
}
+static uint32_t cc_calc_addu(uint64_t carry_out, uint64_t result)
+{
+ g_assert(carry_out <= 1);
+ return (result != 0) + 2 * carry_out;
+}
+
static uint32_t cc_calc_add_64(int64_t a1, int64_t a2, int64_t ar)
{
if ((a1 > 0 && a2 > 0 && ar < 0) || (a1 < 0 && a2 < 0 && ar > 0)) {
@@ -138,11 +144,6 @@ static uint32_t cc_calc_add_64(int64_t a1, int64_t a2, int64_t ar)
}
}
-static uint32_t cc_calc_addu_64(uint64_t a1, uint64_t a2, uint64_t ar)
-{
- return (ar != 0) + 2 * (ar < a1);
-}
-
static uint32_t cc_calc_addc_64(uint64_t a1, uint64_t a2, uint64_t ar)
{
/* Recover a2 + carry_in. */
@@ -239,11 +240,6 @@ static uint32_t cc_calc_add_32(int32_t a1, int32_t a2, int32_t ar)
}
}
-static uint32_t cc_calc_addu_32(uint32_t a1, uint32_t a2, uint32_t ar)
-{
- return (ar != 0) + 2 * (ar < a1);
-}
-
static uint32_t cc_calc_addc_32(uint32_t a1, uint32_t a2, uint32_t ar)
{
/* Recover a2 + carry_in. */
@@ -483,12 +479,12 @@ static uint32_t do_calc_cc(CPUS390XState *env, uint32_t cc_op,
case CC_OP_NZ:
r = cc_calc_nz(dst);
break;
+ case CC_OP_ADDU:
+ r = cc_calc_addu(src, dst);
+ break;
case CC_OP_ADD_64:
r = cc_calc_add_64(src, dst, vr);
break;
- case CC_OP_ADDU_64:
- r = cc_calc_addu_64(src, dst, vr);
- break;
case CC_OP_ADDC_64:
r = cc_calc_addc_64(src, dst, vr);
break;
@@ -517,9 +513,6 @@ static uint32_t do_calc_cc(CPUS390XState *env, uint32_t cc_op,
case CC_OP_ADD_32:
r = cc_calc_add_32(src, dst, vr);
break;
- case CC_OP_ADDU_32:
- r = cc_calc_addu_32(src, dst, vr);
- break;
case CC_OP_ADDC_32:
r = cc_calc_addc_32(src, dst, vr);
break;