From c3e10c7b4377c1cbc0a4fbc12312c2cf41c0cda7 Mon Sep 17 00:00:00 2001 From: j_mayer Date: Sun, 11 Nov 2007 00:18:34 +0000 Subject: Optimize PowerPC overflow flag computation in most useful cases. Use the same routines to check overflow for addo, subfo and PowerPC 405 multiply and add cases. Fix carry reset in addme(o) and subfme(o) cases. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3574 c046a42c-6fe2-441c-8c8c-71466251a162 --- target-ppc/op_helper.c | 75 +++++++++++++++----------------------------------- 1 file changed, 22 insertions(+), 53 deletions(-) (limited to 'target-ppc/op_helper.c') diff --git a/target-ppc/op_helper.c b/target-ppc/op_helper.c index 6ed9c95331..75bf33bff1 100644 --- a/target-ppc/op_helper.c +++ b/target-ppc/op_helper.c @@ -151,15 +151,12 @@ void do_addmeo (void) { T1 = T0; T0 += xer_ca + (-1); - if (likely(!((uint32_t)T1 & - ((uint32_t)T1 ^ (uint32_t)T0) & (1UL << 31)))) { - xer_ov = 0; - } else { - xer_ov = 1; - xer_so = 1; - } + xer_ov = ((uint32_t)T1 & ((uint32_t)T1 ^ (uint32_t)T0)) >> 31; + xer_so |= xer_ov; if (likely(T1 != 0)) xer_ca = 1; + else + xer_ca = 0; } #if defined(TARGET_PPC64) @@ -167,15 +164,12 @@ void do_addmeo_64 (void) { T1 = T0; T0 += xer_ca + (-1); - if (likely(!((uint64_t)T1 & - ((uint64_t)T1 ^ (uint64_t)T0) & (1ULL << 63)))) { - xer_ov = 0; - } else { - xer_ov = 1; - xer_so = 1; - } + xer_ov = ((uint64_t)T1 & ((uint64_t)T1 ^ (uint64_t)T0)) >> 63; + xer_so |= xer_ov; if (likely(T1 != 0)) xer_ca = 1; + else + xer_ca = 0; } #endif @@ -316,15 +310,12 @@ void do_subfmeo (void) { T1 = T0; T0 = ~T0 + xer_ca - 1; - if (likely(!((uint32_t)~T1 & ((uint32_t)~T1 ^ (uint32_t)T0) & - (1UL << 31)))) { - xer_ov = 0; - } else { - xer_ov = 1; - xer_so = 1; - } + xer_ov = ((uint32_t)~T1 & ((uint32_t)~T1 ^ (uint32_t)T0)) >> 31; + xer_so |= xer_ov; if (likely((uint32_t)T1 != UINT32_MAX)) xer_ca = 1; + else + xer_ca = 0; } #if defined(TARGET_PPC64) @@ -332,15 +323,12 @@ void do_subfmeo_64 (void) { T1 = T0; T0 = ~T0 + xer_ca - 1; - if (likely(!((uint64_t)~T1 & ((uint64_t)~T1 ^ (uint64_t)T0) & - (1ULL << 63)))) { - xer_ov = 0; - } else { - xer_ov = 1; - xer_so = 1; - } + xer_ov = ((uint64_t)~T1 & ((uint64_t)~T1 ^ (uint64_t)T0)) >> 63; + xer_so |= xer_ov; if (likely((uint64_t)T1 != UINT64_MAX)) xer_ca = 1; + else + xer_ca = 0; } #endif @@ -348,13 +336,9 @@ void do_subfzeo (void) { T1 = T0; T0 = ~T0 + xer_ca; - if (likely(!(((uint32_t)~T1 ^ UINT32_MAX) & - ((uint32_t)(~T1) ^ (uint32_t)T0) & (1UL << 31)))) { - xer_ov = 0; - } else { - xer_ov = 1; - xer_so = 1; - } + xer_ov = (((uint32_t)~T1 ^ UINT32_MAX) & + ((uint32_t)(~T1) ^ (uint32_t)T0)) >> 31; + xer_so |= xer_ov; if (likely((uint32_t)T0 >= (uint32_t)~T1)) { xer_ca = 0; } else { @@ -367,13 +351,9 @@ void do_subfzeo_64 (void) { T1 = T0; T0 = ~T0 + xer_ca; - if (likely(!(((uint64_t)~T1 ^ UINT64_MAX) & - ((uint64_t)(~T1) ^ (uint64_t)T0) & (1ULL << 63)))) { - xer_ov = 0; - } else { - xer_ov = 1; - xer_so = 1; - } + xer_ov = (((uint64_t)~T1 ^ UINT64_MAX) & + ((uint64_t)(~T1) ^ (uint64_t)T0)) >> 63; + xer_so |= xer_ov; if (likely((uint64_t)T0 >= (uint64_t)~T1)) { xer_ca = 0; } else { @@ -1755,17 +1735,6 @@ void do_op_602_mfrom (void) /*****************************************************************************/ /* Embedded PowerPC specific helpers */ -void do_405_check_ov (void) -{ - if (likely((((uint32_t)T1 ^ (uint32_t)T2) >> 31) || - !(((uint32_t)T0 ^ (uint32_t)T2) >> 31))) { - xer_ov = 0; - } else { - xer_ov = 1; - xer_so = 1; - } -} - void do_405_check_sat (void) { if (!likely((((uint32_t)T1 ^ (uint32_t)T2) >> 31) || -- cgit v1.2.3