From patchwork Wed Oct 25 07:26:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 737832 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp149036wrq; Wed, 25 Oct 2023 00:28:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEa3FKT/yhjOeJSeNcSfTuiYL0V8cbkhs8VXH1wkY8Y418AGeod06IKE2RYCMzqsKVD14I2 X-Received: by 2002:adf:eb09:0:b0:324:8353:5247 with SMTP id s9-20020adfeb09000000b0032483535247mr11761492wrn.16.1698218918719; Wed, 25 Oct 2023 00:28:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698218918; cv=none; d=google.com; s=arc-20160816; b=WcFDIKCefzL8J6UlW4yYtA9KkDfaC5g8J5SSNICMWAwQJ7/xFsLC70LC7bbD7T0jat sZMrFSeC3hDdlXs4MThIEi2DUQYX6SFXumWEd4pJn3VqJpltylPO2Y70a1xjPZHXvxRJ J9GkaMWoKjtEmsuPLuFFWvsqEfvo4NDAvyuHWWud4u7LL+6u15YI9kgwk0msJJ7ON0Be XOEd8crrpflV/cxkhrfiKWfqwDqRu4cdc1WMwkAo+2fTbt5e5uNKPfU+kJiFi0x++9y0 tk9z6LHoMiN5wHGfoDWm1zgpIjlwipLfXy7T8RApju1FPwRXRo0JZsoSMqA/GhC+gBVl 7gWw== 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:cc:to :from:dkim-signature; bh=oTWlSTl88NPrS8w791ePjYqEfGwAj5/VqVJUyjszQKA=; fh=ycigHkwOPieh2u5PmcA89sNk/qPD1ZkdDlL8Mchfvw8=; b=sAvSy5mCKNwJHinVWWon8eeeHNEb+hy167QE+o0lTCQ2XP6OIT/DbWg1JLpeehMdUZ 62yqphxWpMRdmcP4+Dg+01Pbd+K/mq8lYm4fvCpabxwSOGMOxRRsxql9+/9WT/a6USaW +IjGYEI4Xi8eA2n769CPZLi/x8IU52Oh6BFjS/YwXHB6stj5B2+MYLqIIxto/9eTl0Cg gTqZtkJV0lR+7g2vVXH4oPHF/U0xlxd3h7umnfNNpiSOUPlj45hWW+oeY/t4CTwwNwxv ktP66vgqe6XaB3YI9u4ZBZTqpsEr+7ocRtXuGT/x0Ixr/NBzIrd/P/L0YjdZuA04f0IT i1VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lngfVlZ9; 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 s7-20020a5d4247000000b0032da31b9739si6997668wrr.516.2023.10.25.00.28.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2023 00:28:38 -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=lngfVlZ9; 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 1qvYIc-0000IE-QA; Wed, 25 Oct 2023 03:27:30 -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 1qvYIa-0000GW-Uv for qemu-devel@nongnu.org; Wed, 25 Oct 2023 03:27:29 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qvYIZ-0004hp-5u for qemu-devel@nongnu.org; Wed, 25 Oct 2023 03:27:28 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1cac925732fso36489585ad.1 for ; Wed, 25 Oct 2023 00:27:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698218845; x=1698823645; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oTWlSTl88NPrS8w791ePjYqEfGwAj5/VqVJUyjszQKA=; b=lngfVlZ9r/NOQh5S2NU/xFxoDyVG3UOucq3Q5fWFbPF+srZS+9MrP6wA4k4LGCJmSb nDu8Vqf7qTurg1folodFkCQhEkBuGhU/TOaA0B7/ruwpKJq4uDbfnjaE20QOgdR6bome I272jtpRVidhpRC1ykLs+T6jgoX3gc72thrZdaOwYCIyBj/P9cIVtup1IAUfmDO6tQd1 +/TfSI9mCrooD2/jcMSgtiNpjSjdVJoPMZT+ugUBjWshS1muuLXYin8874fG49mxzYb1 35k5G27srmrCd15YHedWSgbMLQhpCWA7kypPAzgToah0Yylf6/VLwbNZcKLijBw1EKyk Jvlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698218845; x=1698823645; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oTWlSTl88NPrS8w791ePjYqEfGwAj5/VqVJUyjszQKA=; b=Qg1Ku7QuuIym+ckk0OuB2rvLWnTylawslMN12Bu/PPDWLaKOhr/Y3Mb4hRui6aMmuO ZU5b38+PMjI1hUaG0rXPpnnNHoomeVq9wbgtND/JfCDenXtGVwCplkboP/L4lypDY9xj ppaQ62/h5kHn/MnTb/AfAB/G+10i09DJUwX1i3b7/76o50bCLEsCfqjiyvLXtjC4NYsL pPtpNZKev0/dtrQbu6BRsFVCpfYMiK+IaX/rjyBcFYhWQ3+lYo/qFOeEpM85I7murn2j 0U9jvwtxCxWN3nigfL0dGrtOia/7A61gk4pL8PbC3r6tX86TnVOr/sNdKbuLw5SRtkUN Db0g== X-Gm-Message-State: AOJu0YxL8TYEuaalwsDDKFH4jYWKTRNBo2ehbUD2ftUemMRFGky2mODS x2Erj2Ivmg/wyjA8yMq8G5CUWo/g4r0Mr92AS+4= X-Received: by 2002:a17:902:e851:b0:1c9:e3b1:1f4 with SMTP id t17-20020a170902e85100b001c9e3b101f4mr14985988plg.62.1698218845628; Wed, 25 Oct 2023 00:27:25 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id ji5-20020a170903324500b001b06c106844sm8578661plb.151.2023.10.25.00.27.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 00:27:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH 18/29] tcg/sparc64: Hoist read of tcg_cond_to_rcond Date: Wed, 25 Oct 2023 00:26:56 -0700 Message-Id: <20231025072707.833943-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231025072707.833943-1-richard.henderson@linaro.org> References: <20231025072707.833943-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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);