From patchwork Tue Dec 2 17:51:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 416955 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 534E714011D for ; Wed, 3 Dec 2014 04:51:53 +1100 (AEDT) Received: from localhost ([::1]:38102 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xvrc6-0003lB-P1 for incoming@patchwork.ozlabs.org; Tue, 02 Dec 2014 12:51:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57078) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xvrbi-0003PW-Ko for qemu-devel@nongnu.org; Tue, 02 Dec 2014 12:51:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xvrbb-0005Yy-O3 for qemu-devel@nongnu.org; Tue, 02 Dec 2014 12:51:26 -0500 Received: from relay1.mentorg.com ([192.94.38.131]:43847) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xvrbb-0005YV-Eq for qemu-devel@nongnu.org; Tue, 02 Dec 2014 12:51:19 -0500 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1XvrbZ-00067J-9O from Maciej_Rozycki@mentor.com ; Tue, 02 Dec 2014 09:51:17 -0800 Received: from localhost (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 2 Dec 2014 17:51:15 +0000 Date: Tue, 2 Dec 2014 17:51:12 +0000 From: "Maciej W. Rozycki" To: Message-ID: User-Agent: Alpine 1.10 (DEB 962 2008-03-14) MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 Cc: Leon Alrae , Aurelien Jarno Subject: [Qemu-devel] [PATCH] target-mips: Use local float status pointer across MSA macros X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Reduce line wrapping throughout MSA helper macros by using a local float status pointer rather than referring to the float status through the environment each time. No functional change. Signed-off-by: Maciej W. Rozycki Reviewed-by: Leon Alrae --- Hi, The same float status applies across a single MSA operation (i.e. there can't be an MT thread context switch in the middle) so there is no need to get through the environment on each individual sub-operation. And at any reasonable optimisation level code generated should be the same if not better. The local pointer will help with a follow-up change that would otherwise make line wrapping unbearable. Please apply, Maciej qemu-mips-msa-helper-status.diff Index: qemu-git-trunk/target-mips/msa_helper.c =================================================================== --- qemu-git-trunk.orig/target-mips/msa_helper.c 2014-11-21 13:04:27.000000000 +0000 +++ qemu-git-trunk/target-mips/msa_helper.c 2014-11-21 13:07:07.267638120 +0000 @@ -1782,15 +1782,14 @@ static inline int32 float64_to_q32(float #define MSA_FLOAT_COND(DEST, OP, ARG1, ARG2, BITS, QUIET) \ do { \ + float_status *status = &env->active_tc.msa_fp_status; \ int c; \ int64_t cond; \ - set_float_exception_flags(0, &env->active_tc.msa_fp_status); \ + set_float_exception_flags(0, status); \ if (!QUIET) { \ - cond = float ## BITS ## _ ## OP(ARG1, ARG2, \ - &env->active_tc.msa_fp_status); \ + cond = float ## BITS ## _ ## OP(ARG1, ARG2, status); \ } else { \ - cond = float ## BITS ## _ ## OP ## _quiet(ARG1, ARG2, \ - &env->active_tc.msa_fp_status); \ + cond = float ## BITS ## _ ## OP ## _quiet(ARG1, ARG2, status); \ } \ DEST = cond ? M_MAX_UINT(BITS) : 0; \ c = update_msacsr(env, CLEAR_IS_INEXACT, 0); \ @@ -2375,11 +2374,11 @@ void helper_msa_fsne_df(CPUMIPSState *en #define MSA_FLOAT_BINOP(DEST, OP, ARG1, ARG2, BITS) \ do { \ + float_status *status = &env->active_tc.msa_fp_status; \ int c; \ \ - set_float_exception_flags(0, &env->active_tc.msa_fp_status); \ - DEST = float ## BITS ## _ ## OP(ARG1, ARG2, \ - &env->active_tc.msa_fp_status); \ + set_float_exception_flags(0, status); \ + DEST = float ## BITS ## _ ## OP(ARG1, ARG2, status); \ c = update_msacsr(env, 0, IS_DENORMAL(DEST, BITS)); \ \ if (get_enabled_exceptions(env, c)) { \ @@ -2511,11 +2510,11 @@ void helper_msa_fdiv_df(CPUMIPSState *en #define MSA_FLOAT_MULADD(DEST, ARG1, ARG2, ARG3, NEGATE, BITS) \ do { \ + float_status *status = &env->active_tc.msa_fp_status; \ int c; \ \ - set_float_exception_flags(0, &env->active_tc.msa_fp_status); \ - DEST = float ## BITS ## _muladd(ARG2, ARG3, ARG1, NEGATE, \ - &env->active_tc.msa_fp_status); \ + set_float_exception_flags(0, status); \ + DEST = float ## BITS ## _muladd(ARG2, ARG3, ARG1, NEGATE, status); \ c = update_msacsr(env, 0, IS_DENORMAL(DEST, BITS)); \ \ if (get_enabled_exceptions(env, c)) { \ @@ -2630,10 +2629,11 @@ void helper_msa_fexp2_df(CPUMIPSState *e #define MSA_FLOAT_UNOP(DEST, OP, ARG, BITS) \ do { \ + float_status *status = &env->active_tc.msa_fp_status; \ int c; \ \ - set_float_exception_flags(0, &env->active_tc.msa_fp_status); \ - DEST = float ## BITS ## _ ## OP(ARG, &env->active_tc.msa_fp_status);\ + set_float_exception_flags(0, status); \ + DEST = float ## BITS ## _ ## OP(ARG, status); \ c = update_msacsr(env, 0, IS_DENORMAL(DEST, BITS)); \ \ if (get_enabled_exceptions(env, c)) { \ @@ -2678,10 +2678,11 @@ void helper_msa_fexdo_df(CPUMIPSState *e #define MSA_FLOAT_UNOP_XD(DEST, OP, ARG, BITS, XBITS) \ do { \ + float_status *status = &env->active_tc.msa_fp_status; \ int c; \ \ - set_float_exception_flags(0, &env->active_tc.msa_fp_status); \ - DEST = float ## BITS ## _ ## OP(ARG, &env->active_tc.msa_fp_status);\ + set_float_exception_flags(0, status); \ + DEST = float ## BITS ## _ ## OP(ARG, status); \ c = update_msacsr(env, CLEAR_FS_UNDERFLOW, 0); \ \ if (get_enabled_exceptions(env, c)) { \ @@ -2728,11 +2729,11 @@ void helper_msa_ftq_df(CPUMIPSState *env #define MSA_FLOAT_MAXOP(DEST, OP, ARG1, ARG2, BITS) \ do { \ + float_status *status = &env->active_tc.msa_fp_status; \ int c; \ \ - set_float_exception_flags(0, &env->active_tc.msa_fp_status); \ - DEST = float ## BITS ## _ ## OP(ARG1, ARG2, \ - &env->active_tc.msa_fp_status); \ + set_float_exception_flags(0, status); \ + DEST = float ## BITS ## _ ## OP(ARG1, ARG2, status); \ c = update_msacsr(env, 0, 0); \ \ if (get_enabled_exceptions(env, c)) { \ @@ -2924,10 +2925,11 @@ void helper_msa_fclass_df(CPUMIPSState * #define MSA_FLOAT_UNOP0(DEST, OP, ARG, BITS) \ do { \ + float_status *status = &env->active_tc.msa_fp_status; \ int c; \ \ - set_float_exception_flags(0, &env->active_tc.msa_fp_status); \ - DEST = float ## BITS ## _ ## OP(ARG, &env->active_tc.msa_fp_status);\ + set_float_exception_flags(0, status); \ + DEST = float ## BITS ## _ ## OP(ARG, status); \ c = update_msacsr(env, CLEAR_FS_UNDERFLOW, 0); \ \ if (get_enabled_exceptions(env, c)) { \ @@ -3029,11 +3031,11 @@ void helper_msa_fsqrt_df(CPUMIPSState *e #define MSA_FLOAT_RECIPROCAL(DEST, ARG, BITS) \ do { \ + float_status *status = &env->active_tc.msa_fp_status; \ int c; \ \ - set_float_exception_flags(0, &env->active_tc.msa_fp_status); \ - DEST = float ## BITS ## _ ## div(FLOAT_ONE ## BITS, ARG, \ - &env->active_tc.msa_fp_status); \ + set_float_exception_flags(0, status); \ + DEST = float ## BITS ## _ ## div(FLOAT_ONE ## BITS, ARG, status); \ c = update_msacsr(env, float ## BITS ## _is_infinity(ARG) || \ float ## BITS ## _is_quiet_nan(DEST) ? \ 0 : RECIPROCAL_INEXACT, \ @@ -3138,23 +3140,20 @@ void helper_msa_frint_df(CPUMIPSState *e #define MSA_FLOAT_LOGB(DEST, ARG, BITS) \ do { \ + float_status *status = &env->active_tc.msa_fp_status; \ int c; \ \ - set_float_exception_flags(0, &env->active_tc.msa_fp_status); \ - set_float_rounding_mode(float_round_down, \ - &env->active_tc.msa_fp_status); \ - DEST = float ## BITS ## _ ## log2(ARG, \ - &env->active_tc.msa_fp_status); \ - DEST = float ## BITS ## _ ## round_to_int(DEST, \ - &env->active_tc.msa_fp_status); \ + set_float_exception_flags(0, status); \ + set_float_rounding_mode(float_round_down, status); \ + DEST = float ## BITS ## _ ## log2(ARG, status); \ + DEST = float ## BITS ## _ ## round_to_int(DEST, status); \ set_float_rounding_mode(ieee_rm[(env->active_tc.msacsr & \ MSACSR_RM_MASK) >> MSACSR_RM], \ - &env->active_tc.msa_fp_status); \ + status); \ \ - set_float_exception_flags( \ - get_float_exception_flags(&env->active_tc.msa_fp_status) \ - & (~float_flag_inexact), \ - &env->active_tc.msa_fp_status); \ + set_float_exception_flags(get_float_exception_flags(status) & \ + (~float_flag_inexact), \ + status); \ \ c = update_msacsr(env, 0, IS_DENORMAL(DEST, BITS)); \ \