From patchwork Thu Oct 26 00:14:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 738197 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp553035wrq; Wed, 25 Oct 2023 17:20:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFRmnflcCZ/JoeO876K/ZlvJUeIABfa4aEe0P7N7Dphe6D1lQdaw7/FLHjqw1uW//wd3QYv X-Received: by 2002:a5d:6e89:0:b0:320:6d6:315b with SMTP id k9-20020a5d6e89000000b0032006d6315bmr922696wrz.29.1698279606135; Wed, 25 Oct 2023 17:20:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698279606; cv=none; d=google.com; s=arc-20160816; b=dYiHdxUKuzaHnUiwEEZFCdjLOUN6XjM60RQ3bXh/TaQ1W41Uf+E1O8ncYTCr0Zffhr 5GswFnx0AYrv4cEnWz0K0fEQm+wWAQaI9WVh3IowqrBdVE3HH3lQxr+7BIvAWqT6C+yJ ulM8e/KwoctGATgNpRoF3/qj3GnekOLzhuT9jz8CYckN21ECjGrIniU8qBowvI72oJv9 C1TAqCQ6lBoG8Xnqlo9yTsj4kYXvNkcoArHLXKpBNyFcemca7bXx8gOGpK9mmzUf5z9a u0zd5iAv03oPNkRGiZh8so7UkM9xlVEn9BCAleI3nQTafLoDwb184Cxe4Wdls7InYKow PuqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=oTWlSTl88NPrS8w791ePjYqEfGwAj5/VqVJUyjszQKA=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=hNwIP/hyP5BHQJD8IOaKXGU+dXPHxjYgZwjVR5vtJhfhrg1+xcetrZ0TlPCHBe5iVj 7FLU9yU5XmieCXOZX+4n7H5z3FCQRENS1FFjOSui4eZT23lcZ52lHlRneyfGqTMMgY3+ hdxeXXVCqcsMq63IqobRiCWXspwx8wzkaslbfCrHLi6vc7IC8KyN4FMnPnVpu1mi3ig8 83iXuE9DWMadMETqkmFkJUTCuNuNNDz48KntHdPLyFvTZwtgNW78wIHJX+wEtEPtJCcq /sFVOJnLIjktIQabPUAX3NFeTqLL4iSfaxOjukF9F1IGunL/VwdGA8AkBwWS0tMRUUjc 3SXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EWk9T0gd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v5-20020a5d4a45000000b0032d829884b0si8088866wrs.816.2023.10.25.17.20.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2023 17:20:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EWk9T0gd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvo2z-0007Lh-6N; Wed, 25 Oct 2023 20:16:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvo2t-0007Al-Lr for qemu-devel@nongnu.org; Wed, 25 Oct 2023 20:16:19 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qvo2o-0004uv-PH for qemu-devel@nongnu.org; Wed, 25 Oct 2023 20:16:19 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1c9e06f058bso11212075ad.0 for ; Wed, 25 Oct 2023 17:16:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698279373; x=1698884173; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=oTWlSTl88NPrS8w791ePjYqEfGwAj5/VqVJUyjszQKA=; b=EWk9T0gdTUqHOAI1YUGzB//B7h1vwRf9sncQVQmFkOX4mt0MaFz8T1Cko/8tigV6eZ XI1yGbL2eZc4r2fDW5ohTcqea9OSEtufHyPUMHClEdDLlSEzboC+41tdMiijConmDj7e EJYAT3OloaQZou/WHC+zp8TG6loMCV2BvtHN5GSrrXZsFCjBBXsgU03o26BZBvrHYX4y tITUen4oSnNHCMaC6Sa9uCfzu4iYZdd1zoP+tX2Y/TFMDkbmp5o9Zxd8Q2wm0LlS6zG/ amOeSjwvIOH4iiDM2urltC6DuyBDqAAKMpTmb/6VY+7ZnnDOoKC5eUajqROtz3jsd7WS k43A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698279373; x=1698884173; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oTWlSTl88NPrS8w791ePjYqEfGwAj5/VqVJUyjszQKA=; b=Yg64Sx4vrqb+a7nkQWlPAxDunRf7xBHG1S+TQthdBZaQizM96lrbIbAjBoAzZ31z3C sbh738Pm81l1wHowfLu0L7HPmQvQO1RwVpEsIcUgbP38va1Ym+x+GOOSIHIBLZ6CZRRI 9WvjlCILxmkg5N40Hm1jdq1ZLziSL7fIOEhBb4sA4LMbsjVMTFICzJ2EzS9sBWlk9nul 0ZAHqUb0dWrytM2kwJGKKmeme8IeRSL+FV1YL6g/9CIlRFmp0AekfP+T52ZCRGRGbM6O trUs7/ne/r4N8LERm4/AqMPko0Xy+6oxahfANpU7fM+6Ar16bqHv3dVJo7u0Mn8cvVub QUsw== X-Gm-Message-State: AOJu0YzQrFM9Dp2jMPMlOk29iWxjPZJ7kLoB8K6aEcmGxh/aqo0m2chz WsgMbZHmfm/2KROOBp3GYijwnN7vC7PrlG6eJLU= X-Received: by 2002:a17:902:f54f:b0:1ca:15ad:1c5 with SMTP id h15-20020a170902f54f00b001ca15ad01c5mr1342866plf.6.1698279373538; Wed, 25 Oct 2023 17:16:13 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id ij23-20020a170902ab5700b001c582de968dsm10038433plb.72.2023.10.25.17.16.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 17:16:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 18/29] tcg/sparc64: Hoist read of tcg_cond_to_rcond Date: Wed, 25 Oct 2023 17:14:15 -0700 Message-Id: <20231026001542.1141412-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026001542.1141412-1-richard.henderson@linaro.org> References: <20231026001542.1141412-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use a non-zero value here (an illegal encoding) as a better condition than is_unsigned_cond for when MOVR/BPR is usable. Signed-off-by: Richard Henderson --- tcg/sparc64/tcg-target.c.inc | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc index a91defd0ac..13ad92b9b6 100644 --- a/tcg/sparc64/tcg-target.c.inc +++ b/tcg/sparc64/tcg-target.c.inc @@ -619,7 +619,7 @@ static const uint8_t tcg_cond_to_bcond[] = { [TCG_COND_GTU] = COND_GU, }; -static const uint8_t tcg_cond_to_rcond[] = { +static const uint8_t tcg_cond_to_rcond[16] = { [TCG_COND_EQ] = RCOND_Z, [TCG_COND_NE] = RCOND_NZ, [TCG_COND_LT] = RCOND_LZ, @@ -678,7 +678,8 @@ static void tcg_out_brcond_i64(TCGContext *s, TCGCond cond, TCGReg arg1, int32_t arg2, int const_arg2, TCGLabel *l) { /* For 64-bit signed comparisons vs zero, we can avoid the compare. */ - if (arg2 == 0 && !is_unsigned_cond(cond)) { + int rcond = tcg_cond_to_rcond[cond]; + if (arg2 == 0 && rcond) { int off16 = 0; if (l->has_value) { @@ -687,7 +688,7 @@ static void tcg_out_brcond_i64(TCGContext *s, TCGCond cond, TCGReg arg1, tcg_out_reloc(s, s->code_ptr, R_SPARC_WDISP16, l, 0); } tcg_out32(s, INSN_OP(0) | INSN_OP2(3) | BPR_PT | INSN_RS1(arg1) - | INSN_COND(tcg_cond_to_rcond[cond]) | off16); + | INSN_COND(rcond) | off16); } else { tcg_out_cmp(s, arg1, arg2, const_arg2); tcg_out_bpcc(s, tcg_cond_to_bcond[cond], BPCC_XCC | BPCC_PT, l); @@ -695,11 +696,10 @@ static void tcg_out_brcond_i64(TCGContext *s, TCGCond cond, TCGReg arg1, tcg_out_nop(s); } -static void tcg_out_movr(TCGContext *s, TCGCond cond, TCGReg ret, TCGReg c1, +static void tcg_out_movr(TCGContext *s, int rcond, TCGReg ret, TCGReg c1, int32_t v1, int v1const) { - tcg_out32(s, ARITH_MOVR | INSN_RD(ret) | INSN_RS1(c1) - | (tcg_cond_to_rcond[cond] << 10) + tcg_out32(s, ARITH_MOVR | INSN_RD(ret) | INSN_RS1(c1) | (rcond << 10) | (v1const ? INSN_IMM10(v1) : INSN_RS2(v1))); } @@ -710,9 +710,9 @@ static void tcg_out_movcond_i64(TCGContext *s, TCGCond cond, TCGReg ret, /* For 64-bit signed comparisons vs zero, we can avoid the compare. Note that the immediate range is one bit smaller, so we must check for that as well. */ - if (c2 == 0 && !is_unsigned_cond(cond) - && (!v1const || check_fit_i32(v1, 10))) { - tcg_out_movr(s, cond, ret, c1, v1, v1const); + int rcond = tcg_cond_to_rcond[cond]; + if (c2 == 0 && rcond && (!v1const || check_fit_i32(v1, 10))) { + tcg_out_movr(s, rcond, ret, c1, v1, v1const); } else { tcg_out_cmp(s, c1, c2, c2const); tcg_out_movcc(s, cond, MOVCC_XCC, ret, v1, v1const); @@ -787,6 +787,8 @@ static void tcg_out_setcond_i32(TCGContext *s, TCGCond cond, TCGReg ret, static void tcg_out_setcond_i64(TCGContext *s, TCGCond cond, TCGReg ret, TCGReg c1, int32_t c2, int c2const, bool neg) { + int rcond; + if (use_vis3_instructions && !neg) { switch (cond) { case TCG_COND_NE: @@ -806,9 +808,10 @@ static void tcg_out_setcond_i64(TCGContext *s, TCGCond cond, TCGReg ret, /* For 64-bit signed comparisons vs zero, we can avoid the compare if the input does not overlap the output. */ - if (c2 == 0 && !is_unsigned_cond(cond) && c1 != ret) { + rcond = tcg_cond_to_rcond[cond]; + if (c2 == 0 && rcond && c1 != ret) { tcg_out_movi_s13(s, ret, 0); - tcg_out_movr(s, cond, ret, c1, neg ? -1 : 1, 1); + tcg_out_movr(s, rcond, ret, c1, neg ? -1 : 1, 1); } else { tcg_out_cmp(s, c1, c2, c2const); tcg_out_movi_s13(s, ret, 0);