From patchwork Wed Jan 10 22:43:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761464 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2111990wrz; Wed, 10 Jan 2024 14:45:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IHs51A6h8ylbnfBmJfwGUWxFCbaOw/6rMbmeEsnAomUGw8EXhj7VJUcU8iyv3qxmivxBFFA X-Received: by 2002:a05:6214:2268:b0:680:b0df:19c4 with SMTP id gs8-20020a056214226800b00680b0df19c4mr223947qvb.6.1704926713464; Wed, 10 Jan 2024 14:45:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926713; cv=none; d=google.com; s=arc-20160816; b=hV4oxD0MTl7lWy0AweRBPLdfLyaCI+X0FkqeqreWqkrVdawI9I7Nwk21daSIuJ37K2 mGj7mnjff6c1xVbPchAJ/hhDiH2MgJHpOEfUrI3b/hN79RftluJsbBX1JYwdNQOgOOSk dtLdRGNj3MTnmqOWUk6sr2Q/DN3qdl1ql+P5ZjN5YZEKxcuVvF8YA6Sp0WrgThevzZm8 nrlLtImQotNAKgfD2R9dN27GkZ4SA3y38KjOw2SmomMsaOT0co+SJYb8nF1rwv0nUe0G Dx0kl0aKrLiV2BbOjE5FmQIW2qXeTVhjirE/0FPccPu5LQiMzZy69pfVxol4pjY37qid su5w== 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=Xe6YKO+UBE6YLyYsW2AZ/tSAY+8N62/s82QricPcuNc=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=HLjABp5v0NmRg6WNTL+0Y/1E0n+CExIwgBGj8ulJldOXq/XVmpBOxwFWdcTRVToyWK pHwxcVl86Ed9k0vSjbSJHcKqJca+SN4c9zYEFMTr/Xl6nPsuz9abJjvXYdEM0ULvD9+J ZQBqRR9A8FKO041fKjvQ0W4rf1QvA0aARLVSYRNB7//TzTXQ/yKOvv+HTNnu5FSmJW+o eqdfvnNgFaK23vx30TDEXMcGm76oZWRxknN/XD7Vg856iWRfsYauoHeE5yWu1Cpe3CDb cgeoAUNfcot6gU/KhQurYJo99Fuue7pSt923KcDfSrEFvIjagAy5EFYVttyyac1y3XZC WP8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wFJhcy9I; 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 g17-20020a0cdf11000000b006805f51071dsi5354375qvl.40.2024.01.10.14.45.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:45:13 -0800 (PST) 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=wFJhcy9I; 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 1rNhJM-0004RJ-O6; Wed, 10 Jan 2024 17:44:36 -0500 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 1rNhJL-0004Qp-8T for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:44:35 -0500 Received: from mail-qk1-x731.google.com ([2607:f8b0:4864:20::731]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhJJ-0002Ro-FU for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:44:35 -0500 Received: by mail-qk1-x731.google.com with SMTP id af79cd13be357-7831c604a84so284624885a.1 for ; Wed, 10 Jan 2024 14:44:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926672; x=1705531472; 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=Xe6YKO+UBE6YLyYsW2AZ/tSAY+8N62/s82QricPcuNc=; b=wFJhcy9I/yiGbYJltig/zkhFNvAYKPMl4+EW9g9vuEC3zi2fA/9MtFILdwVwcYI6Mu 01B45V1A627L2KCyznlwMB2AdAegNfJ3HniKVIyEg2Z4U3M3nSlG3ueaguwdx/9V+9Jj +yLK9pINAKrvzVVBitO6RAcm/fQlOIlnskFpR2/gJYGKi6A94EScLqvmZ2fwMQAQbShb +JikKFdckrO8P+3UD4GDBkuL6l6HymAqDZvN/xFV4JMeTniL8ulPwyWphyrNZqRQ6ZTq 1jAHqXejymK30z9w0uguy+o8sLcaji7cyU0Sb4nUyVt0rZjnVG4aGUMDepLLfG8w/mPf j3HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926672; x=1705531472; 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=Xe6YKO+UBE6YLyYsW2AZ/tSAY+8N62/s82QricPcuNc=; b=FKwzbgQIyLA2gxPQuc5PJHacMVW1aPvQDuqj1yRGMddNZvC82L7QoH3cC92kkEaRI5 4NkLllKC2hDtIZSe1OJZn3UPMO5rhS8DU1cjOXImDoMJJB56z4wLtofkrRDu1zL+8HGe Trioqqqyd6Snbyh7mR3PhDunKmNqVIvlPEPHxrA8InSvVM9YUr2Xx/REby9VC2sU6q4k RIxHkX3MiMaQaaqh8Jh8Kw17yQgDhxP5Ln5HmLfNCnRqDdQYvstZJitJO7scy4dBaM/2 WyTfGWJw1Q/0Qpz1nFDR23vF0m8GD61pSdZDRCwaRgPIT6KvXRlRbQkEIKtxEn9M5LXn 2RYg== X-Gm-Message-State: AOJu0YwpYUeWV5ZkkdmLNp+Jp1Uig8T0WQJRgqkJzVsXDFhU7GXeTDpS 1zU++Qqr+M5a3TlQJLTduYOTuS1LBm2c8Cs3zoYjRxIeIwAVy5UF X-Received: by 2002:a05:622a:15d6:b0:429:aac8:95d3 with SMTP id d22-20020a05622a15d600b00429aac895d3mr330462qty.45.1704926672212; Wed, 10 Jan 2024 14:44:32 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.44.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:44:31 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 01/38] tcg: Introduce TCG_COND_TST{EQ,NE} Date: Thu, 11 Jan 2024 09:43:31 +1100 Message-Id: <20240110224408.10444-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::731; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x731.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Add the enumerators, adjust the helpers to match, and dump. Not supported anywhere else just yet. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- docs/devel/tcg-ops.rst | 2 ++ include/tcg/tcg-cond.h | 74 ++++++++++++++++++++++++++++++------------ tcg/tcg.c | 4 ++- 3 files changed, 58 insertions(+), 22 deletions(-) diff --git a/docs/devel/tcg-ops.rst b/docs/devel/tcg-ops.rst index 8ae59ea02b..d46b625e0e 100644 --- a/docs/devel/tcg-ops.rst +++ b/docs/devel/tcg-ops.rst @@ -253,6 +253,8 @@ Jumps/Labels | ``TCG_COND_GEU /* unsigned */`` | ``TCG_COND_LEU /* unsigned */`` | ``TCG_COND_GTU /* unsigned */`` + | ``TCG_COND_TSTEQ /* t1 & t2 == 0 */`` + | ``TCG_COND_TSTNE /* t1 & t2 != 0 */`` Arithmetic ---------- diff --git a/include/tcg/tcg-cond.h b/include/tcg/tcg-cond.h index 2a38a386d4..5cadbd6ff2 100644 --- a/include/tcg/tcg-cond.h +++ b/include/tcg/tcg-cond.h @@ -29,26 +29,34 @@ * Conditions. Note that these are laid out for easy manipulation by * the functions below: * bit 0 is used for inverting; - * bit 1 is signed, - * bit 2 is unsigned, - * bit 3 is used with bit 0 for swapping signed/unsigned. + * bit 1 is used for conditions that need swapping (signed/unsigned). + * bit 2 is used with bit 1 for swapping. + * bit 3 is used for unsigned conditions. */ typedef enum { /* non-signed */ TCG_COND_NEVER = 0 | 0 | 0 | 0, TCG_COND_ALWAYS = 0 | 0 | 0 | 1, + + /* equality */ TCG_COND_EQ = 8 | 0 | 0 | 0, TCG_COND_NE = 8 | 0 | 0 | 1, + + /* "test" i.e. and then compare vs 0 */ + TCG_COND_TSTEQ = 8 | 4 | 0 | 0, + TCG_COND_TSTNE = 8 | 4 | 0 | 1, + /* signed */ TCG_COND_LT = 0 | 0 | 2 | 0, TCG_COND_GE = 0 | 0 | 2 | 1, - TCG_COND_LE = 8 | 0 | 2 | 0, - TCG_COND_GT = 8 | 0 | 2 | 1, + TCG_COND_GT = 0 | 4 | 2 | 0, + TCG_COND_LE = 0 | 4 | 2 | 1, + /* unsigned */ - TCG_COND_LTU = 0 | 4 | 0 | 0, - TCG_COND_GEU = 0 | 4 | 0 | 1, - TCG_COND_LEU = 8 | 4 | 0 | 0, - TCG_COND_GTU = 8 | 4 | 0 | 1, + TCG_COND_LTU = 8 | 0 | 2 | 0, + TCG_COND_GEU = 8 | 0 | 2 | 1, + TCG_COND_GTU = 8 | 4 | 2 | 0, + TCG_COND_LEU = 8 | 4 | 2 | 1, } TCGCond; /* Invert the sense of the comparison. */ @@ -60,25 +68,49 @@ static inline TCGCond tcg_invert_cond(TCGCond c) /* Swap the operands in a comparison. */ static inline TCGCond tcg_swap_cond(TCGCond c) { - return c & 6 ? (TCGCond)(c ^ 9) : c; + return (TCGCond)(c ^ ((c & 2) << 1)); } -/* Create an "unsigned" version of a "signed" comparison. */ -static inline TCGCond tcg_unsigned_cond(TCGCond c) +/* Must a comparison be considered signed? */ +static inline bool is_signed_cond(TCGCond c) { - return c & 2 ? (TCGCond)(c ^ 6) : c; -} - -/* Create a "signed" version of an "unsigned" comparison. */ -static inline TCGCond tcg_signed_cond(TCGCond c) -{ - return c & 4 ? (TCGCond)(c ^ 6) : c; + return (c & (8 | 2)) == 2; } /* Must a comparison be considered unsigned? */ static inline bool is_unsigned_cond(TCGCond c) { - return (c & 4) != 0; + return (c & (8 | 2)) == (8 | 2); +} + +/* Must a comparison be considered a test? */ +static inline bool is_tst_cond(TCGCond c) +{ + return (c | 1) == TCG_COND_TSTNE; +} + +/* Create an "unsigned" version of a "signed" comparison. */ +static inline TCGCond tcg_unsigned_cond(TCGCond c) +{ + return is_signed_cond(c) ? (TCGCond)(c + 8) : c; +} + +/* Create a "signed" version of an "unsigned" comparison. */ +static inline TCGCond tcg_signed_cond(TCGCond c) +{ + return is_unsigned_cond(c) ? (TCGCond)(c - 8) : c; +} + +/* Create the eq/ne version of a tsteq/tstne comparison. */ +static inline TCGCond tcg_tst_eqne_cond(TCGCond c) +{ + return is_tst_cond(c) ? (TCGCond)(c - 4) : c; +} + +/* Create the lt/ge version of a tstne/tsteq comparison of the sign. */ +static inline TCGCond tcg_tst_ltge_cond(TCGCond c) +{ + return is_tst_cond(c) ? (TCGCond)(c ^ 0xf) : c; } /* @@ -92,7 +124,7 @@ static inline TCGCond tcg_high_cond(TCGCond c) case TCG_COND_LE: case TCG_COND_GEU: case TCG_COND_LEU: - return (TCGCond)(c ^ 8); + return (TCGCond)(c ^ (4 | 1)); default: return c; } diff --git a/tcg/tcg.c b/tcg/tcg.c index e2c38f6d11..9d146b13aa 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2482,7 +2482,9 @@ static const char * const cond_name[] = [TCG_COND_LTU] = "ltu", [TCG_COND_GEU] = "geu", [TCG_COND_LEU] = "leu", - [TCG_COND_GTU] = "gtu" + [TCG_COND_GTU] = "gtu", + [TCG_COND_TSTEQ] = "tsteq", + [TCG_COND_TSTNE] = "tstne", }; static const char * const ldst_name[(MO_BSWAP | MO_SSIZE) + 1] = From patchwork Wed Jan 10 22:43:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761479 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2112693wrz; Wed, 10 Jan 2024 14:47:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IECWfvEm/moPLX1sJFf/kTlOTH1/6WNBtt4inC+8S6/xug4Y7bUh2NnEe6HiOydk1MeUlMz X-Received: by 2002:a05:6214:3290:b0:680:ff9c:8f1 with SMTP id mu16-20020a056214329000b00680ff9c08f1mr231085qvb.70.1704926851036; Wed, 10 Jan 2024 14:47:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926851; cv=none; d=google.com; s=arc-20160816; b=Q5xF3Y8QkWK1lYSqrvLWG7okwu0TCkuVP3YlyhHjeE4zbtpJ9A2/UwPOaflBq0uSba zfiNBNIvOBSyr8bPfMeFLucpbEQYCvmlUtBl6wQXrgTGSe3Yp4c49W8BedR353s+YMxe MwKj09VxC4h3vIH451NLghHsq+y6Gh/rjHSiOmeanBmyLMhhpDdSrzPzWUqo72zETBbS yJ9XUfxgavRfJwVmnmF4N+HkYt7NitSfFh5RMsouRsb/kyyAXKGdp2QA+cdkNxa/PfmO tFYa6dSHomHSZ8Bty/Sg791zEVOxMyzxU3TY4YWarA0yaADmZbhiWXCbOs+s7MJ/Nomr LSKQ== 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=XHALRgn6+R7mnoPisAPyxnrzriWZt0G/V66nE0399oE=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=uvIWlwZtRMDLwQIPZ88yDaPdYpCnHb33yN3PXzAaZjELeoTWMOeKyVGa90sUE0LpbV XMWM6VrGaLW2qK+Oif307mLE8LSZUkpGwBieTZLPOHRrmEaloaOnosvZvDrv2TtUHRJ1 K52i2yh7rJIKZ97FzZN6umhVAyBEYOwEhd5dCt4/vB1UXMr900bFmrC1J3/iz4dnXOY9 iiyDLd0S2UsptfMZXe3OHhmxPkpjTnEjI79vCEGmR2+y5WNdDzf/9rxfzYTUhcxQH8Xv 1fPdpLnHzOAhnRs06oavBWp9IZSapkvKpwEKKLVxfEXesCrsfnlQyaKrKAb4w8ifqac7 FQZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BlwGvnoN; 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 o6-20020a0ccb06000000b0067f7a01e3a1si5242195qvk.600.2024.01.10.14.47.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:47:31 -0800 (PST) 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=BlwGvnoN; 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 1rNhJR-0004S1-85; Wed, 10 Jan 2024 17:44:41 -0500 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 1rNhJP-0004Rn-K5 for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:44:39 -0500 Received: from mail-qt1-x82c.google.com ([2607:f8b0:4864:20::82c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhJN-0002V3-PL for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:44:39 -0500 Received: by mail-qt1-x82c.google.com with SMTP id d75a77b69052e-429c00bf0efso733781cf.1 for ; Wed, 10 Jan 2024 14:44:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926676; x=1705531476; 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=XHALRgn6+R7mnoPisAPyxnrzriWZt0G/V66nE0399oE=; b=BlwGvnoNSNq7Ud7H9aO2FbiPhE3viZ1+CdtNj3/3i49OogrWH9BH9sPlRXaFr2+Rr+ DezhlBHXH3EYYXHL0IKwCmhRVpIV7cBJiPKLiffdaFRe3E1jcttbn5GYcClyXNU89Eaf TNXmHumbXgAt7QUaYItNRf3vfV29FCscCEFW/d7E/KUvtmB9Cv5kpoxeTcpnKaWHAY/I EAn2vSSX/Zo9oqTvbyQjgpiDHFvaNEaPbRpEMvy1vhx1lUenalBkCnXA/SjgDPi8zYHh vF4HMzH7FgxEAqi2w2LBqouYXr4MHZcw2aTMjnIRzXqa3L5MnDslZPA2U3nfuVww4AwK AzUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926676; x=1705531476; 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=XHALRgn6+R7mnoPisAPyxnrzriWZt0G/V66nE0399oE=; b=Ilpz/ZgqCb/xdFw2mhnxr7RokofsoC66KLfjsoZYOzLOUK4mm+DIQNmGkz5DbDB4/u 5QOmGL98hGH8Rf7SR63cYV/TigF0tQmI+Qu9E4ldqLVw/Yh6ElHUtHOyygKjmjNpSK++ 5cgudcXctaGyZFSL4hTS0TKCZ/wTLaq2ripXaCzXeovQqdcQcXpuMoNCAYXyErKHaEZO CQmDKrCWXvjKgx88MHEGxTsj0iqm+8Ngg8apS9pzYixeVcSrClnma7K71m2fz7cylnk8 9sZ/4/QbJLt83YUMDnzk6zOjfmWhLJ+hvI011KK5zARyGjhjUKyGeDhuUTWPXjPIydyZ 0jjw== X-Gm-Message-State: AOJu0YzBDo7VB7UU7YVSl0WDhXB+gj2prM24lXXZgaCtERcSyclBeM6M 5jid02v4PDx33Zdzy6akHbHqj4w+PUXh8jU78jrh4n49rcZdqej1 X-Received: by 2002:a05:622a:1a90:b0:429:b349:65a7 with SMTP id s16-20020a05622a1a9000b00429b34965a7mr396023qtc.8.1704926676671; Wed, 10 Jan 2024 14:44:36 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.44.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:44:36 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 02/38] tcg: Introduce TCG_TARGET_HAS_tst Date: Thu, 11 Jan 2024 09:43:32 +1100 Message-Id: <20240110224408.10444-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82c; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82c.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Define as 0 for all tcg backends. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tcg/aarch64/tcg-target.h | 2 ++ tcg/arm/tcg-target.h | 2 ++ tcg/i386/tcg-target.h | 2 ++ tcg/loongarch64/tcg-target.h | 2 ++ tcg/mips/tcg-target.h | 2 ++ tcg/ppc/tcg-target.h | 2 ++ tcg/riscv/tcg-target.h | 2 ++ tcg/s390x/tcg-target.h | 2 ++ tcg/sparc64/tcg-target.h | 2 ++ tcg/tci/tcg-target.h | 2 ++ 10 files changed, 20 insertions(+) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index 33f15a564a..b4ac13be7b 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -138,6 +138,8 @@ typedef enum { #define TCG_TARGET_HAS_qemu_ldst_i128 1 #endif +#define TCG_TARGET_HAS_tst 0 + #define TCG_TARGET_HAS_v64 1 #define TCG_TARGET_HAS_v128 1 #define TCG_TARGET_HAS_v256 0 diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index a712cc80ad..7bf42045a7 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -125,6 +125,8 @@ extern bool use_neon_instructions; #define TCG_TARGET_HAS_qemu_ldst_i128 0 +#define TCG_TARGET_HAS_tst 0 + #define TCG_TARGET_HAS_v64 use_neon_instructions #define TCG_TARGET_HAS_v128 use_neon_instructions #define TCG_TARGET_HAS_v256 0 diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index fa34deec47..1dd917a680 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -198,6 +198,8 @@ typedef enum { #define TCG_TARGET_HAS_qemu_ldst_i128 \ (TCG_TARGET_REG_BITS == 64 && (cpuinfo & CPUINFO_ATOMIC_VMOVDQA)) +#define TCG_TARGET_HAS_tst 0 + /* We do not support older SSE systems, only beginning with AVX1. */ #define TCG_TARGET_HAS_v64 have_avx1 #define TCG_TARGET_HAS_v128 have_avx1 diff --git a/tcg/loongarch64/tcg-target.h b/tcg/loongarch64/tcg-target.h index 9c70ebfefc..fede627bf7 100644 --- a/tcg/loongarch64/tcg-target.h +++ b/tcg/loongarch64/tcg-target.h @@ -169,6 +169,8 @@ typedef enum { #define TCG_TARGET_HAS_qemu_ldst_i128 (cpuinfo & CPUINFO_LSX) +#define TCG_TARGET_HAS_tst 0 + #define TCG_TARGET_HAS_v64 0 #define TCG_TARGET_HAS_v128 (cpuinfo & CPUINFO_LSX) #define TCG_TARGET_HAS_v256 0 diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index b98ffae1d0..a996aa171d 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -194,6 +194,8 @@ extern bool use_mips32r2_instructions; #define TCG_TARGET_HAS_qemu_ldst_i128 0 +#define TCG_TARGET_HAS_tst 0 + #define TCG_TARGET_DEFAULT_MO 0 #define TCG_TARGET_NEED_LDST_LABELS #define TCG_TARGET_NEED_POOL_LABELS diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index 5295e4f9ab..60ce49e672 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -143,6 +143,8 @@ typedef enum { #define TCG_TARGET_HAS_qemu_ldst_i128 \ (TCG_TARGET_REG_BITS == 64 && have_isa_2_07) +#define TCG_TARGET_HAS_tst 0 + /* * While technically Altivec could support V64, it has no 64-bit store * instruction and substituting two 32-bit stores makes the generated diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index a4edc3dc74..2c1b680b93 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -158,6 +158,8 @@ extern bool have_zbb; #define TCG_TARGET_HAS_qemu_ldst_i128 0 +#define TCG_TARGET_HAS_tst 0 + #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_NEED_LDST_LABELS diff --git a/tcg/s390x/tcg-target.h b/tcg/s390x/tcg-target.h index e69b0d2ddd..53bed8c8d2 100644 --- a/tcg/s390x/tcg-target.h +++ b/tcg/s390x/tcg-target.h @@ -138,6 +138,8 @@ extern uint64_t s390_facilities[3]; #define TCG_TARGET_HAS_qemu_ldst_i128 1 +#define TCG_TARGET_HAS_tst 0 + #define TCG_TARGET_HAS_v64 HAVE_FACILITY(VECTOR) #define TCG_TARGET_HAS_v128 HAVE_FACILITY(VECTOR) #define TCG_TARGET_HAS_v256 0 diff --git a/tcg/sparc64/tcg-target.h b/tcg/sparc64/tcg-target.h index f8cf145266..ae2910c4ee 100644 --- a/tcg/sparc64/tcg-target.h +++ b/tcg/sparc64/tcg-target.h @@ -149,6 +149,8 @@ extern bool use_vis3_instructions; #define TCG_TARGET_HAS_qemu_ldst_i128 0 +#define TCG_TARGET_HAS_tst 0 + #define TCG_AREG0 TCG_REG_I0 #define TCG_TARGET_DEFAULT_MO (0) diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index 2a13816c8e..609b2f4e4a 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -117,6 +117,8 @@ #define TCG_TARGET_HAS_qemu_ldst_i128 0 +#define TCG_TARGET_HAS_tst 0 + /* Number of registers available. */ #define TCG_TARGET_NB_REGS 16 From patchwork Wed Jan 10 22:43:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761467 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2112114wrz; Wed, 10 Jan 2024 14:45:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IGv6VyQG4xKdUyFbgBqGV+JQ03YSxQ8/OX1K8PdVioPXx1e2vVmixB9ue5I371ApOv+cd0q X-Received: by 2002:a05:6214:3290:b0:67f:89da:aa8c with SMTP id mu16-20020a056214329000b0067f89daaa8cmr247439qvb.115.1704926737221; Wed, 10 Jan 2024 14:45:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926737; cv=none; d=google.com; s=arc-20160816; b=tItmGACihoSpF+5XTLYZmn6cb9VYoKBoy/lEmPBhPJDv7/IU/ZQYlHuV0LAXBUt79m OBmRgeTtzbJditZBXXgdH8OSlz+6+WLEkXdb+ZrjYTd73QU/WBAtI5Ck/VgaOXnvUZbl 8EoXvHrnUtY3BYdoQBRoYPi/PhLXi4E1zC28I54PZ7H4OP4fhkPqUwLnORtigsCAzWnC Hzqiv/be3AgWPon17R58PaJYYNZg34sAx4VKYRzbOYHuxJeWhOjDKwi6BvoXppdnmoU3 zpMICAG3WkqEcn11bpcKilsVacSxTeqhgKCjOx9eadilh3kZbcgDv6/yOQ74HO96eW7n b5Xg== 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=XRwgTLH7x4qjGJwvWHPC6iD3rpKsmYUOnQgcGsFZM2o=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=NudPGvZe/PlX26b7CVxhA75r6A1awPhcVCMHFIzUETf+AsZD7gW5nen3fJZvbRakXy vxCx5qTwyWk5cGHsY0UJj0lG1roQfCf5FLXa8sXZrKXc0BPHvlIfvlNB9MNJA8m+Zjmj E9v3exCAeRo5hsILoh/4h7fvQ0sj5Tur8WfkvddCYJGysHMDYQf4V8fGPDcuytwbQ68e Z5eg/ixKWFWY1448l3RrOb15spFYMdCTaDkEso6DHY7E3Uw56BvQQMG9+ydIi0DRIKwe IGLEKa/nul/QPegydnSlqtrh1gWwFNZekOey8NBCfD68+np01yLvSw0KN1nIUO0g1XKR flOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="kr4/GM78"; 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 r3-20020a0cc403000000b0067f9f28533asi5255184qvi.505.2024.01.10.14.45.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:45:37 -0800 (PST) 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="kr4/GM78"; 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 1rNhJZ-0004TA-Dp; Wed, 10 Jan 2024 17:44:49 -0500 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 1rNhJX-0004Sl-Hg for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:44:47 -0500 Received: from mail-yb1-xb29.google.com ([2607:f8b0:4864:20::b29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhJV-0002b6-RC for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:44:47 -0500 Received: by mail-yb1-xb29.google.com with SMTP id 3f1490d57ef6-dbeff3fefc7so3602925276.2 for ; Wed, 10 Jan 2024 14:44:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926684; x=1705531484; 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=XRwgTLH7x4qjGJwvWHPC6iD3rpKsmYUOnQgcGsFZM2o=; b=kr4/GM78hmqsgk48gQ8MzhpqQd0HbrncDA1RLMxF6yZ0grrlilzjLfq7BvYfJ5xin0 0ICQXkgVG+zAbty4F+69XK5tkTSb30lyqbsDuB+lSi4rfpjEhZNTVIP9qjiBocWwCPBT JdWWtO7voEVDMj9q3jSgpyh0wBczBzy0LitICM2dmdet1h/Gh/vKQdjlJ5PCohSvvGUg ud/zyZAq2koAs2HEcvl8T3pkWz/+YVPhqc1DtaTVYj6xeQC4jtNDqHrOkUSU8hhzqxax vaCttB3VU4V4XktWLth1hE6Op2yjdYh6ZZ0NgofFVTSIc+XubBXCh9m3R6FYwivPIayM L3Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926684; x=1705531484; 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=XRwgTLH7x4qjGJwvWHPC6iD3rpKsmYUOnQgcGsFZM2o=; b=eZp/O1hdRrFJDyBbueCfk8AeeRB5p8QyI8IiQaHeylziLLBkMRH1iw1H+sDkFRrU+l 2t5YauJOglKrteu6sRiJhiltzI+EjdEbsSnUHv8raQHkPElCdMKJAGnXStDStnQ2XqoI 4u5XAu48l0ph2JZphEGqLrwL9rgzZQrYZZNM1EFyzLOzJoDBeJ5X+wXYa1vQ0Sp0yRxe lC9PCYZLkyCv8dNQycbph472UN1bEjhNolW2qJZJbaulXB7aIiB2kz9+1my83h/bqyYZ gFlyq67pxD6OwGNmLMWTLV8FVKhVg2podso8hqOnYHFlDNHwcQdrUm4X0BRI+9I79qCU xk+A== X-Gm-Message-State: AOJu0Yz92f/dAJFnel//vcJU0DgwYo7K4V6zLerd2Y7/yWsletxQJITg XLrkiWCEOG3ySI+pVTrT5zjKi4JXNuQEGoBYePM5s4waPC9IWic0 X-Received: by 2002:a25:9389:0:b0:db9:6ad7:1abb with SMTP id a9-20020a259389000000b00db96ad71abbmr355921ybm.12.1704926684684; Wed, 10 Jan 2024 14:44:44 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.44.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:44:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 03/38] tcg/optimize: Split out arg_is_const_val Date: Thu, 11 Jan 2024 09:43:33 +1100 Message-Id: <20240110224408.10444-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::b29; envelope-from=richard.henderson@linaro.org; helo=mail-yb1-xb29.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/optimize.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index f2d01654c5..73019b9996 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -124,11 +124,22 @@ static inline bool ts_is_const(TCGTemp *ts) return ts_info(ts)->is_const; } +static inline bool ts_is_const_val(TCGTemp *ts, uint64_t val) +{ + TempOptInfo *ti = ts_info(ts); + return ti->is_const && ti->val == val; +} + static inline bool arg_is_const(TCGArg arg) { return ts_is_const(arg_temp(arg)); } +static inline bool arg_is_const_val(TCGArg arg, uint64_t val) +{ + return ts_is_const_val(arg_temp(arg), val); +} + static inline bool ts_is_copy(TCGTemp *ts) { return ts_info(ts)->next_copy != ts; @@ -689,7 +700,7 @@ static int do_constant_folding_cond(TCGType type, TCGArg x, } } else if (args_are_copies(x, y)) { return do_constant_folding_cond_eq(c); - } else if (arg_is_const(y) && arg_info(y)->val == 0) { + } else if (arg_is_const_val(y, 0)) { switch (c) { case TCG_COND_LTU: return 0; @@ -954,7 +965,7 @@ static bool fold_to_not(OptContext *ctx, TCGOp *op, int idx) /* If the binary operation has first argument @i, fold to @i. */ static bool fold_ix_to_i(OptContext *ctx, TCGOp *op, uint64_t i) { - if (arg_is_const(op->args[1]) && arg_info(op->args[1])->val == i) { + if (arg_is_const_val(op->args[1], i)) { return tcg_opt_gen_movi(ctx, op, op->args[0], i); } return false; @@ -963,7 +974,7 @@ static bool fold_ix_to_i(OptContext *ctx, TCGOp *op, uint64_t i) /* If the binary operation has first argument @i, fold to NOT. */ static bool fold_ix_to_not(OptContext *ctx, TCGOp *op, uint64_t i) { - if (arg_is_const(op->args[1]) && arg_info(op->args[1])->val == i) { + if (arg_is_const_val(op->args[1], i)) { return fold_to_not(ctx, op, 2); } return false; @@ -972,7 +983,7 @@ static bool fold_ix_to_not(OptContext *ctx, TCGOp *op, uint64_t i) /* If the binary operation has second argument @i, fold to @i. */ static bool fold_xi_to_i(OptContext *ctx, TCGOp *op, uint64_t i) { - if (arg_is_const(op->args[2]) && arg_info(op->args[2])->val == i) { + if (arg_is_const_val(op->args[2], i)) { return tcg_opt_gen_movi(ctx, op, op->args[0], i); } return false; @@ -981,7 +992,7 @@ static bool fold_xi_to_i(OptContext *ctx, TCGOp *op, uint64_t i) /* If the binary operation has second argument @i, fold to identity. */ static bool fold_xi_to_x(OptContext *ctx, TCGOp *op, uint64_t i) { - if (arg_is_const(op->args[2]) && arg_info(op->args[2])->val == i) { + if (arg_is_const_val(op->args[2], i)) { return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[1]); } return false; @@ -990,7 +1001,7 @@ static bool fold_xi_to_x(OptContext *ctx, TCGOp *op, uint64_t i) /* If the binary operation has second argument @i, fold to NOT. */ static bool fold_xi_to_not(OptContext *ctx, TCGOp *op, uint64_t i) { - if (arg_is_const(op->args[2]) && arg_info(op->args[2])->val == i) { + if (arg_is_const_val(op->args[2], i)) { return fold_to_not(ctx, op, 1); } return false; @@ -1223,8 +1234,8 @@ static bool fold_brcond2(OptContext *ctx, TCGOp *op) * Simplify LT/GE comparisons vs zero to a single compare * vs the high word of the input. */ - if (arg_is_const(op->args[2]) && arg_info(op->args[2])->val == 0 && - arg_is_const(op->args[3]) && arg_info(op->args[3])->val == 0) { + if (arg_is_const_val(op->args[2], 0) && + arg_is_const_val(op->args[3], 0)) { goto do_brcond_high; } break; @@ -1448,9 +1459,7 @@ static bool fold_deposit(OptContext *ctx, TCGOp *op) } /* Inserting a value into zero at offset 0. */ - if (arg_is_const(op->args[1]) - && arg_info(op->args[1])->val == 0 - && op->args[3] == 0) { + if (arg_is_const_val(op->args[1], 0) && op->args[3] == 0) { uint64_t mask = MAKE_64BIT_MASK(0, op->args[4]); op->opc = and_opc; @@ -1461,8 +1470,7 @@ static bool fold_deposit(OptContext *ctx, TCGOp *op) } /* Inserting zero into a value. */ - if (arg_is_const(op->args[2]) - && arg_info(op->args[2])->val == 0) { + if (arg_is_const_val(op->args[2], 0)) { uint64_t mask = deposit64(-1, op->args[3], op->args[4], 0); op->opc = and_opc; @@ -2000,8 +2008,8 @@ static bool fold_setcond2(OptContext *ctx, TCGOp *op) * Simplify LT/GE comparisons vs zero to a single compare * vs the high word of the input. */ - if (arg_is_const(op->args[3]) && arg_info(op->args[3])->val == 0 && - arg_is_const(op->args[4]) && arg_info(op->args[4])->val == 0) { + if (arg_is_const_val(op->args[3], 0) && + arg_is_const_val(op->args[4], 0)) { goto do_setcond_high; } break; From patchwork Wed Jan 10 22:43:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761466 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2112074wrz; Wed, 10 Jan 2024 14:45:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IGLMH3DiqcKIGFPS/zI1X2W4CgHN1NmvIOYXBnFKwHocikyvq+z8+ge7+PbIFPt3Fx4c74c X-Received: by 2002:a05:622a:2c7:b0:429:96e2:876b with SMTP id a7-20020a05622a02c700b0042996e2876bmr234244qtx.65.1704926731516; Wed, 10 Jan 2024 14:45:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926731; cv=none; d=google.com; s=arc-20160816; b=Vqlf5RmgiCFurRHKBJu5fJgBKXYQzOqGhAfMLDFfU2tYN5utFQrKj1NNVaacy/zng3 kTCf+Org56EXnNq2TE6IGgrxT+wTQbcgeytAoD+iU8WdeF6+jMhewjEmf8NG12Hf6fLr ko18yuz85cbMBfqITRL2i6u/UjYEvFcuyS5zlPfbrYJ6wJdJCZgzUvn2Uu4G+N3jLFhK tXrDdYSpwtEuVPfW4CT79CgpxUr9JmIVnfqlB2HZgephvJYxeRfJMgaqww5bag2jJGA3 wq7AwWxusyIyc9sDDWHwERlZ4cKOEC7wM3AWC09brKGyC9enrdY+qdIBfHNruC1BQaUR UyWg== 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=rCOb1ACImxEyjzPr7SpomivAS+ARwGZqu81A17yuvPw=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=QKiOiDchhMk/w79Ss37LFkqv4gSBQilVpELQcyTnqFKusot4ww1SVsm4b6yhd2KC2K KX17yNJu8uDBxip6bg8MAqYLcRKopl+HXOQZpssmyjHPh5TiHU3jFhRBS92ztWPm2hmy HflUbxxir5hRGGsLxvNpU8Z1G7K3CAk9Zzqw9dCpUUfilkl94U2+7PO5+9ElBtfMos0a 4XfmHpmBzOypjuQB9Io54PP6mWfzajvVFoVOej2KlCDkq0vgSWzkw+YAzz+mbKgOjZYm EWhWv7UXPPR9uo3wUwRPKI1gQfN+jo90SpFHoJRdi97mi6TN62lB3QBrbjb8UGBu9Spb kd2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="UM/cDNJi"; 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 fv26-20020a05622a4a1a00b00429899fdb2esi5491873qtb.639.2024.01.10.14.45.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:45:31 -0800 (PST) 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="UM/cDNJi"; 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 1rNhJg-0004VT-Ql; Wed, 10 Jan 2024 17:44:56 -0500 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 1rNhJf-0004Ul-05 for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:44:55 -0500 Received: from mail-qt1-x830.google.com ([2607:f8b0:4864:20::830]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhJd-0002ei-78 for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:44:54 -0500 Received: by mail-qt1-x830.google.com with SMTP id d75a77b69052e-429be9fe952so2179131cf.0 for ; Wed, 10 Jan 2024 14:44:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926692; x=1705531492; 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=rCOb1ACImxEyjzPr7SpomivAS+ARwGZqu81A17yuvPw=; b=UM/cDNJiEpfgOuVsnNsDgYmJ5ffqf8VV23QtN0eyI7Q9k5MLlneuOJYFOIK5eQePlV nYvD6qCzdRObrOrJmNFKHJy58LgLyK+pChao6Xo329TZWbBVFVJQGN71iNcWupwcTguW NOhZnmYLI0Ru5qC5loSFwk0IaYFSMeW9LsnWlW8flV7JA3DAVzn2XDMuDd0fvT0T8UvJ knhGPTjpMgptRXmg7j0AGrIutb5BXYTLV4mcQMKeZ9e3O5FEjZoRgk7VntwQ/4RaNgHS E6t9TDfG70FtLpWz7Xb9L0Z6Ly+kPXMB+DRe2kDWzQxNWXZOmeZ6MbNs/Y3muzXQtPKc +iTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926692; x=1705531492; 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=rCOb1ACImxEyjzPr7SpomivAS+ARwGZqu81A17yuvPw=; b=ttcSKeW2cvpAxAuqlAEbXAae2CUeXT01gVMGmkvDxdPUTvsKbBj/lbtTq+/dSAPXrN mQPz83qJ+CYaL7LQDdcS0lrgrqFCjZEqFqN/6JKEH/XYpr9JtxzPXzALalvL8LtWGo9X 0mgxlNguydRBN0/NrMYWGm3vNlhGQFXcQC4lGC8QGpIIlYkr69Si5/EFt/s2k1UKlOkH gT5QzNwPyaFW5uaszmGSukRafTGkknBi4Yphchma3ER60CSsjRnAYzmqiFUj9Iie4RO5 /2IvBkAL2hy3OR5R2IfQeZOHN3BzVSDSTcPcy2q/FgzYn4SfacSDiOTZg0dJrsArdWtM Aq6w== X-Gm-Message-State: AOJu0YwROVaxcfascXCZzwGHaVTK7nO636ytpK7a30VKs+MZ6uCIKg2L HglKUcvPbVCKXSSXvJmRDMZCHit3RE4+F/1ZKTqDOC7F8HmX5u1b X-Received: by 2002:ac8:5941:0:b0:429:9341:ddf2 with SMTP id 1-20020ac85941000000b004299341ddf2mr1373680qtz.29.1704926692155; Wed, 10 Jan 2024 14:44:52 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.44.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:44:51 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 04/38] tcg/optimize: Split out do_constant_folding_cond1 Date: Thu, 11 Jan 2024 09:43:34 +1100 Message-Id: <20240110224408.10444-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::830; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x830.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Handle modifications to the arguments and condition in a single place. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/optimize.c | 57 ++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 73019b9996..9c04dba099 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -796,6 +796,23 @@ static bool swap_commutative2(TCGArg *p1, TCGArg *p2) return false; } +static int do_constant_folding_cond1(OptContext *ctx, TCGArg dest, + TCGArg *p1, TCGArg *p2, TCGArg *pcond) +{ + TCGCond cond; + bool swap; + int r; + + swap = swap_commutative(dest, p1, p2); + cond = *pcond; + if (swap) { + *pcond = cond = tcg_swap_cond(cond); + } + + r = do_constant_folding_cond(ctx->type, *p1, *p2, cond); + return r; +} + static void init_arguments(OptContext *ctx, TCGOp *op, int nb_args) { for (int i = 0; i < nb_args; i++) { @@ -1193,14 +1210,8 @@ static bool fold_andc(OptContext *ctx, TCGOp *op) static bool fold_brcond(OptContext *ctx, TCGOp *op) { - TCGCond cond = op->args[2]; - int i; - - if (swap_commutative(NO_DEST, &op->args[0], &op->args[1])) { - op->args[2] = cond = tcg_swap_cond(cond); - } - - i = do_constant_folding_cond(ctx->type, op->args[0], op->args[1], cond); + int i = do_constant_folding_cond1(ctx, NO_DEST, &op->args[0], + &op->args[1], &op->args[2]); if (i == 0) { tcg_op_remove(ctx->tcg, op); return true; @@ -1695,21 +1706,18 @@ static bool fold_mov(OptContext *ctx, TCGOp *op) static bool fold_movcond(OptContext *ctx, TCGOp *op) { - TCGCond cond = op->args[5]; int i; - if (swap_commutative(NO_DEST, &op->args[1], &op->args[2])) { - op->args[5] = cond = tcg_swap_cond(cond); - } /* * Canonicalize the "false" input reg to match the destination reg so * that the tcg backend can implement a "move if true" operation. */ if (swap_commutative(op->args[0], &op->args[4], &op->args[3])) { - op->args[5] = cond = tcg_invert_cond(cond); + op->args[5] = tcg_invert_cond(op->args[5]); } - i = do_constant_folding_cond(ctx->type, op->args[1], op->args[2], cond); + i = do_constant_folding_cond1(ctx, NO_DEST, &op->args[1], + &op->args[2], &op->args[5]); if (i >= 0) { return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[4 - i]); } @@ -1723,6 +1731,7 @@ static bool fold_movcond(OptContext *ctx, TCGOp *op) uint64_t tv = arg_info(op->args[3])->val; uint64_t fv = arg_info(op->args[4])->val; TCGOpcode opc, negopc = 0; + TCGCond cond = op->args[5]; switch (ctx->type) { case TCG_TYPE_I32: @@ -1950,14 +1959,8 @@ static bool fold_remainder(OptContext *ctx, TCGOp *op) static bool fold_setcond(OptContext *ctx, TCGOp *op) { - TCGCond cond = op->args[3]; - int i; - - if (swap_commutative(op->args[0], &op->args[1], &op->args[2])) { - op->args[3] = cond = tcg_swap_cond(cond); - } - - i = do_constant_folding_cond(ctx->type, op->args[1], op->args[2], cond); + int i = do_constant_folding_cond1(ctx, op->args[0], &op->args[1], + &op->args[2], &op->args[3]); if (i >= 0) { return tcg_opt_gen_movi(ctx, op, op->args[0], i); } @@ -1969,14 +1972,8 @@ static bool fold_setcond(OptContext *ctx, TCGOp *op) static bool fold_negsetcond(OptContext *ctx, TCGOp *op) { - TCGCond cond = op->args[3]; - int i; - - if (swap_commutative(op->args[0], &op->args[1], &op->args[2])) { - op->args[3] = cond = tcg_swap_cond(cond); - } - - i = do_constant_folding_cond(ctx->type, op->args[1], op->args[2], cond); + int i = do_constant_folding_cond1(ctx, op->args[0], &op->args[1], + &op->args[2], &op->args[3]); if (i >= 0) { return tcg_opt_gen_movi(ctx, op, op->args[0], -i); } From patchwork Wed Jan 10 22:43:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761472 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2112459wrz; Wed, 10 Jan 2024 14:46:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IH81ClILCDXSgvNKFQxuOs/0OljwpfRe+3rgczxVuVYzJ16h0QByVkHGZG2GAQjc8f0frGR X-Received: by 2002:a05:6214:1242:b0:680:9c2a:6ecd with SMTP id r2-20020a056214124200b006809c2a6ecdmr206871qvv.99.1704926799032; Wed, 10 Jan 2024 14:46:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926799; cv=none; d=google.com; s=arc-20160816; b=o+WjDLSNyb/5xo9+u4n8z53uPuDq61hlXak58Kmbppb8lDRG1mjZlbtoTovP3ti7SI xYrdBay3X+kzUQ73x7oDVQJJSzal80G0r8mj2dT/9wFlrSl1f/l+587HcW1T524GiTFx qJsuNFuS20oSD1bduANbI8g0qMEo5UnYcgYus+yt+wcnJvwSEI7SO8hKo4MvwWy417Ui S41OFJiBcVlKCKedhZdAfyoptYwctrUx4JOrQ16JHMzYaFhyrxohZ65TG/Tw8vrvugz2 LebuMcco1Ab7285yyUbcHP4/VKfBxmAPcabSdeOcIsn7wV/2dJYhXxvjZ4zkqnt6+hrR ygNw== 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=VRgNiPJydpvDmMhlC8JjCGm8KjRyw9Ww/5hSgKncWeA=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=hXvMiBxNBH3Ae5enUz0AQOltpMVIVo/zUWHnMaqqt1U5Wiz9AR0vgWhBlKwa/I6KAq vpJzWCB+SGCYegC0AE/KDJGiz7uHMCbJFOavlIR/dhjt51Sm5Ec/ZoKnKrRvOdPqHnaH KJGfn28nVr5RkEHH3IDLxQcz4f6lXx5fBzPFALEiBVYM+YcAasTiTJLjAFDpAd4gcLO8 CjIP3KHZmuU05dydmL6HeSgOp6YFVGmbDIhKk+8PjDKXU7j2iI0V5eWnPPgaRFKUuiK3 YeKbhCtX7qz24PK5gFRFuXwL7j+8i7n83saWGl1dHlvQuMUH9pRnFEI+ZSlhNuorwXqL q10Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MorRs4Tg; 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 r15-20020a0ccc0f000000b0067f9b7e5f33si5218293qvk.344.2024.01.10.14.46.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:46:39 -0800 (PST) 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=MorRs4Tg; 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 1rNhJp-0004WW-1t; Wed, 10 Jan 2024 17:45:05 -0500 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 1rNhJn-0004WJ-S1 for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:03 -0500 Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhJl-0002hk-Uq for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:03 -0500 Received: by mail-oi1-x22a.google.com with SMTP id 5614622812f47-3bbd6e377ceso3851519b6e.1 for ; Wed, 10 Jan 2024 14:45:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926700; x=1705531500; 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=VRgNiPJydpvDmMhlC8JjCGm8KjRyw9Ww/5hSgKncWeA=; b=MorRs4Tgdi/pbbxWQu9IMoL6Sl/iI3Z1rJqLDRWD1wY2hU7zL9rqlLCoHP2GSvgx0z gdFamU4WWMvuyJjF+80/t9CxqQoiLVJMSb7EBkWnJDBbXKU3AvyoPYHrg8dxotXBGNxJ nU2lZdK3N9/VqV00uATv9Hb67sRc7a1ilDhv7RM3SYaeIwBFmDLj+d6lCBMtPoc+RqdX MEMvSkba2xLPLjZVMeHPMTon+MA+eDrm66N1Z8DWhXugpSpScP3H82wuQ+atGq8thOzo FcJ4zrgRgmZOk0N8E2kLuQCtlvyW3QugwV9SIIxHgMfrWWwhAg5YpfHUrFOhUzP41s5E +MZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926700; x=1705531500; 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=VRgNiPJydpvDmMhlC8JjCGm8KjRyw9Ww/5hSgKncWeA=; b=mOJQ+XjOcbUsDSxrP1iRdAdCLW2LahTRFlQO0rYflmF7+Cu7yWNaNArMmEA4WRj4JS jUyK3akKkW8xfnEpBw9F057FY5S+QpPfkOVAwu5J5tcXG4JmODllzmLTh9T9Ywr/GLyl /B15XOW557IcKmfzw8ZigQ/0N5UMYVPJkOXw9BHzWqGDdkLLiPmOKSg9Od3q0uCqMWLN 64bCsJIFJrShU+fPtAzuPFb7vECrIJlXTcqo7JTDzKl2BoV0genewzGdyvQutwf237lS SMr0AIc6+4slVLFCBSlJnwPlKOcGblKNKd/LL8oVLg61V9l9M+dsuXeqPrC7A36k0n1N 46sQ== X-Gm-Message-State: AOJu0YyF6yfHkmMWhA8aoZMYOZrQo8sVJp2IpZMmAWIcGS+DmW8jQtlq HP82YIlSRT07pbPbpX/oCCuCmkhJbrBN2c/bUZbg3QpFAKg1PyZe X-Received: by 2002:a05:6808:16a2:b0:3bb:cd42:752c with SMTP id bb34-20020a05680816a200b003bbcd42752cmr320840oib.70.1704926700464; Wed, 10 Jan 2024 14:45:00 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.44.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:45:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 05/38] tcg/optimize: Do swap_commutative2 in do_constant_folding_cond2 Date: Thu, 11 Jan 2024 09:43:35 +1100 Message-Id: <20240110224408.10444-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22a; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22a.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Mirror the new do_constant_folding_cond1 by doing all argument and condition adjustment within one helper. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/optimize.c | 107 ++++++++++++++++++++++++++----------------------- 1 file changed, 57 insertions(+), 50 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 9c04dba099..08a9280432 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -713,43 +713,6 @@ static int do_constant_folding_cond(TCGType type, TCGArg x, return -1; } -/* - * Return -1 if the condition can't be simplified, - * and the result of the condition (0 or 1) if it can. - */ -static int do_constant_folding_cond2(TCGArg *p1, TCGArg *p2, TCGCond c) -{ - TCGArg al = p1[0], ah = p1[1]; - TCGArg bl = p2[0], bh = p2[1]; - - if (arg_is_const(bl) && arg_is_const(bh)) { - tcg_target_ulong blv = arg_info(bl)->val; - tcg_target_ulong bhv = arg_info(bh)->val; - uint64_t b = deposit64(blv, 32, 32, bhv); - - if (arg_is_const(al) && arg_is_const(ah)) { - tcg_target_ulong alv = arg_info(al)->val; - tcg_target_ulong ahv = arg_info(ah)->val; - uint64_t a = deposit64(alv, 32, 32, ahv); - return do_constant_folding_cond_64(a, b, c); - } - if (b == 0) { - switch (c) { - case TCG_COND_LTU: - return 0; - case TCG_COND_GEU: - return 1; - default: - break; - } - } - } - if (args_are_copies(al, bl) && args_are_copies(ah, bh)) { - return do_constant_folding_cond_eq(c); - } - return -1; -} - /** * swap_commutative: * @dest: TCGArg of the destination argument, or NO_DEST. @@ -796,6 +759,10 @@ static bool swap_commutative2(TCGArg *p1, TCGArg *p2) return false; } +/* + * Return -1 if the condition can't be simplified, + * and the result of the condition (0 or 1) if it can. + */ static int do_constant_folding_cond1(OptContext *ctx, TCGArg dest, TCGArg *p1, TCGArg *p2, TCGArg *pcond) { @@ -813,6 +780,51 @@ static int do_constant_folding_cond1(OptContext *ctx, TCGArg dest, return r; } +static int do_constant_folding_cond2(OptContext *ctx, TCGArg *args) +{ + TCGArg al, ah, bl, bh; + TCGCond c; + bool swap; + + swap = swap_commutative2(args, args + 2); + c = args[4]; + if (swap) { + args[4] = c = tcg_swap_cond(c); + } + + al = args[0]; + ah = args[1]; + bl = args[2]; + bh = args[3]; + + if (arg_is_const(bl) && arg_is_const(bh)) { + tcg_target_ulong blv = arg_info(bl)->val; + tcg_target_ulong bhv = arg_info(bh)->val; + uint64_t b = deposit64(blv, 32, 32, bhv); + + if (arg_is_const(al) && arg_is_const(ah)) { + tcg_target_ulong alv = arg_info(al)->val; + tcg_target_ulong ahv = arg_info(ah)->val; + uint64_t a = deposit64(alv, 32, 32, ahv); + return do_constant_folding_cond_64(a, b, c); + } + if (b == 0) { + switch (c) { + case TCG_COND_LTU: + return 0; + case TCG_COND_GEU: + return 1; + default: + break; + } + } + } + if (args_are_copies(al, bl) && args_are_copies(ah, bh)) { + return do_constant_folding_cond_eq(c); + } + return -1; +} + static void init_arguments(OptContext *ctx, TCGOp *op, int nb_args) { for (int i = 0; i < nb_args; i++) { @@ -1225,15 +1237,13 @@ static bool fold_brcond(OptContext *ctx, TCGOp *op) static bool fold_brcond2(OptContext *ctx, TCGOp *op) { - TCGCond cond = op->args[4]; - TCGArg label = op->args[5]; + TCGCond cond; + TCGArg label; int i, inv = 0; - if (swap_commutative2(&op->args[0], &op->args[2])) { - op->args[4] = cond = tcg_swap_cond(cond); - } - - i = do_constant_folding_cond2(&op->args[0], &op->args[2], cond); + i = do_constant_folding_cond2(ctx, &op->args[0]); + cond = op->args[4]; + label = op->args[5]; if (i >= 0) { goto do_brcond_const; } @@ -1986,14 +1996,11 @@ static bool fold_negsetcond(OptContext *ctx, TCGOp *op) static bool fold_setcond2(OptContext *ctx, TCGOp *op) { - TCGCond cond = op->args[5]; + TCGCond cond; int i, inv = 0; - if (swap_commutative2(&op->args[1], &op->args[3])) { - op->args[5] = cond = tcg_swap_cond(cond); - } - - i = do_constant_folding_cond2(&op->args[1], &op->args[3], cond); + i = do_constant_folding_cond2(ctx, &op->args[1]); + cond = op->args[5]; if (i >= 0) { goto do_setcond_const; } From patchwork Wed Jan 10 22:43:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761471 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2112364wrz; Wed, 10 Jan 2024 14:46:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IHkn171DvNznqL2GZHV/rBwaE6cMS2O2cyfVM0ttrP554i+62mSPBCwMLZwNje4OaJ5Xc1h X-Received: by 2002:a05:620a:b11:b0:783:3409:2c96 with SMTP id t17-20020a05620a0b1100b0078334092c96mr276660qkg.75.1704926780397; Wed, 10 Jan 2024 14:46:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926780; cv=none; d=google.com; s=arc-20160816; b=Fw/pLcXaee3CZ1ZtQMzIsMdJbr74o3rDdqOJh/PbzNcPocB5/Lgzy98JSF3JnxFyZE HYqOSRbKqFRu+9HEvno5tbiJDw/oc0d+EW+v1pXMe9Rgi9qGZaFYqNo+1F0UjlKKgM4y KMQphfF+Zy+8KS3NRj+FkORpXbp2gpYsMW25PJghKt8vknXmilb0U17+N0L/L9AD8Rlj MXYN1lTEYsVfaLcdMVJrtsJRHqADT/rW0mfGSrem6vkUnuiVHX/4PlIVNzyCegEhoMEQ ne1qBC6Fo/N7XGuWsIAuZ4W4RAMTWGJGWJAGAh4adXLEHIa/eY03X7E2J3fiDMdG6S0S vmbg== 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=4WPFWKge9Cibe1+P1uYI+mpRsrAd20eTdoBjuJnsUMU=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=ZkgXzgKjE4n/TeyKe+k/SOCsmckhS5l35HBcO34atS880nn8ed1d0Rssj2f88nu0ya HfKG0zRqayI3OjhOp1OAzqluzpdX5PaBlCmLrnFFqI4YrfwA2umj9rINOJGuxuGjGWUv 3zW9JLqib9sQxWeM/oYoT4+J5Q0oPOgW0nyRU5zeGy0hrWUw4tApB/2kHP5WCMmcnYO1 wzIEaTsytQTLlkttKDb7SMsWcBZsVyCL2fGMzM1Ne1tn0RRm3//x/kfWp/CQT98axKPH SF5h0Ig0Ul/D99TsKZewO9JkbqagtNBIg0vC3fouSQJ7NK+ddEvxIHKPjwKJe4F9EH5d aX3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U7ihqSin; 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 n18-20020a05620a295200b007833600c1cbsi2282887qkp.19.2024.01.10.14.46.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:46:20 -0800 (PST) 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=U7ihqSin; 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 1rNhJy-0004b9-PT; Wed, 10 Jan 2024 17:45:14 -0500 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 1rNhJv-0004XK-7k for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:11 -0500 Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhJs-0002tN-Lw for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:10 -0500 Received: by mail-qt1-x833.google.com with SMTP id d75a77b69052e-429be9fe952so2180471cf.0 for ; Wed, 10 Jan 2024 14:45:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926708; x=1705531508; 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=4WPFWKge9Cibe1+P1uYI+mpRsrAd20eTdoBjuJnsUMU=; b=U7ihqSinGXyf4OriAo9qBxbCwk0re9yY4H2PWwYc3tUM6bw9JwIhK9bEJhHL08yM6H P+VdEpPQ0l76JtrCc5lQBTZAit6MbCaygnz3CgyQfGZsPhsmhKvfbH9QUKu5OFL+eBy/ 1vrjEhQf/opLbUkutkbl7vFfI/pPtG8uJeDjXfn+88rYD6XWej9ERjwRF1umf2gufvz8 1RrPJgrFkhgDxi+bpBkqbrnpCdisPE3FSkW7QAXkUboZGh44KqHK1l4ycDT8T90JRZb3 kU4n+Y8e8JFm1ZU0KvajZEX9pOUSro8i5kK5ASseY8rWYROHCsR1erEaTcBWsJQu5/0n BvtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926708; x=1705531508; 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=4WPFWKge9Cibe1+P1uYI+mpRsrAd20eTdoBjuJnsUMU=; b=CfpUfu3Ocxj9bR4s6+ncwAxNjLG0iOSaH+qScJAXSXPImIDpvUd2oj7jag6VlDt48u VFYc+d8I5PzRV3BEfkUQv4xb8+tTyA7sXaynbkc/bKi5WmYyyjhBBJ3y37mkU5EP5Bst GMrcaew9VITS3vYDtM2jfZ01Qd7sniGdkxihDv9wqnvuzimwYQeeY0TASnyanSCb+vE2 sVyUugbc/N3XenHqi2DJY4T8P+Y9BXsH+MxNS9O8xut+tQAutf9Pv1UcUJ9ml6is55sC TR8UOHFYpNZCiXtbuDi+PtYKWHGBApeTmH9+2LRUg7vP5EFYQlUPE0hWBY/KmNTHLg+9 qw7g== X-Gm-Message-State: AOJu0Yy3z0f1FQkbnRtBsMRXj45G9Pkmt8VOpR9Onl0kWtenJ/mRRHsO yEAhJIekCaYw3XVXhoqRAZh736BVIAk2ygJkAoJEWE3eK/xaaijV X-Received: by 2002:ac8:584d:0:b0:429:8a1c:8cdd with SMTP id h13-20020ac8584d000000b004298a1c8cddmr1411571qth.57.1704926707734; Wed, 10 Jan 2024 14:45:07 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.45.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:45:07 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 06/38] tcg/optimize: Handle TCG_COND_TST{EQ,NE} Date: Thu, 11 Jan 2024 09:43:36 +1100 Message-Id: <20240110224408.10444-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::833; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x833.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Fold constant comparisons. Canonicalize "tst x,x" to equality vs zero. Canonicalize "tst x,sign" to sign test vs zero. Fold double-word comparisons with zero parts. Fold setcond of "tst x,pow2" to a bit extract. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/optimize.c | 240 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 218 insertions(+), 22 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 08a9280432..2ed6322f97 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -625,9 +625,15 @@ static bool do_constant_folding_cond_32(uint32_t x, uint32_t y, TCGCond c) return x <= y; case TCG_COND_GTU: return x > y; - default: - g_assert_not_reached(); + case TCG_COND_TSTEQ: + return (x & y) == 0; + case TCG_COND_TSTNE: + return (x & y) != 0; + case TCG_COND_ALWAYS: + case TCG_COND_NEVER: + break; } + g_assert_not_reached(); } static bool do_constant_folding_cond_64(uint64_t x, uint64_t y, TCGCond c) @@ -653,12 +659,18 @@ static bool do_constant_folding_cond_64(uint64_t x, uint64_t y, TCGCond c) return x <= y; case TCG_COND_GTU: return x > y; - default: - g_assert_not_reached(); + case TCG_COND_TSTEQ: + return (x & y) == 0; + case TCG_COND_TSTNE: + return (x & y) != 0; + case TCG_COND_ALWAYS: + case TCG_COND_NEVER: + break; } + g_assert_not_reached(); } -static bool do_constant_folding_cond_eq(TCGCond c) +static int do_constant_folding_cond_eq(TCGCond c) { switch (c) { case TCG_COND_GT: @@ -673,9 +685,14 @@ static bool do_constant_folding_cond_eq(TCGCond c) case TCG_COND_LEU: case TCG_COND_EQ: return 1; - default: - g_assert_not_reached(); + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + return -1; + case TCG_COND_ALWAYS: + case TCG_COND_NEVER: + break; } + g_assert_not_reached(); } /* @@ -703,8 +720,10 @@ static int do_constant_folding_cond(TCGType type, TCGArg x, } else if (arg_is_const_val(y, 0)) { switch (c) { case TCG_COND_LTU: + case TCG_COND_TSTNE: return 0; case TCG_COND_GEU: + case TCG_COND_TSTEQ: return 1; default: return -1; @@ -777,7 +796,30 @@ static int do_constant_folding_cond1(OptContext *ctx, TCGArg dest, } r = do_constant_folding_cond(ctx->type, *p1, *p2, cond); - return r; + if (r >= 0) { + return r; + } + if (!is_tst_cond(cond)) { + return -1; + } + + /* + * TSTNE x,x -> NE x,0 + * TSTNE x,-1 -> NE x,0 + */ + if (args_are_copies(*p1, *p2) || arg_is_const_val(*p2, -1)) { + *p2 = arg_new_constant(ctx, 0); + *pcond = tcg_tst_eqne_cond(cond); + return -1; + } + + /* TSTNE x,sign -> LT x,0 */ + if (arg_is_const_val(*p2, (ctx->type == TCG_TYPE_I32 + ? INT32_MIN : INT64_MIN))) { + *p2 = arg_new_constant(ctx, 0); + *pcond = tcg_tst_ltge_cond(cond); + } + return -1; } static int do_constant_folding_cond2(OptContext *ctx, TCGArg *args) @@ -785,6 +827,7 @@ static int do_constant_folding_cond2(OptContext *ctx, TCGArg *args) TCGArg al, ah, bl, bh; TCGCond c; bool swap; + int r; swap = swap_commutative2(args, args + 2); c = args[4]; @@ -806,21 +849,54 @@ static int do_constant_folding_cond2(OptContext *ctx, TCGArg *args) tcg_target_ulong alv = arg_info(al)->val; tcg_target_ulong ahv = arg_info(ah)->val; uint64_t a = deposit64(alv, 32, 32, ahv); - return do_constant_folding_cond_64(a, b, c); + + r = do_constant_folding_cond_64(a, b, c); + if (r >= 0) { + return r; + } } + if (b == 0) { switch (c) { case TCG_COND_LTU: + case TCG_COND_TSTNE: return 0; case TCG_COND_GEU: + case TCG_COND_TSTEQ: return 1; default: break; } } + + /* TSTNE x,-1 -> NE x,0 */ + if (b == -1 && is_tst_cond(c)) { + args[3] = args[2] = arg_new_constant(ctx, 0); + args[4] = tcg_tst_eqne_cond(c); + return -1; + } + + /* TSTNE x,sign -> LT x,0 */ + if (b == INT64_MIN && is_tst_cond(c)) { + /* bl must be 0, so copy that to bh */ + args[3] = bl; + args[4] = tcg_tst_ltge_cond(c); + return -1; + } } + if (args_are_copies(al, bl) && args_are_copies(ah, bh)) { - return do_constant_folding_cond_eq(c); + r = do_constant_folding_cond_eq(c); + if (r >= 0) { + return r; + } + + /* TSTNE x,x -> NE x,0 */ + if (is_tst_cond(c)) { + args[3] = args[2] = arg_new_constant(ctx, 0); + args[4] = tcg_tst_eqne_cond(c); + return -1; + } } return -1; } @@ -1284,24 +1360,37 @@ static bool fold_brcond2(OptContext *ctx, TCGOp *op) case 0: goto do_brcond_const; case 1: - op->opc = INDEX_op_brcond_i32; - op->args[1] = op->args[2]; - op->args[2] = cond; - op->args[3] = label; - break; + goto do_brcond_low; + } + break; + + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + if (arg_is_const_val(op->args[2], 0)) { + goto do_brcond_high; + } + if (arg_is_const_val(op->args[3], 0)) { + goto do_brcond_low; } break; default: break; + do_brcond_low: + op->opc = INDEX_op_brcond_i32; + op->args[1] = op->args[2]; + op->args[2] = cond; + op->args[3] = label; + return fold_brcond(ctx, op); + do_brcond_high: op->opc = INDEX_op_brcond_i32; op->args[0] = op->args[1]; op->args[1] = op->args[3]; op->args[2] = cond; op->args[3] = label; - break; + return fold_brcond(ctx, op); do_brcond_const: if (i == 0) { @@ -1967,6 +2056,99 @@ static bool fold_remainder(OptContext *ctx, TCGOp *op) return false; } +static void fold_setcond_tst_pow2(OptContext *ctx, TCGOp *op, bool neg) +{ + TCGOpcode and_opc, sub_opc, xor_opc, neg_opc, shr_opc, uext_opc, sext_opc; + TCGCond cond = op->args[3]; + TCGArg ret, src1, src2; + TCGOp *op2; + uint64_t val; + int sh; + bool inv; + + if (!is_tst_cond(cond) || !arg_is_const(op->args[2])) { + return; + } + + src2 = op->args[2]; + val = arg_info(src2)->val; + if (!is_power_of_2(val)) { + return; + } + sh = ctz64(val); + + switch (ctx->type) { + case TCG_TYPE_I32: + and_opc = INDEX_op_and_i32; + sub_opc = INDEX_op_sub_i32; + xor_opc = INDEX_op_xor_i32; + shr_opc = INDEX_op_shr_i32; + neg_opc = INDEX_op_neg_i32; + if (TCG_TARGET_extract_i32_valid(sh, 1)) { + uext_opc = TCG_TARGET_HAS_extract_i32 ? INDEX_op_extract_i32 : 0; + sext_opc = TCG_TARGET_HAS_sextract_i32 ? INDEX_op_sextract_i32 : 0; + } + break; + case TCG_TYPE_I64: + and_opc = INDEX_op_and_i64; + sub_opc = INDEX_op_sub_i64; + xor_opc = INDEX_op_xor_i64; + shr_opc = INDEX_op_shr_i64; + neg_opc = INDEX_op_neg_i64; + if (TCG_TARGET_extract_i64_valid(sh, 1)) { + uext_opc = TCG_TARGET_HAS_extract_i64 ? INDEX_op_extract_i64 : 0; + sext_opc = TCG_TARGET_HAS_sextract_i64 ? INDEX_op_sextract_i64 : 0; + } + break; + default: + g_assert_not_reached(); + } + + ret = op->args[0]; + src1 = op->args[1]; + inv = cond == TCG_COND_TSTEQ; + + if (sh && sext_opc && neg && !inv) { + op->opc = sext_opc; + op->args[1] = src1; + op->args[2] = sh; + op->args[3] = 1; + return; + } else if (sh && uext_opc) { + op->opc = uext_opc; + op->args[1] = src1; + op->args[2] = sh; + op->args[3] = 1; + } else { + if (sh) { + op2 = tcg_op_insert_before(ctx->tcg, op, shr_opc, 3); + op2->args[0] = ret; + op2->args[1] = src1; + op2->args[2] = arg_new_constant(ctx, sh); + src1 = ret; + } + op->opc = and_opc; + op->args[1] = src1; + op->args[2] = arg_new_constant(ctx, 1); + } + + if (neg && inv) { + op2 = tcg_op_insert_after(ctx->tcg, op, sub_opc, 3); + op2->args[0] = ret; + op2->args[1] = ret; + op2->args[2] = arg_new_constant(ctx, 1); + } else if (inv) { + op2 = tcg_op_insert_after(ctx->tcg, op, xor_opc, 3); + op2->args[0] = ret; + op2->args[1] = ret; + op2->args[2] = arg_new_constant(ctx, 1); + } else if (neg) { + op2 = tcg_op_insert_after(ctx->tcg, op, neg_opc, 2); + op2->args[0] = ret; + op2->args[1] = ret; + } +} + static bool fold_setcond(OptContext *ctx, TCGOp *op) { int i = do_constant_folding_cond1(ctx, op->args[0], &op->args[1], @@ -1974,6 +2156,7 @@ static bool fold_setcond(OptContext *ctx, TCGOp *op) if (i >= 0) { return tcg_opt_gen_movi(ctx, op, op->args[0], i); } + fold_setcond_tst_pow2(ctx, op, false); ctx->z_mask = 1; ctx->s_mask = smask_from_zmask(1); @@ -1987,13 +2170,13 @@ static bool fold_negsetcond(OptContext *ctx, TCGOp *op) if (i >= 0) { return tcg_opt_gen_movi(ctx, op, op->args[0], -i); } + fold_setcond_tst_pow2(ctx, op, true); /* Value is {0,-1} so all bits are repetitions of the sign. */ ctx->s_mask = -1; return false; } - static bool fold_setcond2(OptContext *ctx, TCGOp *op) { TCGCond cond; @@ -2041,22 +2224,35 @@ static bool fold_setcond2(OptContext *ctx, TCGOp *op) case 0: goto do_setcond_const; case 1: - op->args[2] = op->args[3]; - op->args[3] = cond; - op->opc = INDEX_op_setcond_i32; - break; + goto do_setcond_low; + } + break; + + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + if (arg_is_const_val(op->args[2], 0)) { + goto do_setcond_high; + } + if (arg_is_const_val(op->args[4], 0)) { + goto do_setcond_low; } break; default: break; + do_setcond_low: + op->args[2] = op->args[3]; + op->args[3] = cond; + op->opc = INDEX_op_setcond_i32; + return fold_setcond(ctx, op); + do_setcond_high: op->args[1] = op->args[2]; op->args[2] = op->args[4]; op->args[3] = cond; op->opc = INDEX_op_setcond_i32; - break; + return fold_setcond(ctx, op); } ctx->z_mask = 1; From patchwork Wed Jan 10 22:43:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761492 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2113124wrz; Wed, 10 Jan 2024 14:48:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IFZ/7NgNYRMFGP1QFAJF0qa//DRfd/CVOyEEiwBRbJmeq9YZuRY+aNqydMRiYmhMArFKKpS X-Received: by 2002:a05:620a:1362:b0:783:3ed0:ffb5 with SMTP id d2-20020a05620a136200b007833ed0ffb5mr128215qkl.98.1704926933387; Wed, 10 Jan 2024 14:48:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926933; cv=none; d=google.com; s=arc-20160816; b=BestPaetvATLpaXcxlSSkj99ImfMNjiRd4TooWOPv3+5Ef7DtXPGke/Rrz8JYoV3GV LdZKUeuq03nnR0NaIPK84n3+88PcmXfwQFUKT04NppAzY7TGXqGZQc84FPHmigqPIi2t tm5lDBZsyVgae9iHO0lXsnltvr4ZQ65E5Yo1pyOWKqIUM1AbGnXVNxlS7uAoxvmGVm1K NO+33+BnRFTFpFyDYoCdxLVWwwP4roxuTcubkhMMQccmohzY8+23pXMGA2Se2FZ/k2w4 uacN9ifEXBBG4TJ0B8zarc8ORDYJL3yai9yvA2HWr30iqJPEF83NYuTibd5wNHp0MUUy UelA== 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=y2ce6D5ByMe3tDiT00xgPKeYRv8+A16TaFSE/MtfeS0=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=C65bQMumJA/DQ7kwTbAockpSsBMwc2bNTxMJJcKVtrpM0XO4tnZ+fs1dPp9EqSDmqm 1Os/IDGd2vsIQyHAIaPku3VtaBoWRknC+ccJjSX6oqbJ4yyq2I2cK628xB+pnQJn2Rp7 err+Dm/EImiK0AA0CBkfATNz+KLaZDy5APzISjXuigtAOS1OEPBj8Sj7W50JNFKVLRAB XauvNobvH5UihF3nvTy3WpZIxflV0fdKlj50SzdSvEd3b4m0yUhruYq2gjQaCSO3mtf8 060eV2DENuvVVhCEtuaSQCQC9hCbPT2+hlpFx2XOh47REHLZ0f7t0ioOI4MatDBbBHJQ fsqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VFS39RS0; 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=fail (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 h5-20020a37c445000000b007832a088152si4924624qkm.415.2024.01.10.14.48.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:48:53 -0800 (PST) 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=fail header.i=@linaro.org header.s=google header.b=VFS39RS0; 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=fail (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 1rNhK2-0004da-2W; Wed, 10 Jan 2024 17:45:18 -0500 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 1rNhJz-0004cn-Fc for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:15 -0500 Received: from mail-qt1-x82b.google.com ([2607:f8b0:4864:20::82b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhJx-0002uL-LF for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:15 -0500 Received: by mail-qt1-x82b.google.com with SMTP id d75a77b69052e-429c00bf0efso736131cf.1 for ; Wed, 10 Jan 2024 14:45:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926712; x=1705531512; 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=y2ce6D5ByMe3tDiT00xgPKeYRv8+A16TaFSE/MtfeS0=; b=VFS39RS0y8vYnEcaMFmr/G+2y5leAv0vEgk6LgnXLJyijUD7Q3C//I8L4yIYuDYCvb 7Sa9viokTUv2I722qHFo+Uw3WAdtrd2e04PEHUcNJBHkTphSKvaVqLnNF2fM+XXYQ1ln vPFN7pa8dloRpYgZ/DsZCuKLKGJfr/u5zJPOzNyW9+kROsOe30uRxXvgG8ddg8KinJk+ 0BV9W3Elg5TEIkaxxrOBS3gbebUSm28YXxWKTSSOXVDrp16jWvccfdV92ftUoAyY1eN6 8vFXz2MEPpXWpneBG1gbxCsKXsENtMeqmP9XYkx7T7fGSa2v2MUh/ecZzLG4p+emBhRk Aqbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926712; x=1705531512; 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=y2ce6D5ByMe3tDiT00xgPKeYRv8+A16TaFSE/MtfeS0=; b=F4IGCEqN1Qad0muBofixZPj1RjR7mtIpt2cGdKC41hgdM4TIcYfENsdiaikaGADOpq f2W2TWQn0QwPtzMSj3MLCaZINwH27CbkEl3zlyvOKcP0jakD33EgYP2SYU7n8DtklMiU mbfnD+M5Y6GTT1h1Wv4qQPNpY7B3QeaokCZnzOcyBCpXmor3GQMbze+4YmOAd6g6aVtm acquU5JNkOjIjj7q0aRp7jqP/iPUuRpM2ZFAh7WogSXTL2NsAkn5L+TYXEIiKju48S3o ZtkQv4PfFTuL21NPevYxjpycpwswrg2dIeom+7Gz68vrX5mmjqOBNQl9GQXosr5Onq5f 6q7A== X-Gm-Message-State: AOJu0Yxb+RpNxlD0OO5vtbwrZQ7W0pZAX1k3a5NDgmU/YIbCx96vT0E8 22Go8NKrhyuSNGkqS8IdLSWwJTjum9TUsbn0Au7D0jzoIMVA6TRT X-Received: by 2002:ac8:7fcd:0:b0:429:a1e3:d036 with SMTP id b13-20020ac87fcd000000b00429a1e3d036mr358917qtk.47.1704926712499; Wed, 10 Jan 2024 14:45:12 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.45.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:45:12 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 07/38] tcg/optimize: Lower TCG_COND_TST{EQ, NE} if unsupported Date: Thu, 11 Jan 2024 09:43:37 +1100 Message-Id: <20240110224408.10444-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82b; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82b.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, T_SCC_BODY_TEXT_LINE=-0.01 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 After having performed other simplifications, lower any remaining test comparisons with AND. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tcg/tcg-internal.h | 2 ++ tcg/optimize.c | 60 +++++++++++++++++++++++++++++++++++++++------- tcg/tcg.c | 2 +- 3 files changed, 55 insertions(+), 9 deletions(-) diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index 6c9d9e48db..9b0d982f65 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -83,6 +83,8 @@ static inline TCGv_i64 TCGV128_HIGH(TCGv_i128 t) bool tcg_target_has_memory_bswap(MemOp memop); +TCGTemp *tcg_temp_new_internal(TCGType type, TCGTempKind kind); + /* * Locate or create a read-only temporary that is a constant. * This kind of temporary need not be freed, but for convenience diff --git a/tcg/optimize.c b/tcg/optimize.c index 2ed6322f97..79e701652b 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -364,6 +364,13 @@ static TCGArg arg_new_constant(OptContext *ctx, uint64_t val) return temp_arg(ts); } +static TCGArg arg_new_temp(OptContext *ctx) +{ + TCGTemp *ts = tcg_temp_new_internal(ctx->type, TEMP_EBB); + init_ts_info(ctx, ts); + return temp_arg(ts); +} + static bool tcg_opt_gen_mov(OptContext *ctx, TCGOp *op, TCGArg dst, TCGArg src) { TCGTemp *dst_ts = arg_temp(dst); @@ -782,7 +789,7 @@ static bool swap_commutative2(TCGArg *p1, TCGArg *p2) * Return -1 if the condition can't be simplified, * and the result of the condition (0 or 1) if it can. */ -static int do_constant_folding_cond1(OptContext *ctx, TCGArg dest, +static int do_constant_folding_cond1(OptContext *ctx, TCGOp *op, TCGArg dest, TCGArg *p1, TCGArg *p2, TCGArg *pcond) { TCGCond cond; @@ -818,11 +825,28 @@ static int do_constant_folding_cond1(OptContext *ctx, TCGArg dest, ? INT32_MIN : INT64_MIN))) { *p2 = arg_new_constant(ctx, 0); *pcond = tcg_tst_ltge_cond(cond); + return -1; + } + + /* Expand to AND with a temporary if no backend support. */ + if (!TCG_TARGET_HAS_tst) { + TCGOpcode and_opc = (ctx->type == TCG_TYPE_I32 + ? INDEX_op_and_i32 : INDEX_op_and_i64); + TCGOp *op2 = tcg_op_insert_before(ctx->tcg, op, and_opc, 3); + TCGArg tmp = arg_new_temp(ctx); + + op2->args[0] = tmp; + op2->args[1] = *p1; + op2->args[2] = *p2; + + *p1 = tmp; + *p2 = arg_new_constant(ctx, 0); + *pcond = tcg_tst_eqne_cond(cond); } return -1; } -static int do_constant_folding_cond2(OptContext *ctx, TCGArg *args) +static int do_constant_folding_cond2(OptContext *ctx, TCGOp *op, TCGArg *args) { TCGArg al, ah, bl, bh; TCGCond c; @@ -898,6 +922,26 @@ static int do_constant_folding_cond2(OptContext *ctx, TCGArg *args) return -1; } } + + /* Expand to AND with a temporary if no backend support. */ + if (!TCG_TARGET_HAS_tst && is_tst_cond(c)) { + TCGOp *op1 = tcg_op_insert_before(ctx->tcg, op, INDEX_op_and_i32, 3); + TCGOp *op2 = tcg_op_insert_before(ctx->tcg, op, INDEX_op_and_i32, 3); + TCGArg t1 = arg_new_temp(ctx); + TCGArg t2 = arg_new_temp(ctx); + + op1->args[0] = t1; + op1->args[1] = al; + op1->args[2] = bl; + op2->args[0] = t2; + op2->args[1] = ah; + op2->args[2] = bh; + + args[0] = t1; + args[1] = t2; + args[3] = args[2] = arg_new_constant(ctx, 0); + args[4] = tcg_tst_eqne_cond(c); + } return -1; } @@ -1298,7 +1342,7 @@ static bool fold_andc(OptContext *ctx, TCGOp *op) static bool fold_brcond(OptContext *ctx, TCGOp *op) { - int i = do_constant_folding_cond1(ctx, NO_DEST, &op->args[0], + int i = do_constant_folding_cond1(ctx, op, NO_DEST, &op->args[0], &op->args[1], &op->args[2]); if (i == 0) { tcg_op_remove(ctx->tcg, op); @@ -1317,7 +1361,7 @@ static bool fold_brcond2(OptContext *ctx, TCGOp *op) TCGArg label; int i, inv = 0; - i = do_constant_folding_cond2(ctx, &op->args[0]); + i = do_constant_folding_cond2(ctx, op, &op->args[0]); cond = op->args[4]; label = op->args[5]; if (i >= 0) { @@ -1815,7 +1859,7 @@ static bool fold_movcond(OptContext *ctx, TCGOp *op) op->args[5] = tcg_invert_cond(op->args[5]); } - i = do_constant_folding_cond1(ctx, NO_DEST, &op->args[1], + i = do_constant_folding_cond1(ctx, op, NO_DEST, &op->args[1], &op->args[2], &op->args[5]); if (i >= 0) { return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[4 - i]); @@ -2151,7 +2195,7 @@ static void fold_setcond_tst_pow2(OptContext *ctx, TCGOp *op, bool neg) static bool fold_setcond(OptContext *ctx, TCGOp *op) { - int i = do_constant_folding_cond1(ctx, op->args[0], &op->args[1], + int i = do_constant_folding_cond1(ctx, op, op->args[0], &op->args[1], &op->args[2], &op->args[3]); if (i >= 0) { return tcg_opt_gen_movi(ctx, op, op->args[0], i); @@ -2165,7 +2209,7 @@ static bool fold_setcond(OptContext *ctx, TCGOp *op) static bool fold_negsetcond(OptContext *ctx, TCGOp *op) { - int i = do_constant_folding_cond1(ctx, op->args[0], &op->args[1], + int i = do_constant_folding_cond1(ctx, op, op->args[0], &op->args[1], &op->args[2], &op->args[3]); if (i >= 0) { return tcg_opt_gen_movi(ctx, op, op->args[0], -i); @@ -2182,7 +2226,7 @@ static bool fold_setcond2(OptContext *ctx, TCGOp *op) TCGCond cond; int i, inv = 0; - i = do_constant_folding_cond2(ctx, &op->args[1]); + i = do_constant_folding_cond2(ctx, op, &op->args[1]); cond = op->args[5]; if (i >= 0) { goto do_setcond_const; diff --git a/tcg/tcg.c b/tcg/tcg.c index 9d146b13aa..2f4522488a 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1655,7 +1655,7 @@ TCGv_ptr tcg_global_mem_new_ptr(TCGv_ptr reg, intptr_t off, const char *name) return temp_tcgv_ptr(ts); } -static TCGTemp *tcg_temp_new_internal(TCGType type, TCGTempKind kind) +TCGTemp *tcg_temp_new_internal(TCGType type, TCGTempKind kind) { TCGContext *s = tcg_ctx; TCGTemp *ts; From patchwork Wed Jan 10 22:43:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761490 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2113076wrz; Wed, 10 Jan 2024 14:48:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IGfPMz6rxthvdnmhKbRGX1sGBjApn+XKessPcPJ+cpjCfBTIk7qh0WlQ4h9OqMRib0gMfxI X-Received: by 2002:a05:6214:23c9:b0:681:916:b324 with SMTP id hr9-20020a05621423c900b006810916b324mr174281qvb.33.1704926926218; Wed, 10 Jan 2024 14:48:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926926; cv=none; d=google.com; s=arc-20160816; b=AGCKF+PO/DBLe0/yWhHnoiA52RF/4Z+p/cdhNIwLFqYh6iqwmo192Ya/iXakUJzTS5 JXyqCtd1w6dAV0ouqt4orpPOF8DqkE7qG2MYmOg9DfFmnjDRWzG4zPZrsarDzKHgErJk MkUznVtKIKjH616EuQtdn0q7V+wgs6Mkz+MX2x/JIeon/5zMGQUq2VlCtbmmRakIJP1w kBgNePR1ixVKqF+NwItm2QL1mk/M6jMOF+TFTa97v3eDj0oP39brSKaut9GyyidPOsao wbdm6CBIjvYq00FQqtCPZ/9HiIpT3qXadWKK2tvKZFl+uh6K+n61Zz2OCUxX00bnGbHg yKUw== 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=UglnfSI98W1O26WExoHEv4U96HoZn03cAysbwbueFqA=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=wrBCIL6l94b24uQ+hEPXMi5eWPbUD9IOtbJCPfKv4pSXl0WrOM3XVGRX3sJgg9LcSR tMIkSkJC+lK+3jfOosTljE1zqCazW3Fk2ywj8YBxpO1urlPpcqMS2grCighutVQCcmK0 fXLF1Tftic8k2ZoGE8uBm9XpmNJjNuWZKglN2TjNeWPEQ8BqkWYQjSQ5vpn5Bwc+JYt3 6B+84+DdnDh6c7l5mz2vVYc41JIaANpbdlgKT/Z0Pmx0nxCbfyQLlyx4BgQUUYPdRccm ZMfSddBy8Ix/0rl4usB8ZStxfGNyZvaf7wTTV8108D9Xnjr7f8Y8HfNTFWG9W7/Ialm7 aUnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XtCk1Qob; 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 e28-20020a0caa5c000000b0067f2c23a115si5442333qvb.163.2024.01.10.14.48.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:48:46 -0800 (PST) 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=XtCk1Qob; 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 1rNhKC-0004pF-Da; Wed, 10 Jan 2024 17:45:28 -0500 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 1rNhK3-0004f0-6T for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:24 -0500 Received: from mail-qt1-x82d.google.com ([2607:f8b0:4864:20::82d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhK1-0002v6-Dc for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:18 -0500 Received: by mail-qt1-x82d.google.com with SMTP id d75a77b69052e-429c00bf0efso736381cf.1 for ; Wed, 10 Jan 2024 14:45:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926716; x=1705531516; 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=UglnfSI98W1O26WExoHEv4U96HoZn03cAysbwbueFqA=; b=XtCk1QobpOCT8gQGPWkcJUqcrTRbiNeaFDPHoXSTa1nmCxewq8jbTmP5UaAZBwJlnw e8jsHAUgwjF+BkNc0pRaNuiu21wYM6+odpZ/ZF+VTGbrAMWvx4oqRcL9ue2dqeV3moUf JUhSNQq0aMclNcJd4E2QU88lg2ofO5HaqAMUkqd/kV1Fg7xtSphbi/d12i7le69tuiDK ZEsX70xi7RJbg7ItZ/BNV55JYShQorSU0qSdAPl4odC7WrszUoMI57F5PXHJYilRgTxy O9Wmo267v51Wk+ixjMgNOvm4OO/cwAcLye8eOBcdl22ki+4Qk/ywAtGLWRMvs8EV5DT0 uqQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926716; x=1705531516; 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=UglnfSI98W1O26WExoHEv4U96HoZn03cAysbwbueFqA=; b=VTwhkoD7m7KB31z0WvLoW1MjoE5e5OblJnj8bPj1oPJyeoDci4QBYzr984wIMIA8fj wC5xEf+l9VQGJHKbohBIj5Vo/QbEuCX58+TLuVCLQtHQmVifBoKL37Zk4GV6Fuvg0pzJ apfnNycNGA8tEPuDGOFY+hiP0vptx+oAfM+8s6XNVTpt/4bKgHOXKMIQoIG0muzYtcgN qDdljAXbvKURrxsD9kfp/1ceu8IGqoYUa837ciOl9Qwnu4+fQS2VZWOeOSQ8oIzbdcPd joa2p5jD4c47jvAu5rlai2VqfoNCxvxAwzxyAbaodqtf/IeTxwC7IzNtYiybemMaXnpQ NHhQ== X-Gm-Message-State: AOJu0YxS2qZzC4ARDJKHzZqp7EFwZkjy+KFkzQnqp5iDUvKd3oCL+z8I 6Mj9DEGlZP/FiA1XEZn/T+wsJlM/qd3z0MAKdhhaPIYgFWhDkK/k X-Received: by 2002:a05:622a:1a90:b0:429:b349:65a7 with SMTP id s16-20020a05622a1a9000b00429b34965a7mr396964qtc.8.1704926716062; Wed, 10 Jan 2024 14:45:16 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.45.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:45:15 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 08/38] target/alpha: Pass immediate value to gen_bcond_internal() Date: Thu, 11 Jan 2024 09:43:38 +1100 Message-Id: <20240110224408.10444-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82d; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82d.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Simplify gen_bcond() by passing an immediate value. Signed-off-by: Richard Henderson Message-Id: <20231028194522.245170-33-richard.henderson@linaro.org> [PMD: Split from bigger patch, part 1/2] Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20231108205247.83234-1-philmd@linaro.org> Reviewed-by: Philippe Mathieu-Daudé --- target/alpha/translate.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/target/alpha/translate.c b/target/alpha/translate.c index 32333081d8..89e630a7cc 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -453,13 +453,13 @@ static DisasJumpType gen_bdirect(DisasContext *ctx, int ra, int32_t disp) } static DisasJumpType gen_bcond_internal(DisasContext *ctx, TCGCond cond, - TCGv cmp, int32_t disp) + TCGv cmp, uint64_t imm, int32_t disp) { uint64_t dest = ctx->base.pc_next + (disp << 2); TCGLabel *lab_true = gen_new_label(); if (use_goto_tb(ctx, dest)) { - tcg_gen_brcondi_i64(cond, cmp, 0, lab_true); + tcg_gen_brcondi_i64(cond, cmp, imm, lab_true); tcg_gen_goto_tb(0); tcg_gen_movi_i64(cpu_pc, ctx->base.pc_next); @@ -472,11 +472,11 @@ static DisasJumpType gen_bcond_internal(DisasContext *ctx, TCGCond cond, return DISAS_NORETURN; } else { - TCGv_i64 z = load_zero(ctx); + TCGv_i64 i = tcg_constant_i64(imm); TCGv_i64 d = tcg_constant_i64(dest); TCGv_i64 p = tcg_constant_i64(ctx->base.pc_next); - tcg_gen_movcond_i64(cond, cpu_pc, cmp, z, d, p); + tcg_gen_movcond_i64(cond, cpu_pc, cmp, i, d, p); return DISAS_PC_UPDATED; } } @@ -484,15 +484,8 @@ static DisasJumpType gen_bcond_internal(DisasContext *ctx, TCGCond cond, static DisasJumpType gen_bcond(DisasContext *ctx, TCGCond cond, int ra, int32_t disp, int mask) { - if (mask) { - TCGv tmp = tcg_temp_new(); - DisasJumpType ret; - - tcg_gen_andi_i64(tmp, load_gpr(ctx, ra), 1); - ret = gen_bcond_internal(ctx, cond, tmp, disp); - return ret; - } - return gen_bcond_internal(ctx, cond, load_gpr(ctx, ra), disp); + return gen_bcond_internal(ctx, cond, load_gpr(ctx, ra), + mask, disp); } /* Fold -0.0 for comparison with COND. */ @@ -533,7 +526,7 @@ static DisasJumpType gen_fbcond(DisasContext *ctx, TCGCond cond, int ra, DisasJumpType ret; gen_fold_mzero(cond, cmp_tmp, load_fpr(ctx, ra)); - ret = gen_bcond_internal(ctx, cond, cmp_tmp, disp); + ret = gen_bcond_internal(ctx, cond, cmp_tmp, 0, disp); return ret; } From patchwork Wed Jan 10 22:43:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761468 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2112222wrz; Wed, 10 Jan 2024 14:45:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHiJqLpDToSsfiqvyd0HjMCiOgfRQiKVMf9GrWHcp1FZzJtog5kVfNDAZSbUrcRmGYpmsS6 X-Received: by 2002:ac8:7c54:0:b0:429:acd9:975c with SMTP id o20-20020ac87c54000000b00429acd9975cmr235572qtv.47.1704926753833; Wed, 10 Jan 2024 14:45:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926753; cv=none; d=google.com; s=arc-20160816; b=KxpKbnHyX22K6/Y8oS4kw2J5eGeuqD4sWOvvW4BZHV/+oDtjN//mteaL7BGlqHMGNA JcpQ5dPSShibM5s4E/rbpalqIsG9x+qaZFbUlFFCn+mxNuIdHH+nsn3B0Kf8cYvn5c/Q qqNwofv7hDw9G63LociYd8oVsVv4RQzNNPK8y6hByENO05W8lfxzSFsR6kGmtLmucmBx YAICr0n5YPEBWr7kQCqI3C2+XGOGwOqGT2cIvWbb3TUc7LylY/qWnFzJMs+bh6xrCWoT +JlGF3SNuDMsfDpFy2QXU+RR+QLkbHy5yscNJLal1VoNW43Sf1hZd8yoG7NzuJ1ajIxb VPXg== 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=iq7I5R53pVNdI93EJRMub3T9kBHS1RS5Ymgrbh0dENY=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=EU8sZmGWVBCu6jsqTAtgziKjNYN3lgq+XnWLC0sVDUM4NMdysXYxYuzzDVuwgYbeaV FZSCNBqv00WeDg3Xt4qw5bFT7wyIolIY1sxD1VwrnN1CTRwH9JP3vHxSyToXbKlna9+L jQPGrPBQuXFrwEzXU7IX3flj9qPwquKZficT2OJGakOUpvHqTmeUkh+QGrRCkm5QT7Vs vyel86Rw3bdE425iugoyqq0HOAw+k4hiVyIocL1UQLGombGU8seCxPWLYssadObkLuzT cHBMGsebDJAP5svqVwfdRigbNySx4QVQIWYHRZnUO02GKx87ok1YSKQb4PB+gX4KY1/l 81pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WqBUN6Ma; 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 r14-20020ac85c8e000000b00429bd71ac6fsi955956qta.579.2024.01.10.14.45.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:45:53 -0800 (PST) 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=WqBUN6Ma; 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 1rNhKJ-0004xu-6Z; Wed, 10 Jan 2024 17:45:38 -0500 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 1rNhK7-0004l2-Eh for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:25 -0500 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhK5-0002ve-Mo for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:23 -0500 Received: by mail-qk1-x72a.google.com with SMTP id af79cd13be357-78333a8d428so114928885a.1 for ; Wed, 10 Jan 2024 14:45:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926719; x=1705531519; 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=iq7I5R53pVNdI93EJRMub3T9kBHS1RS5Ymgrbh0dENY=; b=WqBUN6MacR6Ims/gcjGWLdoJyRQ1j5wpnXy5rwXxHVYkOmG2moa6H1lPqqWIKlRdrj 3dOIP3Z0gnufbGRNSgdacF8O8wvDeL0Ww7aoNuuCOwVLslHcMo06ztGy9t8eb6RGwmSK 9LehmR6XW2L5/T1bkpY1E1m/b8pq2coYmowW+mUT6UcpfBznRG2rsQzKE5gRB9OgPLW3 jwedtrkrphDCeJnzdXcFdqqmofwK4bEEkCKYKniKDtyAs0FCgv/1cPe/IEno8kq6c9qy qVmPDdzP+MLYwir3NHFEB1qOyLNP0Vu4JqNLLOhxOJVjk/+X7SCV1UcT8X2PWrr9FV8F ijKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926719; x=1705531519; 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=iq7I5R53pVNdI93EJRMub3T9kBHS1RS5Ymgrbh0dENY=; b=B7fgJCKpmOdGeX4ADdJR2Q0vzTMmC0lDKsNhkQ/QnHSMTOKxyjxH3vFihMLwaQyoXY QINQ7lpQmPV7er6QC3Mvw9Ij+ffLhW2GuGLxvYwnUIs3vz/CH016zRej/i4xf5i6SQjt gjo+YJLO2SfWd8zpjQkmq6aN4JXYOEfG1m/lFYoKH/FFLFca6/YnAqVywVyPeqSIP4oh XoHajX6L6GoWva0kbLzBFaUud5yxIngguAT7Nwomu8Wu7FMzX0RnMJi7EDzfqmX1hMtN c79iRV4JN0UwCxFeBAW2jAV5/LPer3mdVMthxCyOTrrTHIRAwI3G1WBE41UmMGLSvzqo dAvw== X-Gm-Message-State: AOJu0Yzu4ukBjZW74Pd3mH+XSXoclQYIZiJKQhBH0wpBGNmpLr1Dbku5 u6EIeDYtphrGwPRgaIrGuBF/7Kn7PS9sQDI+UzzE3dsPZxLplzJ3 X-Received: by 2002:a05:620a:1130:b0:783:376c:7b41 with SMTP id p16-20020a05620a113000b00783376c7b41mr1170635qkk.45.1704926719510; Wed, 10 Jan 2024 14:45:19 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.45.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:45:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 09/38] target/alpha: Use TCG_COND_TST{EQ,NE} for BLB{C,S} Date: Thu, 11 Jan 2024 09:43:39 +1100 Message-Id: <20240110224408.10444-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::72a; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72a.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Signed-off-by: Richard Henderson Message-Id: <20231028194522.245170-33-richard.henderson@linaro.org> [PMD: Split from bigger patch, part 2/2] Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20231108205247.83234-2-philmd@linaro.org> Reviewed-by: Philippe Mathieu-Daudé --- target/alpha/translate.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/target/alpha/translate.c b/target/alpha/translate.c index 89e630a7cc..49e6a7b62d 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -482,10 +482,10 @@ static DisasJumpType gen_bcond_internal(DisasContext *ctx, TCGCond cond, } static DisasJumpType gen_bcond(DisasContext *ctx, TCGCond cond, int ra, - int32_t disp, int mask) + int32_t disp) { return gen_bcond_internal(ctx, cond, load_gpr(ctx, ra), - mask, disp); + is_tst_cond(cond), disp); } /* Fold -0.0 for comparison with COND. */ @@ -2820,35 +2820,35 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn) break; case 0x38: /* BLBC */ - ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 1); + ret = gen_bcond(ctx, TCG_COND_TSTEQ, ra, disp21); break; case 0x39: /* BEQ */ - ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 0); + ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21); break; case 0x3A: /* BLT */ - ret = gen_bcond(ctx, TCG_COND_LT, ra, disp21, 0); + ret = gen_bcond(ctx, TCG_COND_LT, ra, disp21); break; case 0x3B: /* BLE */ - ret = gen_bcond(ctx, TCG_COND_LE, ra, disp21, 0); + ret = gen_bcond(ctx, TCG_COND_LE, ra, disp21); break; case 0x3C: /* BLBS */ - ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 1); + ret = gen_bcond(ctx, TCG_COND_TSTNE, ra, disp21); break; case 0x3D: /* BNE */ - ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 0); + ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21); break; case 0x3E: /* BGE */ - ret = gen_bcond(ctx, TCG_COND_GE, ra, disp21, 0); + ret = gen_bcond(ctx, TCG_COND_GE, ra, disp21); break; case 0x3F: /* BGT */ - ret = gen_bcond(ctx, TCG_COND_GT, ra, disp21, 0); + ret = gen_bcond(ctx, TCG_COND_GT, ra, disp21); break; invalid_opc: ret = gen_invalid(ctx); From patchwork Wed Jan 10 22:43:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761469 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2112294wrz; Wed, 10 Jan 2024 14:46:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IHcYf98/mLr5996vZ81EOCjLE8TsU68JW5VoHrspwrMoLe8xNwiC2Ge5h3DS2k+dNpfSERP X-Received: by 2002:a05:6122:c89:b0:4b7:6143:7a47 with SMTP id ba9-20020a0561220c8900b004b761437a47mr162687vkb.20.1704926766122; Wed, 10 Jan 2024 14:46:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926766; cv=none; d=google.com; s=arc-20160816; b=XhIxvNgFJyCrbtK5Biz1P/r4g55LYfH3SOxtzKOlhloXqK6lxFcqa9fFjjKrDKwe70 s48UXoUABVLuffeWhTdDwGuAUMbe4n99Gm2ycpFKk8xUmbDlPJmJqIEMglky/ugca8Ui 3y5KjmBffNm37eK+Ko0BMUO5061MQ+tKJOafjIGvs3giC2ga4g82Clp38ySRLah+pk5n /ejsvrQM0Tnn7r0Dwl2jKv2L72UDbpcLXz4BvALV6XvbAlWqd55acghx+Rko4rbldhsz a8JF1/OijgVCx8VquU5NV1K1qH5zhdMI87e2VoyX2tjJiiZshBhws/0LPZs00ce/EukS rl+g== 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=fGroRAMABW6rD6Q1rW6plntl0iLNiILFnyK4nwakVJo=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=GtdgDVOmK9zGAVgDx+Y/jddEB/t6kwB1TFVTTaMEX4nzEaDXFpGJSTDXiBVEXFECvR Ad43R3inbEhn/fY6mLiiZsqu8snFWbrnTMRq25PMNLSyTEkxvq2GdSPA2/HE0e/VVrC4 gWc3m7+hvGN82G/FvR0t11SJrtOYAFbrO3yHjMWtho3hqK/YiZwwaW2p2z3/xsbcthg6 FUtkYR4syHMv9hbLhDG5ziPavXOXdNLLY2HO3sY81dOQ3rFx21nIrjuMKP2YbxyVlm6w drFH1cuDOohDm1i8Nhr3ex8VNgpwISSalgsucqFxrzTUa0EdyH8pm2hCDyT93SKJcvJN jwdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=NXKtMUaL; 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=fail (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 vy26-20020a05620a491a00b0078217e9d131si4756964qkn.48.2024.01.10.14.46.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:46:06 -0800 (PST) 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=fail header.i=@linaro.org header.s=google header.b=NXKtMUaL; 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=fail (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 1rNhKT-0004ye-0q; Wed, 10 Jan 2024 17:45:45 -0500 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 1rNhKC-0004rK-Jz for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:28 -0500 Received: from mail-qt1-x830.google.com ([2607:f8b0:4864:20::830]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhKA-0002w8-EV for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:27 -0500 Received: by mail-qt1-x830.google.com with SMTP id d75a77b69052e-429af318342so8665391cf.0 for ; Wed, 10 Jan 2024 14:45:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926723; x=1705531523; 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=fGroRAMABW6rD6Q1rW6plntl0iLNiILFnyK4nwakVJo=; b=NXKtMUaLe38dhg1PSEiB76sdX7DPZcNErV7r7SwTqgg/MteW7aobMbmfjKQOO2PWBX QSBbtEHuawjnrlkW/YbsBkygnKIxB9+8dSE9mp6tvFIAJAK5vOBHr3ArW9oAGDXn+JiJ Uw5BQkYQ7uhj4ImZ7PePilr3Gn+mz2hU3Wgk133PFfyIclgcGseotHGz/Z00u0x3Rd1p PF9DeVnI5+4PZdYYrL0PDnsv/et6MYgdD8YwjT7nuTn7A+dorAs4Fs6xbyoHGN6xYmJ5 p6IMbuHg/+1q+6DIytS4SLpoR9Zsqe5ao/zdzWsi6jqFyTc2f7FEJ0CxAm/X53gnQ6Gg WlTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926723; x=1705531523; 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=fGroRAMABW6rD6Q1rW6plntl0iLNiILFnyK4nwakVJo=; b=ZLRwb+n07KgZjMyOv9xPucQZQgXa4iJL8fr5pwmlbIa++249Y09SOOVOGcSuMqXEej Rg9y29Mt6XUpxTLoRJI7ITdTSyLQIdXV9/QtEdK92d2YEE1RVbJw7ZOw5FEIqzTSrznr FX/z826LMvJV9+q3ihNVTb1ugv1AagHaWyWeo6k7B/hDM1Q/a//RBF+28IgOeFNqyoFu JSCoBW7NTHehT03JzqSABJadvqkstu8NwgSg6iDTKAvxL8WXDm45wDzdD5XPVarUF8XO Bn55ekX43h5pegz89pmASTIEBMv6Q/pByVtx2p4A27mnBXC8Vn6ndjznXxuDscfp37ZS bv3Q== X-Gm-Message-State: AOJu0YyWSOifzyQI+tgSECFejgsIf78q76Teitl3gkS35GnsEXIv/wq9 cEyCzZSFFmnOF+u11ZO9ZIMCJh8CfYYzu4Q6gYHcYdXU7VBwqC6I X-Received: by 2002:a05:622a:4b:b0:429:af00:8be with SMTP id y11-20020a05622a004b00b00429af0008bemr336892qtw.82.1704926723391; Wed, 10 Jan 2024 14:45:23 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.45.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:45:23 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 10/38] target/alpha: Use TCG_COND_TST{EQ, NE} for CMOVLB{C, S} Date: Thu, 11 Jan 2024 09:43:40 +1100 Message-Id: <20240110224408.10444-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::830; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x830.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/alpha/translate.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/target/alpha/translate.c b/target/alpha/translate.c index 49e6a7b62d..c7daf46de7 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -1676,16 +1676,12 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn) break; case 0x14: /* CMOVLBS */ - tmp = tcg_temp_new(); - tcg_gen_andi_i64(tmp, va, 1); - tcg_gen_movcond_i64(TCG_COND_NE, vc, tmp, load_zero(ctx), + tcg_gen_movcond_i64(TCG_COND_TSTNE, vc, va, tcg_constant_i64(1), vb, load_gpr(ctx, rc)); break; case 0x16: /* CMOVLBC */ - tmp = tcg_temp_new(); - tcg_gen_andi_i64(tmp, va, 1); - tcg_gen_movcond_i64(TCG_COND_EQ, vc, tmp, load_zero(ctx), + tcg_gen_movcond_i64(TCG_COND_TSTEQ, vc, va, tcg_constant_i64(1), vb, load_gpr(ctx, rc)); break; case 0x20: From patchwork Wed Jan 10 22:43:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761473 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2112521wrz; Wed, 10 Jan 2024 14:46:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHvTKhYiykMBj/a08R3Zvwb3oH9QPr2jCM0Xos+p2q6Nx3TJ1jYaksOy66a8ne/iatFgbPu X-Received: by 2002:a81:4c8d:0:b0:5fb:1f9:64ff with SMTP id z135-20020a814c8d000000b005fb01f964ffmr83540ywa.12.1704926813886; Wed, 10 Jan 2024 14:46:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926813; cv=none; d=google.com; s=arc-20160816; b=BJg064UdojDvP/R6TVDnyooc/CFq8PMTMQKx1VDfpr7RXdR/7lLlmlXhxH0gGGF0bi fDIq+HrW49UxoghdCi40utTxXoIxURmO9Hswl64/X1t2W8af0ES82CcTOkPhYOgSwyjA /aiWT2UcuFIj+cuQpGfm4MSHfZoJJDirjUQaMRbBj0nw5L8aNsiIYihKY1Y2BX1ENqdM ac7TYv7TfB8QhxOz3WFvuKQQYOcAvwJbkBuuV1Aus57+n/394JXil90OXnThOrukODCA H22kjvF5qKdBu1DXTa78kQXIGD4RjCeNzgaQpCkmGTgm0Avw4ie4orjlK4ZGexq/Rhck DUFw== 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=/Mi02s/8pPhslq92YCDg9owTXJVUIjB51aqomHFCjPA=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=XAXqNeuC7LzJwbSIrtxSryRe0VWjG69pmDC4EcfUrhcNSeHsgtyMALErjL2Ce6UwMt OI+URfvMSKowxfcJaA4NdqV2m6qHgGnluyk877ijb6GIr3TeP/wsfwAqY6HII8XBz9Kx YL/wc9rFSFBwYVzTRUq/W42GVATXDuCAXWc9yhXJXZ57XNyWMCzbiTN4XXAZfNJx8eIl fLoES9TenD11NVUfDwsRoRN6Bz76JZY6O3v9DZZUhjmFFuJS4v9JsMNVgyH8a2lxJKoD P13bhAOYxhdKL8iNTiN00doLvvTg8WulHQ/YGr5iCUgR6QMyePdQU+TQw1WM9fKGDDrQ BJEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UFG6cNwE; 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 ay30-20020a05620a179e00b007833008db9bsi3990217qkb.602.2024.01.10.14.46.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:46:53 -0800 (PST) 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=UFG6cNwE; 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 1rNhKe-0005Pt-SJ; Wed, 10 Jan 2024 17:45:57 -0500 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 1rNhKG-0004y2-Fh for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:33 -0500 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhKC-0002wZ-Ce for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:29 -0500 Received: by mail-qt1-x832.google.com with SMTP id d75a77b69052e-429be919998so1957051cf.0 for ; Wed, 10 Jan 2024 14:45:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926727; x=1705531527; 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=/Mi02s/8pPhslq92YCDg9owTXJVUIjB51aqomHFCjPA=; b=UFG6cNwE2nYjK72QtMVbbEHP1lnq6X+5vqew8499JX0guQ+h1tLEciNXnleoEzIdN2 ZIOwyu0tjs53t1T7YAFZNkvxVQTe/49vHGYknCN5Vh9oj+fo1nTJHwv9WOlDDNC+Gu8w rhy/zq2ZLSQFqDGYvJ5SMqGtrQj7x+DrXceoowxqFnjmr/FI4pn+yZH8P3/bcAsfm2Mm DXU8Hzz2ZzIw2DX3Zh3qXGRp0vC8diSIYXk2rvaSfvE/wG9+SUryy3Klk6oy+WHPYCU6 0gcDcVhvQl8SPz4MrhfRZe0POFBdNQveuRK4F9kWMgHG0atKpGYJySw/VHA3fM91B0O8 vv4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926727; x=1705531527; 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=/Mi02s/8pPhslq92YCDg9owTXJVUIjB51aqomHFCjPA=; b=lXsIIgd1heKGzQ13QXc4DbJqkNP+69mDYLfqxG3fsFRWuKZ8Jl5HIoORZsFbbaLaSP 3Yq+FVjJ55PB4XJltrGqzW9GuzIjP/ruzJu3QBuyKHxPRq0AdE5X7XpgvNKxxz+GdFcG 4Uf5vwskuFYV4DkOndQlZmc3qumYTkv25SFAcmQeV1HIZYgdasyo/63gfHkFS0u6emFn NCClukPre6LFp1kveGSMyA5BwknyKZTmsiXkOWcyHK1k45muK7HZWNQfz5F9ZosHswsJ bl0v+1Y2Jo97OH2ya+OQlie9yBlpE4hqdG1pLkYnJwOw7kHpecvATa4f1jOFbo6mxXju ypaA== X-Gm-Message-State: AOJu0YzfhJ258NRoHRR8uMcNLb102+PcXFCVEag56IZUqd3xi5r8CYLR DL9VceGsqoK5XKa2JLlmeDf1WNO1v0ZnCtSusi8+B0LvECxo0reU X-Received: by 2002:a05:622a:e:b0:429:bb88:6f1e with SMTP id x14-20020a05622a000e00b00429bb886f1emr252029qtw.118.1704926727080; Wed, 10 Jan 2024 14:45:27 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.45.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:45:26 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 11/38] target/alpha: Use TCG_COND_TSTNE for gen_fold_mzero Date: Thu, 11 Jan 2024 09:43:41 +1100 Message-Id: <20240110224408.10444-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::832; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x832.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/alpha/translate.c | 49 +++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/target/alpha/translate.c b/target/alpha/translate.c index c7daf46de7..c68c2bcd21 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -490,56 +490,53 @@ static DisasJumpType gen_bcond(DisasContext *ctx, TCGCond cond, int ra, /* Fold -0.0 for comparison with COND. */ -static void gen_fold_mzero(TCGCond cond, TCGv dest, TCGv src) +static TCGv_i64 gen_fold_mzero(TCGCond *pcond, uint64_t *pimm, TCGv_i64 src) { - uint64_t mzero = 1ull << 63; + TCGv_i64 tmp; - switch (cond) { + *pimm = 0; + switch (*pcond) { case TCG_COND_LE: case TCG_COND_GT: /* For <= or >, the -0.0 value directly compares the way we want. */ - tcg_gen_mov_i64(dest, src); - break; + return src; case TCG_COND_EQ: case TCG_COND_NE: - /* For == or !=, we can simply mask off the sign bit and compare. */ - tcg_gen_andi_i64(dest, src, mzero - 1); - break; + /* For == or !=, we can compare without the sign bit. */ + *pcond = *pcond == TCG_COND_EQ ? TCG_COND_TSTEQ : TCG_COND_TSTNE; + *pimm = INT64_MAX; + return src; case TCG_COND_GE: case TCG_COND_LT: /* For >= or <, map -0.0 to +0.0. */ - tcg_gen_movcond_i64(TCG_COND_NE, dest, src, tcg_constant_i64(mzero), - src, tcg_constant_i64(0)); - break; + tmp = tcg_temp_new_i64(); + tcg_gen_movcond_i64(TCG_COND_EQ, tmp, + src, tcg_constant_i64(INT64_MIN), + tcg_constant_i64(0), src); + return tmp; default: - abort(); + g_assert_not_reached(); } } static DisasJumpType gen_fbcond(DisasContext *ctx, TCGCond cond, int ra, int32_t disp) { - TCGv cmp_tmp = tcg_temp_new(); - DisasJumpType ret; - - gen_fold_mzero(cond, cmp_tmp, load_fpr(ctx, ra)); - ret = gen_bcond_internal(ctx, cond, cmp_tmp, 0, disp); - return ret; + uint64_t imm; + TCGv_i64 tmp = gen_fold_mzero(&cond, &imm, load_fpr(ctx, ra)); + return gen_bcond_internal(ctx, cond, tmp, imm, disp); } static void gen_fcmov(DisasContext *ctx, TCGCond cond, int ra, int rb, int rc) { - TCGv_i64 va, vb, z; - - z = load_zero(ctx); - vb = load_fpr(ctx, rb); - va = tcg_temp_new(); - gen_fold_mzero(cond, va, load_fpr(ctx, ra)); - - tcg_gen_movcond_i64(cond, dest_fpr(ctx, rc), va, z, vb, load_fpr(ctx, rc)); + uint64_t imm; + TCGv_i64 tmp = gen_fold_mzero(&cond, &imm, load_fpr(ctx, ra)); + tcg_gen_movcond_i64(cond, dest_fpr(ctx, rc), + tmp, tcg_constant_i64(imm), + load_fpr(ctx, rb), load_fpr(ctx, rc)); } #define QUAL_RM_N 0x080 /* Round mode nearest even */ From patchwork Wed Jan 10 22:43:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761481 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2112703wrz; Wed, 10 Jan 2024 14:47:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IGMN1NHGrjUJAIfqvg8G+taU9Y43nDgIfuandfmOX/7CBwJXJVd25+s7aBXfpSsTjbAPvqd X-Received: by 2002:a05:6808:1390:b0:3bd:3b0b:c655 with SMTP id c16-20020a056808139000b003bd3b0bc655mr373416oiw.15.1704926852882; Wed, 10 Jan 2024 14:47:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926852; cv=none; d=google.com; s=arc-20160816; b=EwgdsmRohdeqzCsuA26WkO/Ni6NZDhqNgMHBGwp4A1gtwFptRPHZI7Td44U36g00nO rgW4S3UICodqHCAupP9HKSv9rQU1aGPvqD2RFcU6dbXktt1PNapWft7cY/YzJ9rgTGZA to/jgWS11IgS+zmG7/+/wnZWCh2Gm3Bn18cINr4z7KLl3oNOtjANpYTUp52+699dO5jG wUklvO7MejhBF3oyJJGbk9q7J92OLRgXk21AyRogWdyLczLrwzqmcm73He15F4eXOfpG YIaxLripkqLoJ93RguA2FeihVCyOxPmbb38DPVKcs8J4G84U9IRfcENBXbSTAP4GfTeB 9c9A== 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=9Wfu8qLoAolc0Teqm8g6ViWX6SdHYrms61Q6QJWJ8CE=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=zsoRB1YQq2achQni9M7rVidcZF6kBPoI2B36AjzCv4xP12IqzlRQz6q8IpThe9lGEZ i9zMax/uZfTr4qUEbGky/JRQ/Mtb5tiNsAyOy0ekMiOkqgg+SvgFi3nrG5iEIgfiEsx0 uC8Q4gRUHawGlC3wa7McYtE1sXiVmdnUOh2HcsYmsicPMPZjgHdM0lRRM15NRZuwBh0c 8w5zGX92i5E1eGTmm3qo6bbGVAI/+MDYNBccX+yBD3FD46fKbmu1HAihN41+tGE1gmEo KOQf78hcBkbFZJqjb59xHHwSfopwd+9uvS/0CEzMe+IERRblTW0AMvEewRpKoLhCTRkV M1Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GIEQAiSh; 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=fail (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 b25-20020a0c9b19000000b0067f96ff70f2si5191277qve.346.2024.01.10.14.47.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:47:32 -0800 (PST) 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=fail header.i=@linaro.org header.s=google header.b=GIEQAiSh; 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=fail (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 1rNhKj-0005np-Im; Wed, 10 Jan 2024 17:46:01 -0500 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 1rNhKK-00057C-Cy for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:38 -0500 Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhKG-0002xF-8K for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:34 -0500 Received: by mail-qt1-x835.google.com with SMTP id d75a77b69052e-42998e38716so16949541cf.0 for ; Wed, 10 Jan 2024 14:45:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926730; x=1705531530; 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=9Wfu8qLoAolc0Teqm8g6ViWX6SdHYrms61Q6QJWJ8CE=; b=GIEQAiShYlkwY6mR3myTLpdadbeEWUYIVBAzM5/tYt0DZuKPxDfaQ1jG+QNfU11Ga1 wpXMEL+cr9C5vkAx66sdWqT/nfLpSyeRteGXyYbMX0zcauGngOVOJQWcGF06sPNl7vpY bjAKvqPHwQ40mf6Os5p0j1AOSPg+X13aoba+LlyF0TEtphXb6bVwhdwyx1VsPdj1q4f3 VFO7s6pnvMqvH8xbOrwIFr8g3kPoZMu5svsjQeqyUdmlWDR8JE0Vj4wyWbBWbvDQNva7 pvtAkfD+KsqYKsYDKT/RSFlju889yOL6Tvr3Ju6SzPX9J4xFpi4epyJaW3PVSVCY/ALy 39nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926730; x=1705531530; 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=9Wfu8qLoAolc0Teqm8g6ViWX6SdHYrms61Q6QJWJ8CE=; b=Bz4x0NkiD8CXQldbe4V3xHcIpq7gcAoGu6UVoz7xjPWdB2aDv3Z9hglXhHkpnH8jXN 8y3M8oLjBOvIHso9LopmRuHJPjUkkAd21AV4o5jKnGKSlcYEvpbB2gJCQuCwriK0RGex p2GAD3yma7zYpln4Rl5e1FmCMWadixa+BMtJGdNr2muaVuKIu2H5+E78lgUELxmn7ci1 +x2hsdct+0RNcg/+w6Xib/0yNR7ObziJzgnzhQntihh/keCa7ksFJOYz1qLZY+U0QMgZ lvdapbMCmywmV4TZawxCJEu927ivASJHzOjs8C7X4RfiBqbyVsjDLm/kUoxGLxdgmkA0 h/vA== X-Gm-Message-State: AOJu0YyOZXX/NWVxENRhtkPlIrAqLwk0E2DShTP0Vrt4+6nd5RQpxaIK A/FhgNGcjeVSpSji8zlvAI2aQuOOS8RLM5fCCHNXmzYKxNiAg1ID X-Received: by 2002:a05:622a:11cb:b0:429:b971:593c with SMTP id n11-20020a05622a11cb00b00429b971593cmr302151qtk.9.1704926730574; Wed, 10 Jan 2024 14:45:30 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.45.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:45:30 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 12/38] target/m68k: Use TCG_COND_TST{EQ, NE} in gen_fcc_cond Date: Thu, 11 Jan 2024 09:43:42 +1100 Message-Id: <20240110224408.10444-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::835; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x835.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/m68k/translate.c | 74 ++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 41 deletions(-) diff --git a/target/m68k/translate.c b/target/m68k/translate.c index 4a0b0b2703..f30b92f2d4 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -5129,46 +5129,44 @@ undef: static void gen_fcc_cond(DisasCompare *c, DisasContext *s, int cond) { TCGv fpsr; + int imm = 0; - c->v2 = tcg_constant_i32(0); /* TODO: Raise BSUN exception. */ fpsr = tcg_temp_new(); gen_load_fcr(s, fpsr, M68K_FPSR); + c->v1 = fpsr; + switch (cond) { case 0: /* False */ case 16: /* Signaling False */ - c->v1 = c->v2; c->tcond = TCG_COND_NEVER; break; case 1: /* EQual Z */ case 17: /* Signaling EQual Z */ - c->v1 = tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_Z); - c->tcond = TCG_COND_NE; + imm = FPSR_CC_Z; + c->tcond = TCG_COND_TSTNE; break; case 2: /* Ordered Greater Than !(A || Z || N) */ case 18: /* Greater Than !(A || Z || N) */ - c->v1 = tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, - FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N); - c->tcond = TCG_COND_EQ; + imm = FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N; + c->tcond = TCG_COND_TSTEQ; break; case 3: /* Ordered Greater than or Equal Z || !(A || N) */ case 19: /* Greater than or Equal Z || !(A || N) */ c->v1 = tcg_temp_new(); tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A); tcg_gen_shli_i32(c->v1, c->v1, ctz32(FPSR_CC_N) - ctz32(FPSR_CC_A)); - tcg_gen_andi_i32(fpsr, fpsr, FPSR_CC_Z | FPSR_CC_N); tcg_gen_or_i32(c->v1, c->v1, fpsr); tcg_gen_xori_i32(c->v1, c->v1, FPSR_CC_N); - c->tcond = TCG_COND_NE; + imm = FPSR_CC_Z | FPSR_CC_N; + c->tcond = TCG_COND_TSTNE; break; case 4: /* Ordered Less Than !(!N || A || Z); */ case 20: /* Less Than !(!N || A || Z); */ c->v1 = tcg_temp_new(); tcg_gen_xori_i32(c->v1, fpsr, FPSR_CC_N); - tcg_gen_andi_i32(c->v1, c->v1, FPSR_CC_N | FPSR_CC_A | FPSR_CC_Z); - c->tcond = TCG_COND_EQ; + imm = FPSR_CC_N | FPSR_CC_A | FPSR_CC_Z; + c->tcond = TCG_COND_TSTEQ; break; case 5: /* Ordered Less than or Equal Z || (N && !A) */ case 21: /* Less than or Equal Z || (N && !A) */ @@ -5176,49 +5174,45 @@ static void gen_fcc_cond(DisasCompare *c, DisasContext *s, int cond) tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A); tcg_gen_shli_i32(c->v1, c->v1, ctz32(FPSR_CC_N) - ctz32(FPSR_CC_A)); tcg_gen_andc_i32(c->v1, fpsr, c->v1); - tcg_gen_andi_i32(c->v1, c->v1, FPSR_CC_Z | FPSR_CC_N); - c->tcond = TCG_COND_NE; + imm = FPSR_CC_Z | FPSR_CC_N; + c->tcond = TCG_COND_TSTNE; break; case 6: /* Ordered Greater or Less than !(A || Z) */ case 22: /* Greater or Less than !(A || Z) */ - c->v1 = tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A | FPSR_CC_Z); - c->tcond = TCG_COND_EQ; + imm = FPSR_CC_A | FPSR_CC_Z; + c->tcond = TCG_COND_TSTEQ; break; case 7: /* Ordered !A */ case 23: /* Greater, Less or Equal !A */ - c->v1 = tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A); - c->tcond = TCG_COND_EQ; + imm = FPSR_CC_A; + c->tcond = TCG_COND_TSTEQ; break; case 8: /* Unordered A */ case 24: /* Not Greater, Less or Equal A */ - c->v1 = tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A); - c->tcond = TCG_COND_NE; + imm = FPSR_CC_A; + c->tcond = TCG_COND_TSTNE; break; case 9: /* Unordered or Equal A || Z */ case 25: /* Not Greater or Less then A || Z */ - c->v1 = tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A | FPSR_CC_Z); - c->tcond = TCG_COND_NE; + imm = FPSR_CC_A | FPSR_CC_Z; + c->tcond = TCG_COND_TSTNE; break; case 10: /* Unordered or Greater Than A || !(N || Z)) */ case 26: /* Not Less or Equal A || !(N || Z)) */ c->v1 = tcg_temp_new(); tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_Z); tcg_gen_shli_i32(c->v1, c->v1, ctz32(FPSR_CC_N) - ctz32(FPSR_CC_Z)); - tcg_gen_andi_i32(fpsr, fpsr, FPSR_CC_A | FPSR_CC_N); tcg_gen_or_i32(c->v1, c->v1, fpsr); tcg_gen_xori_i32(c->v1, c->v1, FPSR_CC_N); - c->tcond = TCG_COND_NE; + imm = FPSR_CC_A | FPSR_CC_N; + c->tcond = TCG_COND_TSTNE; break; case 11: /* Unordered or Greater or Equal A || Z || !N */ case 27: /* Not Less Than A || Z || !N */ c->v1 = tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N); - tcg_gen_xori_i32(c->v1, c->v1, FPSR_CC_N); - c->tcond = TCG_COND_NE; + tcg_gen_xori_i32(c->v1, fpsr, FPSR_CC_N); + imm = FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N; + c->tcond = TCG_COND_TSTNE; break; case 12: /* Unordered or Less Than A || (N && !Z) */ case 28: /* Not Greater than or Equal A || (N && !Z) */ @@ -5226,27 +5220,25 @@ static void gen_fcc_cond(DisasCompare *c, DisasContext *s, int cond) tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_Z); tcg_gen_shli_i32(c->v1, c->v1, ctz32(FPSR_CC_N) - ctz32(FPSR_CC_Z)); tcg_gen_andc_i32(c->v1, fpsr, c->v1); - tcg_gen_andi_i32(c->v1, c->v1, FPSR_CC_A | FPSR_CC_N); - c->tcond = TCG_COND_NE; + imm = FPSR_CC_A | FPSR_CC_N; + c->tcond = TCG_COND_TSTNE; break; case 13: /* Unordered or Less or Equal A || Z || N */ case 29: /* Not Greater Than A || Z || N */ - c->v1 = tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N); - c->tcond = TCG_COND_NE; + imm = FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N; + c->tcond = TCG_COND_TSTNE; break; case 14: /* Not Equal !Z */ case 30: /* Signaling Not Equal !Z */ - c->v1 = tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_Z); - c->tcond = TCG_COND_EQ; + imm = FPSR_CC_Z; + c->tcond = TCG_COND_TSTEQ; break; case 15: /* True */ case 31: /* Signaling True */ - c->v1 = c->v2; c->tcond = TCG_COND_ALWAYS; break; } + c->v2 = tcg_constant_i32(imm); } static void gen_fjmpcc(DisasContext *s, int cond, TCGLabel *l1) From patchwork Wed Jan 10 22:43:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761470 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2112366wrz; Wed, 10 Jan 2024 14:46:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IGn2zOCSv94PcMHvln6YZahS0HEGb6e1NVrO3JB5x2HkUShX8q6ILOgBdY13nKgA6r+DhvK X-Received: by 2002:a05:6808:3c8c:b0:3bd:4d43:47de with SMTP id gs12-20020a0568083c8c00b003bd4d4347demr620098oib.117.1704926780596; Wed, 10 Jan 2024 14:46:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926780; cv=none; d=google.com; s=arc-20160816; b=a3iL9iYRnYg767D1ZGuo29Qlh2rpsHPPS3aXMKg0Dj+S3mhjZd6HjfAwwkjQM+jeV5 3KfeFxx5GbbQgNj4m97/yatyeIg2qAXhkP5+QGvVmPb7YDM9pL5kOMFNk5fo8zrqu6zK 8J7kecCoPK+hCNeKa7nv3vfzYQ96R/alWHtq4HHncLSgUKyc51LESI+AKltUqh2Xjm1w 0JH2WQgu8yzXStojhoSQx2NpYwLfH8MDDhCJWNasMzyal/nSFfJePWx/jCDv8d535l1M xh/XpmyZsufE+KAwin72nox7PIcsISuZPriqfHoJPJjH+h6b+TYi/12xasRa0+l6ZjLw QS4g== 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=wsZxMo/6G0y0rb+He/biAv9zUFttsowRzurXqIiQz9A=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=JBddGNzXJpfeuQQJqHrg+o//lpLysNtsH9QKHSITU8ZYgvlje0JIikX6dR6fZwU5ot t0QhZxvVGMIa0shCAzcrs+Bnr6YU3u6mzR8Zat7sdcBCzJCmLYabcjIWa7UU6oXTzS4G +dz87bzKszXAByBNGI6Ya0zYoTvD0lV+T0OIktwEsn+eXV3aKzxrBIW1D92ge7ll8JuS ngoOudn+TEr0e6kd6tsyQxQL69YkvdV2AzZnJogOF9Er4PNb0WpxXT8ZJSS3TgqBBek8 orCuIdQW2CkZooLBCtfDhWIcv3Y/IQBry8SZthco7XZSrRgJos8z/L3BtRzumGZgahgN DXlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vQ+JaNl2; 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 ow40-20020a05620a822800b007831c391243si4704139qkn.417.2024.01.10.14.46.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:46:20 -0800 (PST) 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=vQ+JaNl2; 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 1rNhKy-0006Js-Rv; Wed, 10 Jan 2024 17:46:17 -0500 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 1rNhKM-0005CK-Df for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:43 -0500 Received: from mail-yb1-xb29.google.com ([2607:f8b0:4864:20::b29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhKK-0002xy-0t for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:37 -0500 Received: by mail-yb1-xb29.google.com with SMTP id 3f1490d57ef6-dbed0710c74so3834664276.1 for ; Wed, 10 Jan 2024 14:45:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926734; x=1705531534; 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=wsZxMo/6G0y0rb+He/biAv9zUFttsowRzurXqIiQz9A=; b=vQ+JaNl2RX6wyQm1u0IhanRh6R2n6t3DSV1N+3IK65zZVt5UKmLrjiBDO+7O2srNxe 6fshd4wFe6hsHU+348QWaUsV/9onijEOU1EdozwGW61y/P6JAltwYytSrTR7eEK4b28W Cu2/ZAiXcIcTB+Q3iYcmCafj++bQCG57y6ZYC2E54iZ4A9Uj6uVEW+6PEpXcx/clH2/9 2mOd5nKa8OtsR6yHwTlGgrLQvSYkpHiZ/bdv1lCughJX8bj9TsQVQ6vAuEyCkFXc82e6 BmpatWqBcukry4nDcJbcUbFMzbRQv0h8IZ2yrYFMkrRFGefmwt8TcnatXmY8QAUmsYwq k+qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926734; x=1705531534; 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=wsZxMo/6G0y0rb+He/biAv9zUFttsowRzurXqIiQz9A=; b=Y0hxBMpv4TxEWRmxxkaLWx8jqVLZMAGP2mQ7WTxRnk4AqlvdVorvWkC+IRFBh8XpB8 NEeymgFIljiqw+qyovpuQKm/DD6Wg3IKuhKAkyw0Imjh1Ig6eV6/qYxw9VTtu2KFO0LX Rfh3Q5Bxps8xpTt6HCCzRqLKhpwFEP3u+KXip5IXM1tFZXgfQisT64faO7etXXInRcfu xsPqbtxDHTeheO6P1pcivYbXiXlwpTN0pKkhzRfdgGbQlpd3C5KpAu5n+EQu7SoB9iDR /aBwOgKwrAatq2J3O20i6JJnIYO9KMb0d69FyTuqUG3+hYoxYQAnyyIitVo1cZFQDvUc c6vg== X-Gm-Message-State: AOJu0YyxsH4CCsANOKYhROteQ1BQ9Uf2jGAvJyMq+jPLHNNCBpCUoI5b wuQfqRgIfbcMAm5UnL4oIz6pZBHj3XCa/tHN3eUX8aWLaftmtLkc X-Received: by 2002:a25:9701:0:b0:db7:dacf:59ce with SMTP id d1-20020a259701000000b00db7dacf59cemr345588ybo.66.1704926733978; Wed, 10 Jan 2024 14:45:33 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.45.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:45:33 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 13/38] target/sparc: Use TCG_COND_TSTEQ in gen_op_mulscc Date: Thu, 11 Jan 2024 09:43:43 +1100 Message-Id: <20240110224408.10444-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::b29; envelope-from=richard.henderson@linaro.org; helo=mail-yb1-xb29.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/sparc/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 9387299559..b96633dde1 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -506,6 +506,7 @@ static void gen_op_subccc(TCGv dst, TCGv src1, TCGv src2) static void gen_op_mulscc(TCGv dst, TCGv src1, TCGv src2) { TCGv zero = tcg_constant_tl(0); + TCGv one = tcg_constant_tl(1); TCGv t_src1 = tcg_temp_new(); TCGv t_src2 = tcg_temp_new(); TCGv t0 = tcg_temp_new(); @@ -517,8 +518,7 @@ static void gen_op_mulscc(TCGv dst, TCGv src1, TCGv src2) * if (!(env->y & 1)) * src2 = 0; */ - tcg_gen_andi_tl(t0, cpu_y, 0x1); - tcg_gen_movcond_tl(TCG_COND_EQ, t_src2, t0, zero, zero, t_src2); + tcg_gen_movcond_tl(TCG_COND_TSTEQ, t_src2, cpu_y, one, zero, t_src2); /* * b2 = src1 & 1; From patchwork Wed Jan 10 22:43:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761489 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2113025wrz; Wed, 10 Jan 2024 14:48:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFYKTRTu4AQZmdUGPFbGwq6kQYTqUiAlll7bYjkp6aS0ECE3HTLlgxWOSu7nq96mu+p1tGn X-Received: by 2002:a05:620a:1985:b0:783:22b2:7bb8 with SMTP id bm5-20020a05620a198500b0078322b27bb8mr421954qkb.17.1704926913946; Wed, 10 Jan 2024 14:48:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926913; cv=none; d=google.com; s=arc-20160816; b=Vl1UPWeMaFifMH7nikW/Re0uvMA+OP39bWO+tw77N5k1zY5wJKTKLU7DbBkQ4EiLFm JcoI4TMdKM1h1VPCYtm0uVtGVBrVLiRD38bnv7035PL2RWfJeDK/3zDAGjQ9ZcUkPs7A qCWMYhmEG2DlLeG3GE0KzmVM3YQnPqOUKcBbbxwDpd1V2dG0ynb7TS9bN6WsV82OAiBU jGDkrmfnD6lNRgQgxMTbxDorFgiWIyXx1YteZOPIK7x4JwW9DSEXUvUq02ZmXoFikLOd BpfT5WX/kKA1VRaRh9h9lRpgkjTMqBHm2IRAYiZhqXpqs9csei3WXma+0GV2ukEaVrF/ FzPQ== 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=GS3d6Cpw6XkPNpi2NrfgOHaZo+XrWfNCNBnXScIVqj4=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=loq7EBvBpGGfBLn4e44L57009TUmx5BToAEpnLFoQeFABECbLTZcQ0MrHf93+68SI1 JreDSWm9ILhUhyv7Kl8pcP1q2hu3zbEerAXXbt+x6QGOiOdgbN4L2+4Gy4PRzTkIE3vs QUHdTkkh43Cviv1t9zU2Qqnnlods5Vc+p4Ar7VU8ka/RLDOL0Rkbj0N2hdZA9gSGe2sb w86YySoKX9MP9WgZ/DXTeBtidb6wcOC1IotLxn/OjkBHEAS1I0w6zwYqGWTf20A7tZr1 joi1ly/eWln9XE0UyukNyj40OXPav4MNRE1I1dHm9Mg3s66PCJKzIXB1hlmg40cZ9HVr JX9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CSuLkcff; 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 ow30-20020a05620a821e00b00781c84227aesi4719210qkn.54.2024.01.10.14.48.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:48:33 -0800 (PST) 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=CSuLkcff; 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 1rNhKi-0005i7-S3; Wed, 10 Jan 2024 17:46:01 -0500 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 1rNhKO-0005CW-0A for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:45 -0500 Received: from mail-yw1-x1133.google.com ([2607:f8b0:4864:20::1133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhKM-0002zf-D6 for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:39 -0500 Received: by mail-yw1-x1133.google.com with SMTP id 00721157ae682-5f15a1052b3so43127777b3.1 for ; Wed, 10 Jan 2024 14:45:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926737; x=1705531537; 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=GS3d6Cpw6XkPNpi2NrfgOHaZo+XrWfNCNBnXScIVqj4=; b=CSuLkcffE1w0jEfbGW+l9lSjqdI4AYilwWYX4SqqKF9eyHUK3XxcNL9K2HWnQ47ma/ uOeVhjOD+X3luj4j0VE0RBoEx3zOsKYusTi4VxxA5HUGgvK9+DFSE82KwF07mksHKH7E jrVgCKKPD5WMUKbGIRtx4OM/pzZXvPA1JgCKsHV+w5YR6z0ZKFDHGfjkub+Hac88GFpe 3TD+kAOpo6TLBX63hjnsV18fOyRGTMSapXOcG6rAv+SZMT6aWUTLaeuLS3Gi7EcDdSXS m2F/LlEAAYa0a8tTYVJdS5Vrxk+w7q+oPTO8ej/XFw51rIdurTXbi6h2B1SbylwH2PFi WNXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926737; x=1705531537; 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=GS3d6Cpw6XkPNpi2NrfgOHaZo+XrWfNCNBnXScIVqj4=; b=EXV46sPnAJwQ0ScJ9PlkE5yZejOtQYQhooex1NYkdhypW4OFwiUQQAxxdAu6uwYVwr dDFJOKgvHwTluAEzRdWzWJ2jMLmryAvxMsFCb2qjCVvH4hfp8Bcu+El3/O6Y7nAckKEQ bhAwbICZV7rjFcND7lPuoy8IiPt2L5RN35hpnPct1+fCg+0h1W/SYQF8ypYyJqWMpksC w8M+Lc+hAj43OleyLs31URXO/QCsJ3oLMWd6RguFv+Yvfu62znIaAuPCTcrD39rSJz4k AYFm2hE03T4hpVgh9/ZEq6/fM/tvjWenH9cnVkHoGlZWAk7HOD6S3mYeaADR7/TH1Mh1 7Obw== X-Gm-Message-State: AOJu0YxjKKvhDRpnvaNsUiEG3AJCKua4jBV051y90nKDc6UeoOHCcHh+ OpDsiEf2NmYT7nZfvZ7BUG3mxOXvR3TReUxJCg4OazbDskDivsjU X-Received: by 2002:a25:bdc3:0:b0:db7:dacf:3f9c with SMTP id g3-20020a25bdc3000000b00db7dacf3f9cmr307624ybk.73.1704926737416; Wed, 10 Jan 2024 14:45:37 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.45.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:45:37 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 14/38] target/s390x: Use TCG_COND_TSTNE for CC_OP_{TM,ICM} Date: Thu, 11 Jan 2024 09:43:44 +1100 Message-Id: <20240110224408.10444-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1133; envelope-from=richard.henderson@linaro.org; helo=mail-yw1-x1133.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, T_SCC_BODY_TEXT_LINE=-0.01 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 These are all test-and-compare type instructions. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/s390x/tcg/translate.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c index 62ab2be8b1..ae4e7b27ec 100644 --- a/target/s390x/tcg/translate.c +++ b/target/s390x/tcg/translate.c @@ -754,10 +754,10 @@ static void disas_jcc(DisasContext *s, DisasCompare *c, uint32_t mask) case CC_OP_TM_64: switch (mask) { case 8: - cond = TCG_COND_EQ; + cond = TCG_COND_TSTEQ; break; case 4 | 2 | 1: - cond = TCG_COND_NE; + cond = TCG_COND_TSTNE; break; default: goto do_dynamic; @@ -768,11 +768,11 @@ static void disas_jcc(DisasContext *s, DisasCompare *c, uint32_t mask) case CC_OP_ICM: switch (mask) { case 8: - cond = TCG_COND_EQ; + cond = TCG_COND_TSTEQ; break; case 4 | 2 | 1: case 4 | 2: - cond = TCG_COND_NE; + cond = TCG_COND_TSTNE; break; default: goto do_dynamic; @@ -854,18 +854,14 @@ static void disas_jcc(DisasContext *s, DisasCompare *c, uint32_t mask) c->u.s64.a = cc_dst; c->u.s64.b = tcg_constant_i64(0); break; + case CC_OP_LTGT_64: case CC_OP_LTUGTU_64: - c->u.s64.a = cc_src; - c->u.s64.b = cc_dst; - break; - case CC_OP_TM_32: case CC_OP_TM_64: case CC_OP_ICM: - c->u.s64.a = tcg_temp_new_i64(); - c->u.s64.b = tcg_constant_i64(0); - tcg_gen_and_i64(c->u.s64.a, cc_src, cc_dst); + c->u.s64.a = cc_src; + c->u.s64.b = cc_dst; break; case CC_OP_ADDU: From patchwork Wed Jan 10 22:43:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761475 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2112671wrz; Wed, 10 Jan 2024 14:47:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IEcrwMQPYDtC8JfXir4TcpnFIO0zVWJAbUsYdZdN21Ly6oyeInQ5yvxfyn7wvZvveugMJ9a X-Received: by 2002:a05:620a:261b:b0:781:45db:8024 with SMTP id z27-20020a05620a261b00b0078145db8024mr369067qko.53.1704926846891; Wed, 10 Jan 2024 14:47:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926846; cv=none; d=google.com; s=arc-20160816; b=aLxjNxjfcj/tQ40NC/t73EII+Pjm5rZo+itvdLsImw82WpYqvH9o0uOEZxQSA0BavF egmQwk/SKfzkCSqGs/M+OAgbFfPWQrOrLIHYo+IjZ7Hfv0UyaESbsTpSYtRpZ7ABOCXw P3wjZoEo+3RjMCSl5uItGTpwyPTGtrZO2sttKzUNhOY0Eyi+9xto4B/imp10DQyOVxbT ZSaTqk0Gq9ccmFlFUG44dFC5KaDN5+hSvT7Iym0JfDCrSN1PK/coLpRQyPrF/us46Kdk 3oYUoiGvf4ZmDcrzqpLIjRkpUP0hOi0t5fUIbGw06/y/WkQ4lwMa/iTqD+meZYtv3EQx GFxg== 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=W1dg8xzeToyJ1noTdWjMrmUW84nILSKxoDBHRkIKi/4=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=mSpA1fNdgOlEvU6SUShUdZaPYUrk30lWOe6w9pov2iCkwOzjsa5I+b0xJelXUj2CSK ytojuZpGleH6Hy8qMAyKUM9lmVYY1vt/rFA3PhVizei+XdChFaMtMFiI5hSGqwKI9Bho MXGXwFH8jSimhO1EtasLwfW03yeSBQv4IQlFC3sRBt1BzMj4BrNuzhXr3TLQv5EdS6Iy txTn8hopZ6FQ/NtKwBHufNk4+TM6XRDGlascKd+cBHL1ovititeu1uK0tPQ2Ikf621LI 4riQPpbZb6WsQXdVgIXhsytqGjM35GJmoaw/Eq7KbAz53/Bon62ll2os715VQAuWwFZW 9Cqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y8W+Kznk; 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 bk10-20020a05620a1a0a00b0078153cbf56fsi5275353qkb.607.2024.01.10.14.47.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:47:26 -0800 (PST) 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=y8W+Kznk; 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 1rNhL5-0006YN-IC; Wed, 10 Jan 2024 17:46:28 -0500 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 1rNhKZ-0005Qp-QI for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:53 -0500 Received: from mail-yw1-x1129.google.com ([2607:f8b0:4864:20::1129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhKT-00030o-F3 for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:48 -0500 Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-5f0629e67f4so50746747b3.3 for ; Wed, 10 Jan 2024 14:45:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926741; x=1705531541; 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=W1dg8xzeToyJ1noTdWjMrmUW84nILSKxoDBHRkIKi/4=; b=y8W+KznkA0ezg3TXvvFhc4Dd561fTajwAC6NpYsxqV+5sjfZSFB6ls9Xbo0jElOBK/ zH96kX6tatdM/H+oV2CWmEKC9sziXVJPHQ7WDB30BHMeEziw7AhPO8haVBv8ItPimvBL fKM1dl1oTCMAxkYB29tvT2oAAeQUnGfRoFXB8jQbGxY4jgjE0ukxgT9J8dbyCIL3ULvV VOZzgo4xE3BTebdSzJiBndBR71znxLhSswU2A6+Za4mypvf8G9Tq/bOks5Q5PfrxBNnQ 2afB0Bqt2mDH8aCRotn806y6oIH00DALln25BDD3hnJo9hrcjuRyDdj3ziAmHInb58ra kv/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926741; x=1705531541; 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=W1dg8xzeToyJ1noTdWjMrmUW84nILSKxoDBHRkIKi/4=; b=TVAoha9K7Ix3p3eVdqe4jxi5uIz2MrlL8Bd2ZqyCU5Ax8QkFRDIxQKX1P4GDsJX2qh R24/nWWk5szAXdjXZ7/0dOHbPg/coybwJFl7YrFPNHIsgnP2yjA6GWY9SRXkxHNAU8z8 Axdxr/XwXUZn3+pulzjCxCHU3sdWatstALxQPSIDTwQPr0lsDNPqKl+9XeOHLXdtyXNW n8HbvM947BqG6A2ToVHmo9oHz0mgbcGp3Z1IuIGeKwSmzYPYCU7E4/8oPidgrJFwUtNQ E3K60FJijWyNr7hqYoZGIFrqIB91z3p0urm8kywCT92N3BdFyO9AjHSYV971ueo8DgpV 3ZWA== X-Gm-Message-State: AOJu0YzW5X3G3fKG12lx96sTJoZ71/id75xIm17u7xAIW+zzaZyv0VFu lgeiqm7P5aivAF/jz35A3dKxIS6VCH7zjZQA3SQzsHURz+7BK911 X-Received: by 2002:a81:57c3:0:b0:5ee:a910:107 with SMTP id l186-20020a8157c3000000b005eea9100107mr364594ywb.21.1704926741409; Wed, 10 Jan 2024 14:45:41 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.45.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:45:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 15/38] target/s390x: Improve general case of disas_jcc Date: Thu, 11 Jan 2024 09:43:45 +1100 Message-Id: <20240110224408.10444-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1129; envelope-from=richard.henderson@linaro.org; helo=mail-yw1-x1129.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Avoid code duplication by handling 7 of the 14 cases by inverting the test for the other 7 cases. Use TCG_COND_TSTNE for cc in {1,3}. Use (cc - 1) <= 1 for cc in {1,2}. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/s390x/tcg/translate.c | 82 +++++++++++++----------------------- 1 file changed, 30 insertions(+), 52 deletions(-) diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c index ae4e7b27ec..168974f2e6 100644 --- a/target/s390x/tcg/translate.c +++ b/target/s390x/tcg/translate.c @@ -885,67 +885,45 @@ static void disas_jcc(DisasContext *s, DisasCompare *c, uint32_t mask) case CC_OP_STATIC: c->is_64 = false; c->u.s32.a = cc_op; - switch (mask) { - case 0x8 | 0x4 | 0x2: /* cc != 3 */ - cond = TCG_COND_NE; + + /* Fold half of the cases using bit 3 to invert. */ + switch (mask & 8 ? mask ^ 0xf : mask) { + case 0x1: /* cc == 3 */ + cond = TCG_COND_EQ; c->u.s32.b = tcg_constant_i32(3); break; - case 0x8 | 0x4 | 0x1: /* cc != 2 */ - cond = TCG_COND_NE; - c->u.s32.b = tcg_constant_i32(2); - break; - case 0x8 | 0x2 | 0x1: /* cc != 1 */ - cond = TCG_COND_NE; - c->u.s32.b = tcg_constant_i32(1); - break; - case 0x8 | 0x2: /* cc == 0 || cc == 2 => (cc & 1) == 0 */ - cond = TCG_COND_EQ; - c->u.s32.a = tcg_temp_new_i32(); - c->u.s32.b = tcg_constant_i32(0); - tcg_gen_andi_i32(c->u.s32.a, cc_op, 1); - break; - case 0x8 | 0x4: /* cc < 2 */ - cond = TCG_COND_LTU; - c->u.s32.b = tcg_constant_i32(2); - break; - case 0x8: /* cc == 0 */ - cond = TCG_COND_EQ; - c->u.s32.b = tcg_constant_i32(0); - break; - case 0x4 | 0x2 | 0x1: /* cc != 0 */ - cond = TCG_COND_NE; - c->u.s32.b = tcg_constant_i32(0); - break; - case 0x4 | 0x1: /* cc == 1 || cc == 3 => (cc & 1) != 0 */ - cond = TCG_COND_NE; - c->u.s32.a = tcg_temp_new_i32(); - c->u.s32.b = tcg_constant_i32(0); - tcg_gen_andi_i32(c->u.s32.a, cc_op, 1); - break; - case 0x4: /* cc == 1 */ - cond = TCG_COND_EQ; - c->u.s32.b = tcg_constant_i32(1); - break; - case 0x2 | 0x1: /* cc > 1 */ - cond = TCG_COND_GTU; - c->u.s32.b = tcg_constant_i32(1); - break; case 0x2: /* cc == 2 */ cond = TCG_COND_EQ; c->u.s32.b = tcg_constant_i32(2); break; - case 0x1: /* cc == 3 */ + case 0x4: /* cc == 1 */ cond = TCG_COND_EQ; - c->u.s32.b = tcg_constant_i32(3); + c->u.s32.b = tcg_constant_i32(1); + break; + case 0x2 | 0x1: /* cc == 2 || cc == 3 => cc > 1 */ + cond = TCG_COND_GTU; + c->u.s32.b = tcg_constant_i32(1); + break; + case 0x4 | 0x1: /* cc == 1 || cc == 3 => (cc & 1) != 0 */ + cond = TCG_COND_TSTNE; + c->u.s32.b = tcg_constant_i32(1); + break; + case 0x4 | 0x2: /* cc == 1 || cc == 2 => (cc - 1) <= 1 */ + cond = TCG_COND_LEU; + c->u.s32.a = tcg_temp_new_i32(); + c->u.s32.b = tcg_constant_i32(1); + tcg_gen_addi_i32(c->u.s32.a, cc_op, -1); + break; + case 0x4 | 0x2 | 0x1: /* cc != 0 */ + cond = TCG_COND_NE; + c->u.s32.b = tcg_constant_i32(0); break; default: - /* CC is masked by something else: (8 >> cc) & mask. */ - cond = TCG_COND_NE; - c->u.s32.a = tcg_temp_new_i32(); - c->u.s32.b = tcg_constant_i32(0); - tcg_gen_shr_i32(c->u.s32.a, tcg_constant_i32(8), cc_op); - tcg_gen_andi_i32(c->u.s32.a, c->u.s32.a, mask); - break; + /* case 0: never, handled above. */ + g_assert_not_reached(); + } + if (mask & 8) { + cond = tcg_invert_cond(cond); } break; From patchwork Wed Jan 10 22:43:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761478 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2112686wrz; Wed, 10 Jan 2024 14:47:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IGMgFiU/yWfzRRS0gfJ4yjDMuJtLvRBr3VqCWMts4071T2GZQq33lt6Mi4LWIySoFS33b7v X-Received: by 2002:a05:620a:a0b:b0:783:25ea:b1a5 with SMTP id i11-20020a05620a0a0b00b0078325eab1a5mr357855qka.143.1704926849345; Wed, 10 Jan 2024 14:47:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926849; cv=none; d=google.com; s=arc-20160816; b=nRw/nPLLvzH2UNul7c4N8WxSu4CBR8p+pU9VGyp2Pgo+KRH8OBYC7U7EwQrpl02cZA rycjyuoK3+Y3BNQ3MDRxjgTv9lsgA+GlThiN9G9DznywILAM33Aw/1FEYtEn2bQ5Zf7a qCGwkEgy7wv7i+NUs6rwyVhGA3AX7jSxWsDB1bS+nQypoh0Sk80CRfGPUSN2EqOV7moT xrxm/7O+NQvz6yodFNKZM/bYhST2obD+Oo+beno6LZpiC90D2SOww0i4wfTexkhMyaEs e1bC+il3SSmO1xEkWoCc83vNgh+7pveChTjDTb8gvzgicnfCXVMqE6hCN/3U18DsJpKG YddQ== 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=Yt1amn66GV+70TUwg6QhzJ4YUnpX4UUEzHPNr30u2sg=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=jf+5fC/uf6tlYPbrDkcaY7Bt3c/ti4opOcTkKs5WwhCMT1wXyicmlxTsX5iAkjmbxJ OPA4PVoJS3Vd9urik1tIRoPTzhWzH0OeaVyTs6FT8efvxK319kB1toplksSkutPKCqil Xl88o96i89Y8n/zx0qYXUfsRxee2bBgBjOH45InoH1K03C2pYr4DRuB2uDRoU0iaJGmQ 6NuUPQSFUwHEe2froayMG23TXWe096ietLyj5tnlZtSSN20ZP2XV1BeFKx8FUr4qoxpd GowixwwvXb+mSnUHlpRt1oSTWTFyMNtsnaMS8Xrmb2jFQq7jgPEVfvm9HrCDUFKleXOF ZpEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=diuisTxz; 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 bn8-20020a05620a2ac800b00783343bb312si2511246qkb.379.2024.01.10.14.47.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:47:29 -0800 (PST) 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=diuisTxz; 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 1rNhKm-000643-79; Wed, 10 Jan 2024 17:46:04 -0500 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 1rNhKZ-0005Qq-Rd for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:53 -0500 Received: from mail-qt1-x82c.google.com ([2607:f8b0:4864:20::82c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhKV-00031d-Ha for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:51 -0500 Received: by mail-qt1-x82c.google.com with SMTP id d75a77b69052e-42989a64713so28033661cf.2 for ; Wed, 10 Jan 2024 14:45:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926745; x=1705531545; 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=Yt1amn66GV+70TUwg6QhzJ4YUnpX4UUEzHPNr30u2sg=; b=diuisTxzDDwVBO0OX7VSiNMAE6vO2MxrhyyL+ti+38sfQCSzcHpp1JmMBlRKaPRvGj glFzUS1oyRbgCPoMuUlCJddOzh7Q8z59xFbgApdfuaBpKvl+sJGWYbCd/xw13jQwq84L HJ61Sgu030kUgDqE+B8F40SsSJNftyDUh8/A1U9IOuhxO54V5U1WVobZIglB+FXtkD9Y bbnUkX3DXzhPPQreHYUVW4RYSjLRT3cN/aRIoFQcsKEmQWZWcMDxhQnplsPQjM+W6ZG1 hDXOuFPh0K6uTpcc1ZO+fuCLlAaS9hSvGuy2R6A4Ut4+YRiTeoPcCHxdmTDRoyp0P3Mr COHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926745; x=1705531545; 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=Yt1amn66GV+70TUwg6QhzJ4YUnpX4UUEzHPNr30u2sg=; b=nDodeq5C9sv9Z35B9U49fH6ZLcGXtia6fC4S6ZGaF0+X5B850hhKo20vqoX0gJO/AY sDaGJWEN7cPrFPDX1pwbuvXbyBZYJonVbBNKm92XW/CygDkFEc+mN6C4pO4CnnVrD801 naf6xzd9GF+GeBss0USAQjUzCz+dO1tNZ7pYMcODG+QvJM8O6jCLA7wUqz1ibm2MxiNn fooN1bQti+dtP4twI5UPTWnaLJYWNOkKxPT7JBVXpeAIsy7iDH6/l+iptgiKQiiUbrOX 52pgeXXhIzboxh0wher77rJHUwDJnS4MXD1zrnzAvFhLKFH5PV0Eepz/4mhD6sD+FNMl D6Lg== X-Gm-Message-State: AOJu0YxBBi013PvskuBx64AxCzAIOrQj5dciPlf4q4Gwk0GxTE+yJM5C gnW8DG/vaFzqvvNGUugYbGBSO3nPGZxljQSeZNIeN2eV8TexwvaZ X-Received: by 2002:a05:622a:48:b0:429:8ed0:3e1b with SMTP id y8-20020a05622a004800b004298ed03e1bmr322884qtw.13.1704926744842; Wed, 10 Jan 2024 14:45:44 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.45.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:45:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 16/38] tcg: Add TCGConst argument to tcg_target_const_match Date: Thu, 11 Jan 2024 09:43:46 +1100 Message-Id: <20240110224408.10444-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82c; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82c.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Fill the new argument from any condition within the opcode. Not yet used within any backend. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/tcg.c | 34 ++++++++++++++++++++++++++++++-- tcg/aarch64/tcg-target.c.inc | 3 ++- tcg/arm/tcg-target.c.inc | 3 ++- tcg/i386/tcg-target.c.inc | 3 ++- tcg/loongarch64/tcg-target.c.inc | 3 ++- tcg/mips/tcg-target.c.inc | 3 ++- tcg/ppc/tcg-target.c.inc | 3 ++- tcg/riscv/tcg-target.c.inc | 3 ++- tcg/s390x/tcg-target.c.inc | 3 ++- tcg/sparc64/tcg-target.c.inc | 3 ++- tcg/tci/tcg-target.c.inc | 3 ++- 11 files changed, 52 insertions(+), 12 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 2f4522488a..4169ce89a4 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -173,7 +173,8 @@ static bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target, const TCGHelperInfo *info); static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot); -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int vece); +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece); #ifdef TCG_TARGET_NEED_LDST_LABELS static int tcg_out_ldst_finalize(TCGContext *s); #endif @@ -4786,6 +4787,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) TCGTemp *ts; TCGArg new_args[TCG_MAX_OP_ARGS]; int const_args[TCG_MAX_OP_ARGS]; + TCGCond op_cond; nb_oargs = def->nb_oargs; nb_iargs = def->nb_iargs; @@ -4798,6 +4800,33 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) i_allocated_regs = s->reserved_regs; o_allocated_regs = s->reserved_regs; + switch (op->opc) { + case INDEX_op_brcond_i32: + case INDEX_op_brcond_i64: + op_cond = op->args[2]; + break; + case INDEX_op_setcond_i32: + case INDEX_op_setcond_i64: + case INDEX_op_negsetcond_i32: + case INDEX_op_negsetcond_i64: + case INDEX_op_cmp_vec: + op_cond = op->args[3]; + break; + case INDEX_op_brcond2_i32: + op_cond = op->args[4]; + break; + case INDEX_op_movcond_i32: + case INDEX_op_movcond_i64: + case INDEX_op_setcond2_i32: + case INDEX_op_cmpsel_vec: + op_cond = op->args[5]; + break; + default: + /* No condition within opcode. */ + op_cond = TCG_COND_ALWAYS; + break; + } + /* satisfy input constraints */ for (k = 0; k < nb_iargs; k++) { TCGRegSet i_preferred_regs, i_required_regs; @@ -4811,7 +4840,8 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) ts = arg_temp(arg); if (ts->val_type == TEMP_VAL_CONST - && tcg_target_const_match(ts->val, ts->type, arg_ct->ct, TCGOP_VECE(op))) { + && tcg_target_const_match(ts->val, arg_ct->ct, ts->type, + op_cond, TCGOP_VECE(op))) { /* constant is OK for instruction */ const_args[i] = 1; new_args[i] = ts->val; diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index a3efa1e67a..420e4a35ea 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -270,7 +270,8 @@ static bool is_shimm1632(uint32_t v32, int *cmode, int *imm8) } } -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index fc78566494..0c29a3929b 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -501,7 +501,8 @@ static bool is_shimm1632(uint32_t v32, int *cmode, int *imm8) * mov operand2: values represented with x << (2 * y), x < 0x100 * add, sub, eor...: ditto */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index d268199fc1..accaaa2660 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -195,7 +195,8 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, } /* test if a constant matches the constraint */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index bab0a173a3..076fc8a917 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -183,7 +183,8 @@ static inline tcg_target_long sextreg(tcg_target_long val, int pos, int len) } /* test if a constant matches the constraint */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return true; diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 8328dbdecc..3b5b5c6d5b 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -188,7 +188,8 @@ static bool is_p2m1(tcg_target_long val) } /* test if a constant matches the constraint */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 54816967bc..850ace98b2 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -282,7 +282,8 @@ static bool reloc_pc34(tcg_insn_unit *src_rw, const tcg_insn_unit *target) } /* test if a constant matches the constraint */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 34e10e77d9..639363039b 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -145,7 +145,8 @@ static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) #define sextreg sextract64 /* test if a constant matches the constraint */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc index fbee43d3b0..08fe00a392 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -538,7 +538,8 @@ static bool risbg_mask(uint64_t c) } /* Test if a constant matches the constraint. */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc index a91defd0ac..ac86b92b75 100644 --- a/tcg/sparc64/tcg-target.c.inc +++ b/tcg/sparc64/tcg-target.c.inc @@ -322,7 +322,8 @@ static bool patch_reloc(tcg_insn_unit *src_rw, int type, } /* test if a constant matches the constraint */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc index 461f4b47ff..c740864b96 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -913,7 +913,8 @@ static inline bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, } /* Test if a constant matches the constraint. */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { return ct & TCG_CT_CONST; } From patchwork Wed Jan 10 22:43:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761495 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2113167wrz; Wed, 10 Jan 2024 14:49:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IGIbbe9ILUxXNhs/L9ZRF2K5JytqgXNp+igSYG120TS+o91NXaUaxK10rcgcJECoqVp4XTP X-Received: by 2002:a81:848b:0:b0:5f7:4913:2a2c with SMTP id u133-20020a81848b000000b005f749132a2cmr357588ywf.101.1704926940421; Wed, 10 Jan 2024 14:49:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926940; cv=none; d=google.com; s=arc-20160816; b=dv0Z5XWnVo1Geke69BtmDjDyDqoeZTCEVASA3Luec8XysIoT/3vJaKoDsf8pjj8iyb jmCmFZw+jkEHHpcGytfZ9x0LNE7edPykj6+g9FMY2yWFBiPUdtgIgj6pT9GrMk0sDqoV GifeFSHBIrlWwow2BbIHrit129tOHneh6JTNDCWK17KfEsrtwwWiZe84k088cdNESvAp mi4xUyo3VnO94oxvjxJXadUHOkoPDGhgkPJkNGJIAs30Y0ieYa+Tpnj+cNyJwxRYMsUB 89hkWAPZn9eRnDFNcZAiFvIzhOXgZnVvH6IdsYuJpxe8BZUGWsjElIhpdM4dL6uIn7XG LqoA== 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=07WcNRuELUJbpEJ/6K8AoY3Jv+ERO1K9CGzKIf1CLoc=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=MCogS/iZGcyHqLhawmmNhYgFK5vPsYnpEShLfj/On8RAuwNtwuFvTiTHg8N4NVQtv3 dtViggh2vvYnURJBD8T37rJGy+R4VvVVIgOlsUaTHZi+FxqgjKVGDAKeRgDQFwABWNi9 9o9lrNXusSO15D4H9qwiq/EvzjuCce9R6HWHt7uQSj1VbUnOwmvwLmM3+YF+HFYQbIUn ga8Q45Fz7qarFQY3sUeC6wyJ9bKDdWLyvLwkHOe9y+L9b3WpXJyuvxLb/tiFOUXzgOMI 5iZm+a8809wkNFkfcIUMJHMXD8eKu19aYuGGg0S7xosPEuoTfrKW6GG2gQth0McIOP/I z/gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aSUe76tO; 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 m3-20020a05622a118300b00429bdb4305fsi892935qtk.83.2024.01.10.14.49.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:49:00 -0800 (PST) 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=aSUe76tO; 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 1rNhLV-0008Rz-5C; Wed, 10 Jan 2024 17:46:49 -0500 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 1rNhKb-0005UC-Nc for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:56 -0500 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhKZ-00032X-8Q for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:53 -0500 Received: by mail-qt1-x834.google.com with SMTP id d75a77b69052e-42993124fa1so24149211cf.3 for ; Wed, 10 Jan 2024 14:45:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926748; x=1705531548; 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=07WcNRuELUJbpEJ/6K8AoY3Jv+ERO1K9CGzKIf1CLoc=; b=aSUe76tOcvNkhja7m2qa1giLNVCwqioyJn1z0RiNqTJX7X8hupmUWKBWU+eWz9U/FM P0tlijgnuDO9WQxXy6qiLSenrqIxYsz3hAZStct4myaqdhNKx4cv/XapntoDeZ0nY/8K teOFXPt5dn7Yt2w+5BVYXlmcbyfNGAyOlpUM9xpZt5zOD8RYExouWKJIzucUOpi1BkLY a4xqdljqkO3bhlWcGXz5w37odmwva/LIQ9fivbI7WXGtWTnD0pvj0bnxD03LSNaua+5S yRGxwnM2dpqhStoWENAs//LFq3zrzK97UXghk9c1LaV6XRYsgYEHGA3pICYzc+LABNpK egEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926748; x=1705531548; 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=07WcNRuELUJbpEJ/6K8AoY3Jv+ERO1K9CGzKIf1CLoc=; b=jRXKP+XxzlwdzeOYk0Zrn/3PVDelZFxHOUnuOn7P0ZqCJYGH/fPGi7lHGfRlQPqRim EK0YkAIVDStauw6GM+HmPUMXCd4vNeuke2W+d9bkxpKGRW/fbV+srOAHMkj0d4tEJ+Tp w/WagdJ+9yEUP6ZA9854/HY+roZHbjcKRMfI8DWHSx3t9S+AFsCNGNChlyXOjrG0z2vd yCrxtYggNy61YW661ylteONBEWznAsNrRar/q/flAogkCxqfxY95c1A8xieOidEdNFAK Jdk8HuQR2PY46qtpT40ue3Sk3BYY8ugVYhSf0i1LIMfq2P88IYniDHHIbcalGYxGtm3+ 4S1Q== X-Gm-Message-State: AOJu0YwORVu/TTEaVqk0bDcMYB3Ft99WoH9bBHYWpWO1mjb719SeITNB 0ORrEcWNCoZt+MnlsfpNKmNcQj8vmHeI0cCCAVhkzGIOIacx/+dz X-Received: by 2002:ac8:4e41:0:b0:429:a14e:12bb with SMTP id e1-20020ac84e41000000b00429a14e12bbmr297554qtw.94.1704926748496; Wed, 10 Jan 2024 14:45:48 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.45.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:45:48 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 17/38] tcg/aarch64: Support TCG_COND_TST{EQ,NE} Date: Thu, 11 Jan 2024 09:43:47 +1100 Message-Id: <20240110224408.10444-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::834; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x834.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tcg/aarch64/tcg-target-con-set.h | 5 +-- tcg/aarch64/tcg-target-con-str.h | 1 + tcg/aarch64/tcg-target.h | 2 +- tcg/aarch64/tcg-target.c.inc | 56 ++++++++++++++++++++++---------- 4 files changed, 44 insertions(+), 20 deletions(-) diff --git a/tcg/aarch64/tcg-target-con-set.h b/tcg/aarch64/tcg-target-con-set.h index 3fdee26a3d..44fcc1206e 100644 --- a/tcg/aarch64/tcg-target-con-set.h +++ b/tcg/aarch64/tcg-target-con-set.h @@ -10,7 +10,7 @@ * tcg-target-con-str.h; the constraint combination is inclusive or. */ C_O0_I1(r) -C_O0_I2(r, rA) +C_O0_I2(r, rC) C_O0_I2(rZ, r) C_O0_I2(w, r) C_O0_I3(rZ, rZ, r) @@ -22,6 +22,7 @@ C_O1_I2(r, 0, rZ) C_O1_I2(r, r, r) C_O1_I2(r, r, rA) C_O1_I2(r, r, rAL) +C_O1_I2(r, r, rC) C_O1_I2(r, r, ri) C_O1_I2(r, r, rL) C_O1_I2(r, rZ, rZ) @@ -31,6 +32,6 @@ C_O1_I2(w, w, wN) C_O1_I2(w, w, wO) C_O1_I2(w, w, wZ) C_O1_I3(w, w, w, w) -C_O1_I4(r, r, rA, rZ, rZ) +C_O1_I4(r, r, rC, rZ, rZ) C_O2_I1(r, r, r) C_O2_I4(r, r, rZ, rZ, rA, rMZ) diff --git a/tcg/aarch64/tcg-target-con-str.h b/tcg/aarch64/tcg-target-con-str.h index fb1a845b4f..48e1722c68 100644 --- a/tcg/aarch64/tcg-target-con-str.h +++ b/tcg/aarch64/tcg-target-con-str.h @@ -16,6 +16,7 @@ REGS('w', ALL_VECTOR_REGS) * CONST(letter, TCG_CT_CONST_* bit set) */ CONST('A', TCG_CT_CONST_AIMM) +CONST('C', TCG_CT_CONST_CMP) CONST('L', TCG_CT_CONST_LIMM) CONST('M', TCG_CT_CONST_MONE) CONST('O', TCG_CT_CONST_ORRI) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index b4ac13be7b..ef5ebe91bd 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -138,7 +138,7 @@ typedef enum { #define TCG_TARGET_HAS_qemu_ldst_i128 1 #endif -#define TCG_TARGET_HAS_tst 0 +#define TCG_TARGET_HAS_tst 1 #define TCG_TARGET_HAS_v64 1 #define TCG_TARGET_HAS_v128 1 diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 420e4a35ea..70df250c04 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -126,6 +126,7 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, #define TCG_CT_CONST_MONE 0x800 #define TCG_CT_CONST_ORRI 0x1000 #define TCG_CT_CONST_ANDI 0x2000 +#define TCG_CT_CONST_CMP 0x4000 #define ALL_GENERAL_REGS 0xffffffffu #define ALL_VECTOR_REGS 0xffffffff00000000ull @@ -279,6 +280,15 @@ static bool tcg_target_const_match(int64_t val, int ct, if (type == TCG_TYPE_I32) { val = (int32_t)val; } + + if (ct & TCG_CT_CONST_CMP) { + if (is_tst_cond(cond)) { + ct |= TCG_CT_CONST_LIMM; + } else { + ct |= TCG_CT_CONST_AIMM; + } + } + if ((ct & TCG_CT_CONST_AIMM) && (is_aimm(val) || is_aimm(-val))) { return 1; } @@ -345,6 +355,9 @@ static const enum aarch64_cond_code tcg_cond_to_aarch64[] = { [TCG_COND_GTU] = COND_HI, [TCG_COND_GEU] = COND_HS, [TCG_COND_LEU] = COND_LS, + /* bit test */ + [TCG_COND_TSTEQ] = COND_EQ, + [TCG_COND_TSTNE] = COND_NE, }; typedef enum { @@ -1342,19 +1355,26 @@ static inline void tcg_out_dep(TCGContext *s, TCGType ext, TCGReg rd, tcg_out_bfm(s, ext, rd, rn, a, b); } -static void tcg_out_cmp(TCGContext *s, TCGType ext, TCGReg a, +static void tcg_out_cmp(TCGContext *s, TCGType ext, TCGCond cond, TCGReg a, tcg_target_long b, bool const_b) { - if (const_b) { - /* Using CMP or CMN aliases. */ - if (b >= 0) { - tcg_out_insn(s, 3401, SUBSI, ext, TCG_REG_XZR, a, b); + if (is_tst_cond(cond)) { + if (!const_b) { + tcg_out_insn(s, 3510, ANDS, ext, TCG_REG_XZR, a, b); } else { - tcg_out_insn(s, 3401, ADDSI, ext, TCG_REG_XZR, a, -b); + tcg_debug_assert(is_limm(b)); + tcg_out_logicali(s, I3404_ANDSI, 0, TCG_REG_XZR, a, b); } } else { - /* Using CMP alias SUBS wzr, Wn, Wm */ - tcg_out_insn(s, 3502, SUBS, ext, TCG_REG_XZR, a, b); + if (!const_b) { + tcg_out_insn(s, 3502, SUBS, ext, TCG_REG_XZR, a, b); + } else if (b >= 0) { + tcg_debug_assert(is_aimm(b)); + tcg_out_insn(s, 3401, SUBSI, ext, TCG_REG_XZR, a, b); + } else { + tcg_debug_assert(is_aimm(-b)); + tcg_out_insn(s, 3401, ADDSI, ext, TCG_REG_XZR, a, -b); + } } } @@ -1402,7 +1422,7 @@ static void tcg_out_brcond(TCGContext *s, TCGType ext, TCGCond c, TCGArg a, need_cmp = false; } else { need_cmp = true; - tcg_out_cmp(s, ext, a, b, b_const); + tcg_out_cmp(s, ext, c, a, b, b_const); } if (!l->has_value) { @@ -1575,7 +1595,7 @@ static void tcg_out_cltz(TCGContext *s, TCGType ext, TCGReg d, } else { AArch64Insn sel = I3506_CSEL; - tcg_out_cmp(s, ext, a0, 0, 1); + tcg_out_cmp(s, ext, TCG_COND_NE, a0, 0, 1); tcg_out_insn(s, 3507, CLZ, ext, TCG_REG_TMP0, a1); if (const_b) { @@ -1720,7 +1740,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h, addr_adj, compare_mask); /* Perform the address comparison. */ - tcg_out_cmp(s, addr_type, TCG_REG_TMP0, TCG_REG_TMP2, 0); + tcg_out_cmp(s, addr_type, TCG_COND_NE, TCG_REG_TMP0, TCG_REG_TMP2, 0); /* If not equal, we jump to the slow path. */ ldst->label_ptr[0] = s->code_ptr; @@ -2276,7 +2296,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, a2 = (int32_t)a2; /* FALLTHRU */ case INDEX_op_setcond_i64: - tcg_out_cmp(s, ext, a1, a2, c2); + tcg_out_cmp(s, ext, args[3], a1, a2, c2); /* Use CSET alias of CSINC Wd, WZR, WZR, invert(cond). */ tcg_out_insn(s, 3506, CSINC, TCG_TYPE_I32, a0, TCG_REG_XZR, TCG_REG_XZR, tcg_invert_cond(args[3])); @@ -2286,7 +2306,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, a2 = (int32_t)a2; /* FALLTHRU */ case INDEX_op_negsetcond_i64: - tcg_out_cmp(s, ext, a1, a2, c2); + tcg_out_cmp(s, ext, args[3], a1, a2, c2); /* Use CSETM alias of CSINV Wd, WZR, WZR, invert(cond). */ tcg_out_insn(s, 3506, CSINV, ext, a0, TCG_REG_XZR, TCG_REG_XZR, tcg_invert_cond(args[3])); @@ -2296,7 +2316,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, a2 = (int32_t)a2; /* FALLTHRU */ case INDEX_op_movcond_i64: - tcg_out_cmp(s, ext, a1, a2, c2); + tcg_out_cmp(s, ext, args[5], a1, a2, c2); tcg_out_insn(s, 3506, CSEL, ext, a0, REG0(3), REG0(4), args[5]); break; @@ -2896,11 +2916,13 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_add_i64: case INDEX_op_sub_i32: case INDEX_op_sub_i64: + return C_O1_I2(r, r, rA); + case INDEX_op_setcond_i32: case INDEX_op_setcond_i64: case INDEX_op_negsetcond_i32: case INDEX_op_negsetcond_i64: - return C_O1_I2(r, r, rA); + return C_O1_I2(r, r, rC); case INDEX_op_mul_i32: case INDEX_op_mul_i64: @@ -2950,11 +2972,11 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_brcond_i32: case INDEX_op_brcond_i64: - return C_O0_I2(r, rA); + return C_O0_I2(r, rC); case INDEX_op_movcond_i32: case INDEX_op_movcond_i64: - return C_O1_I4(r, r, rA, rZ, rZ); + return C_O1_I4(r, r, rC, rZ, rZ); case INDEX_op_qemu_ld_a32_i32: case INDEX_op_qemu_ld_a64_i32: From patchwork Wed Jan 10 22:43:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761491 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2113110wrz; Wed, 10 Jan 2024 14:48:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IGCerF/Y0V07WbPwveki1ut3TgyOuCA9k664icbJXIlljBWnDRUV09WgLDmLYZcxpRkTZq/ X-Received: by 2002:ac8:5781:0:b0:429:8a10:e2af with SMTP id v1-20020ac85781000000b004298a10e2afmr351233qta.25.1704926931162; Wed, 10 Jan 2024 14:48:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926931; cv=none; d=google.com; s=arc-20160816; b=AmQM+RLy8ExuCLfc3SB+uWXK7R2lX0qcJWrpLMlcLa3yntFWJWMIZqgJugB74X69er 3gUDNXyd3vxMOW8gYzyf17/toJmgUt5Qsch9KV0qQ74HMlPUDtNAmtcfOE5WOWnkS70A GeQqrtWsdlOE09oCTnHJmxfQfFi5R/IYGyQ96mGoTBT51Yow5eN8E6mWqAkiLy2u4Iai +N7BJKh/wDVOD/eMVYGWfwDHEeM3LbuUT9zArPf42Erag3eD6dp/jXbU6dWrw6MLN//J +/HMHUAN1IXK6knl4YVjHAT50991G9OgVytBKfXPvlCl8C4iHamtHtIYZNPtYegzuh7D 3wIg== 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=h+gt0CjYg4HfuULsURoNWzr2njchZ3xEe5eZdBzd0U4=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=0Oy9qTSFe1IHhisuoZNx0/sHqy7+QaoJcBEfIwaCqjP9b6MkZYBjh0b2tzVfkP6WGR iM0CsrpljxjYzeJzgYQK+rn54DnHcsIfVmeb1i/XlmpkGzs0Yiigh5fNss03YnwveYxh 1M0iDhPxq1fMHJCjJIMI+j0BE5qh05qjTivNjN2acvlSt7aZFDnPboNPqKIqEg8w7ChS FsbyzhvMENVGI/S0t0wCCcLaSv/4L3P3JOI4WnCH/Ss4JUVdSIF9fxm3Ba2MLPkRIT6s qpoQfTp6z9EQfKVXwcN9KP6AU9YkraW0xfdoi2+y7Z0JThBVQ2n6L3LYed1v+hxGVNFx vbow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DJXceG7Y; 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 g6-20020ac87f46000000b00429b0add358si2675355qtk.143.2024.01.10.14.48.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:48:51 -0800 (PST) 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=DJXceG7Y; 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 1rNhLJ-0007Ai-NS; Wed, 10 Jan 2024 17:46:37 -0500 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 1rNhKh-0005dT-8n for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:59 -0500 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhKe-00039m-QY for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:45:58 -0500 Received: by mail-qt1-x82f.google.com with SMTP id d75a77b69052e-42989a64713so28034031cf.2 for ; Wed, 10 Jan 2024 14:45:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926754; x=1705531554; 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=h+gt0CjYg4HfuULsURoNWzr2njchZ3xEe5eZdBzd0U4=; b=DJXceG7YPV9e6jLxkwPUnNenPBf/NwgfpVfUNe4PjWTxYrLyu0wlDc3IWL1TRP3F7C 0gz+QGwrz1suxWlQ0Ii20vqKw0KGCQXOGAHicfAd5t4gJOAhuApTPkh/UVugWUA4zhX8 wmQCuf/0P7zPMngUiTLAEqAfu4WhMBotVCLlAeEF1wzImW8/Bh4E7GFdy/2TpHKMyg0P sWyc7g+brTbJj82a4YoSAlZNYURp3MA/u8xV8C6eeGG5uCJZAVs6RmBKCGQPO7lCbHi4 AqT6XX8PgHe532p+3daT8keUbnF/mZvxzHBi0N9D24X7LZjOY+EyktxOwVtTiNBvLv7A H+WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926754; x=1705531554; 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=h+gt0CjYg4HfuULsURoNWzr2njchZ3xEe5eZdBzd0U4=; b=YRJ4q8xY/s4SasmUKtWYwBDp1T4JEwzjgyZwiMlkHybNIQu+erccZMLWXxPk2qi0lq YClDRwGGPuVknhgXi14AzP6bx4jiLJjDvMduQyg8cXGZlS5A8yZILpxOVXbvdGFggGkB 8RXK1hvj1Fn0kwyHNyjOfCYGuNr+l8eMQ3Zylv+mFTHuLe9DVRoK35/mm79W7gKFH0f2 /ndYNB9tpeZfQNpsYYRaxnYUx767BK+mwG9qWt2MQfppptlIoId9c/N/GfAu+IOrtkXf uEbx0waw4WJSscicIfMu7OsX2/PH+VY0q4VLTWaMfVKAVzWnLPGz3agoi/7EGcu0CiXH m++Q== X-Gm-Message-State: AOJu0YwJfe/Q2okUdxWLmXd6B0fUFTqji3ml4k95jHmPsSer45iGpBkS ZTSoa0DufKN07QUM4UiP1Ae06LgecvP+6dMToeE1a59QvCdyWMii X-Received: by 2002:ac8:7c4c:0:b0:429:bdb8:a581 with SMTP id o12-20020ac87c4c000000b00429bdb8a581mr273153qtv.7.1704926752228; Wed, 10 Jan 2024 14:45:52 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.45.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:45:51 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 18/38] tcg/aarch64: Generate TBZ, TBNZ Date: Thu, 11 Jan 2024 09:43:48 +1100 Message-Id: <20240110224408.10444-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82f; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82f.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Test the sign bit for LT/GE vs 0, and TSTNE/EQ vs a power of 2. Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.c.inc | 100 ++++++++++++++++++++++++++++------- 1 file changed, 81 insertions(+), 19 deletions(-) diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 70df250c04..55225313ad 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -105,6 +105,18 @@ static bool reloc_pc19(tcg_insn_unit *src_rw, const tcg_insn_unit *target) return false; } +static bool reloc_pc14(tcg_insn_unit *src_rw, const tcg_insn_unit *target) +{ + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + ptrdiff_t offset = target - src_rx; + + if (offset == sextract64(offset, 0, 14)) { + *src_rw = deposit32(*src_rw, 5, 14, offset); + return true; + } + return false; +} + static bool patch_reloc(tcg_insn_unit *code_ptr, int type, intptr_t value, intptr_t addend) { @@ -115,6 +127,8 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, return reloc_pc26(code_ptr, (const tcg_insn_unit *)value); case R_AARCH64_CONDBR19: return reloc_pc19(code_ptr, (const tcg_insn_unit *)value); + case R_AARCH64_TSTBR14: + return reloc_pc14(code_ptr, (const tcg_insn_unit *)value); default: g_assert_not_reached(); } @@ -380,6 +394,10 @@ typedef enum { /* Conditional branch (immediate). */ I3202_B_C = 0x54000000, + /* Test and branch (immediate). */ + I3205_TBZ = 0x36000000, + I3205_TBNZ = 0x37000000, + /* Unconditional branch (immediate). */ I3206_B = 0x14000000, I3206_BL = 0x94000000, @@ -660,6 +678,14 @@ static void tcg_out_insn_3202(TCGContext *s, AArch64Insn insn, tcg_out32(s, insn | tcg_cond_to_aarch64[c] | (imm19 & 0x7ffff) << 5); } +static void tcg_out_insn_3205(TCGContext *s, AArch64Insn insn, + TCGReg rt, int imm6, int imm14) +{ + insn |= (imm6 & 0x20) << (31 - 5); + insn |= (imm6 & 0x1f) << 19; + tcg_out32(s, insn | (imm14 & 0x3fff) << 5 | rt); +} + static void tcg_out_insn_3206(TCGContext *s, AArch64Insn insn, int imm26) { tcg_out32(s, insn | (imm26 & 0x03ffffff)); @@ -1415,30 +1441,66 @@ static inline void tcg_out_goto_label(TCGContext *s, TCGLabel *l) static void tcg_out_brcond(TCGContext *s, TCGType ext, TCGCond c, TCGArg a, TCGArg b, bool b_const, TCGLabel *l) { - intptr_t offset; - bool need_cmp; + int tbit = -1; + bool need_cmp = true; - if (b_const && b == 0 && (c == TCG_COND_EQ || c == TCG_COND_NE)) { - need_cmp = false; - } else { - need_cmp = true; - tcg_out_cmp(s, ext, c, a, b, b_const); - } - - if (!l->has_value) { - tcg_out_reloc(s, s->code_ptr, R_AARCH64_CONDBR19, l, 0); - offset = tcg_in32(s) >> 5; - } else { - offset = tcg_pcrel_diff(s, l->u.value_ptr) >> 2; - tcg_debug_assert(offset == sextract64(offset, 0, 19)); + switch (c) { + case TCG_COND_EQ: + case TCG_COND_NE: + if (b_const && b == 0) { + need_cmp = false; + } + break; + case TCG_COND_LT: + case TCG_COND_GE: + if (b_const && b == 0) { + c = (c == TCG_COND_LT ? TCG_COND_TSTNE : TCG_COND_TSTEQ); + tbit = ext ? 63 : 31; + need_cmp = false; + } + break; + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + if (b_const && is_power_of_2(b)) { + tbit = ctz64(b); + need_cmp = false; + } + break; + default: + break; } if (need_cmp) { - tcg_out_insn(s, 3202, B_C, c, offset); - } else if (c == TCG_COND_EQ) { - tcg_out_insn(s, 3201, CBZ, ext, a, offset); + tcg_out_cmp(s, ext, c, a, b, b_const); + tcg_out_reloc(s, s->code_ptr, R_AARCH64_CONDBR19, l, 0); + tcg_out_insn(s, 3202, B_C, c, 0); + return; + } + + if (tbit >= 0) { + tcg_out_reloc(s, s->code_ptr, R_AARCH64_TSTBR14, l, 0); + switch (c) { + case TCG_COND_TSTEQ: + tcg_out_insn(s, 3205, TBZ, a, tbit, 0); + break; + case TCG_COND_TSTNE: + tcg_out_insn(s, 3205, TBNZ, a, tbit, 0); + break; + default: + g_assert_not_reached(); + } } else { - tcg_out_insn(s, 3201, CBNZ, ext, a, offset); + tcg_out_reloc(s, s->code_ptr, R_AARCH64_CONDBR19, l, 0); + switch (c) { + case TCG_COND_EQ: + tcg_out_insn(s, 3201, CBZ, ext, a, 0); + break; + case TCG_COND_NE: + tcg_out_insn(s, 3201, CBNZ, ext, a, 0); + break; + default: + g_assert_not_reached(); + } } } From patchwork Wed Jan 10 22:43:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761484 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2112791wrz; Wed, 10 Jan 2024 14:47:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IH3bxDm/DLANGxigG6JI0ZrbhSG8oNrJahvx3r7bG0UIA9H93qK1nQJk/wue/dXMiNwjz7B X-Received: by 2002:a05:6214:3d8e:b0:67a:9400:2322 with SMTP id om14-20020a0562143d8e00b0067a94002322mr245794qvb.3.1704926869554; Wed, 10 Jan 2024 14:47:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926869; cv=none; d=google.com; s=arc-20160816; b=0VyF0Oc/7LWdyYGtvXt64w5M1AtIU0W3/kaws2mCcAluh0DObOCe9duWhRejX7grN7 +vRXdFL6wCFqmPj5s2HSuDEjU8uMaRCxqaCyGmXYPah9Y3cfMs9dXIKB9cNfc8ABb0EV DcgJvpkozvd9bDsdJjs+9JTZcfsAqmuoZpyiPupm4G+QfQSKcfyJLlKS8HteSGDOqtXu ThMemsWBcLL7YOCkzYf81DnGun/3+MK0JjU1S79lO5SjcYFvTYoXLaePXMbAG36XBxOj sB4ckKxHZHRxJW2wHyzRFUzYQgwho7MzhK8CAg8Gc5XuIXn65IqJK2wp0W/Ua+IU7kwG d/Vg== 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=9zCJMFAqdf2iFGNb4zrA/FuyIMECuUh8qss+ekAKVh8=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=WK0tcoqlC9OinJTkUwe5gkL6xxfrk1DL5i3wRriKzXwyp5ZBu00M2zgvk9Y0Hz3yru v5/F/T3f8t0A7lbNr1l+pPZZ5E35C6oMuoMnO7YS1J9ck7Q5OAWPhuQWRu4EgG1JLuZU Vgb6Hy7QeYsc5FDlqAnqmuK3ecQuBsB0Zqy39pgFVWgeKd7b10FHyL9SvL/yBI20ALFD T3pqxJ8AVZB+sWeYvccHnDyCBdhcGhhcz2c2iMuGq3ZnZ0Vsc2x77zd8LeiNZR8jJsUI QixoYT9IEFmkjRxLsbB+RD6RJfGdvu7/H5GK+wFWvoy9AP7rocBsUhUN4YivVmgvDQkp Ab+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="eLaddh3/"; 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 dg16-20020a056214085000b00680196555b3si5427145qvb.604.2024.01.10.14.47.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:47:49 -0800 (PST) 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="eLaddh3/"; 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 1rNhLK-0007Eg-1a; Wed, 10 Jan 2024 17:46:38 -0500 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 1rNhKi-0005mH-W8 for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:01 -0500 Received: from mail-qt1-x836.google.com ([2607:f8b0:4864:20::836]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhKh-0003AQ-CO for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:00 -0500 Received: by mail-qt1-x836.google.com with SMTP id d75a77b69052e-4298bdafa54so25704131cf.1 for ; Wed, 10 Jan 2024 14:45:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926758; x=1705531558; 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=9zCJMFAqdf2iFGNb4zrA/FuyIMECuUh8qss+ekAKVh8=; b=eLaddh3/aB5stt/DScS0KSsLoZ8h3acGVqTRqmRgc4KwK5+gwE6EJWOUNAUDkMLbdo nWHkYrWcdLe5+EDxzsm6upurAO8dL44+Fl2JvInph0sXzTyVQowBQr83x6wJEWTsg2kq Bjk/gVkFYhijaxAjxw3FJKxT9DUt7yNkorQb21KGhWIB3Y2NPI2EUtppBSCz2Aha7lKW jPniBPGSqUFWoVA7k614EsN0NZb/yuS0vj9/6wUcVFIj0260CxzkoNCO2iYeOQaf/w/W P5ASo5c4xaQkqLzZuILObFsi5E4RDB6iKhzAC99J6sDgQPwAxs3UMv7A/OOgu6Pjnumw tzAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926758; x=1705531558; 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=9zCJMFAqdf2iFGNb4zrA/FuyIMECuUh8qss+ekAKVh8=; b=syegySttrPZ3WgnxrQCmXetxfzsn3Ja6b3YtsXFGi9CCIjgkdo6lOGNpDudH0ycbI3 x7c9LYJr+rJe2CffP6QSlfmLlET1YToCoxFGAlzM0KL896JB4uP3pW8P3/9wuyxlTjf9 CMDFWAPh62cvBomS/VEuteW730vyv1pWzDM3bujMWaltuepo9mqgM2upQzDdmaJIaBhX aaoBhOW1sYed/IP9fJUfEvs7w3uuod+tbNeu3ja3XbQ0cYW3GDnD7qSESmY06oqLsKi4 qRu8Xe0/57sGmOCaWDdZrGd5wrowRfe8YtYt3wBTUBDEpVTKG2E75YvsmclCUWV/xGee jvug== X-Gm-Message-State: AOJu0YwI5l5TYVvtJtvE9eiz984lCMYaCGsoptTrvuN1mqVzta9iHFAh pG1CAAMSBIY5NHPIieqcUdyUSxlFfw1TKmo/RyjiywuinGRaQ9+a X-Received: by 2002:a05:622a:19a2:b0:429:7fac:a670 with SMTP id u34-20020a05622a19a200b004297faca670mr291082qtc.57.1704926758097; Wed, 10 Jan 2024 14:45:58 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.45.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:45:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 19/38] tcg/aarch64: Generate CBNZ for TSTNE of UINT32_MAX Date: Thu, 11 Jan 2024 09:43:49 +1100 Message-Id: <20240110224408.10444-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::836; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x836.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, T_SCC_BODY_TEXT_LINE=-0.01 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 ... and the inverse, CBZ for TSTEQ. Suggested-by: Paolo Bonzini Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tcg/aarch64/tcg-target.c.inc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 55225313ad..0c98c48f68 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1453,6 +1453,7 @@ static void tcg_out_brcond(TCGContext *s, TCGType ext, TCGCond c, TCGArg a, break; case TCG_COND_LT: case TCG_COND_GE: + /* cmp xN,0; b.mi L -> tbnz xN,63,L */ if (b_const && b == 0) { c = (c == TCG_COND_LT ? TCG_COND_TSTNE : TCG_COND_TSTEQ); tbit = ext ? 63 : 31; @@ -1461,6 +1462,13 @@ static void tcg_out_brcond(TCGContext *s, TCGType ext, TCGCond c, TCGArg a, break; case TCG_COND_TSTEQ: case TCG_COND_TSTNE: + /* tst xN,0xffffffff; b.ne L -> cbnz wN,L */ + if (b_const && b == UINT32_MAX) { + ext = TCG_TYPE_I32; + need_cmp = false; + break; + } + /* tst xN,1< tbnz xN,B,L */ if (b_const && is_power_of_2(b)) { tbit = ctz64(b); need_cmp = false; From patchwork Wed Jan 10 22:43:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761493 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2113155wrz; Wed, 10 Jan 2024 14:48:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IF0vRaEVFvmBvN7g06QqZLnowtxGY3Mb3v36n8aGvJtHSHRxCUI3V9CenIDIXpCoIBdgGve X-Received: by 2002:ac8:5852:0:b0:429:a5ed:b0b9 with SMTP id h18-20020ac85852000000b00429a5edb0b9mr347685qth.47.1704926937895; Wed, 10 Jan 2024 14:48:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926937; cv=none; d=google.com; s=arc-20160816; b=xsJkOQfM+lcUjOE8eRpT0Z3WMOdzbkiVcXx/8zeaT/Qh5RMh0ibvExufZBkahgsRsq DFTB0jZ6+FU/tg7IeCXq/rnNHGUPULdOttH0nohog6v6muD5r5akZFKHzLJcNN12/shE p6iaW2fRK2ad6BgsGATSUEtemFYUsxBrj3Qn/iiCDNePeQ1mBtLIf09z44YEnzgWrrYI ZL6V1GpV5ln3eBIgv9jdEBUUJE/C9eCM4nH/0mOpJfoyHdhCLY+4Tj/9DQJCpRnQfXNI GWkMNM6Oj5P16zyPSwyIPQJXwZmmL0bBSbJS26AF+w6jfT90PwUGJRlWT+Vgn68kcArG VFSA== 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=rBO9h8KMQ8hfOsqhiuTiqmSfaBXd3OkUHNoQ5JH+g9M=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=zqXpADCjZFppEUsJaxz84lSauKraWU4B3unWWiyITQQh26JSF+R7OTAo/wM+stHyZ5 TNHwZl5tWuMm/6UxuyLAFle0r66FlvN1bbMLP4ZjMPQ3vdg50hvuyErAKp1lbPUAwJHe ZbEQD84tAhWj9tjdE6JbSacZbylN8e7ZH71Epu++XlO3Cve+yufKkzzQvInVQCFwjtMa kMunjzttQRFtx4eVXg3UHAiJvfXj3FD8Y2l7+gcKqyTw7fczgK4zs/N8te63Tg0GQCNG DWuugcJVx+Zgz6iA7wjDGKOllla7BjC0j17tqTO/rxX5AjjdBKoVgYzyP+0t6e0dPAaY 3jSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kkMUt7g6; 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 q16-20020a05622a04d000b0042979ee1302si5291994qtx.262.2024.01.10.14.48.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:48:57 -0800 (PST) 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=kkMUt7g6; 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 1rNhLL-0007QJ-NS; Wed, 10 Jan 2024 17:46:39 -0500 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 1rNhKm-0006Bv-Fz for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:04 -0500 Received: from mail-yb1-xb30.google.com ([2607:f8b0:4864:20::b30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhKk-0003Cb-MB for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:04 -0500 Received: by mail-yb1-xb30.google.com with SMTP id 3f1490d57ef6-dbe344a6cf4so3889219276.0 for ; Wed, 10 Jan 2024 14:46:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926761; x=1705531561; 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=rBO9h8KMQ8hfOsqhiuTiqmSfaBXd3OkUHNoQ5JH+g9M=; b=kkMUt7g6lh/vFOZZH0/rgxkqvb6g75SD5jYa7nvV+NgmjMnl5qugs2QpFnkUkoKcB8 8mB0g6StrS1+YgUE/CQKDA5OjGe3DoVkIBYbE+8W01+2tJWiCrvFkdrGLUaz7HPz7QYt kT/7GTL9fUHzt6nygS+OS9OhaXVWj0mHyeMlRkuqhzjgA9Pusi+FMBqwHUARYs4RfUjG kkSEeV6X6sY9CyuVJ+27W6R7OMndzTJ8TrPbuWhFm1eAUaPynQhgCviH2I5E2BNe5u/S quX7IK9uDM8kaj3m+6/By0jBB+1f+xJfvS044I7fUYra5WIPrJ3rY64FwxeL1uzfGkWI QKXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926761; x=1705531561; 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=rBO9h8KMQ8hfOsqhiuTiqmSfaBXd3OkUHNoQ5JH+g9M=; b=wW9yrAuuAk8Cnrk+UOJdLKcBEuquG2wPXDBMsYKWdPt109r4Xw0dr2hkHCe8FJxfF9 QiNpR/gP03njfWEwJV83RoTqFdsotWQ1hrGt7NHJ70DeVNlfUEQICN/S+LmIInpqDPvj U6IdR2tPFNVOkoclsitWCf8AbRgtKO+rKQWDHZKq3dSqauobXYXD6nHcKruvM3JTeRdJ zsgujKtUXTzUlEbEN0FmUtwmnG25h0xcoRrFUsYH1GmgCXZEdcmXY3zHAhJuY63tIZEg DSM0sO3LwhmPlZ4bj6JjqDIT3kdmvZtfCiY44uo5giqWkNPwA0hZEjEsUx2YxE+ffdYj yAYg== X-Gm-Message-State: AOJu0Yy9HH7zr6OtX5j5yeel3y6rD9qj60ns9xLqSC2Zqsv3aP9OiAMF S8tpPyuvfA7QG961nF/SIURGv34mCwJ0yRzW482AQtVBK7QwEBiW X-Received: by 2002:a25:6b43:0:b0:dbe:337e:4d9 with SMTP id o3-20020a256b43000000b00dbe337e04d9mr343655ybm.67.1704926761615; Wed, 10 Jan 2024 14:46:01 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.45.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:46:01 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 20/38] tcg/arm: Factor tcg_out_cmp() out Date: Thu, 11 Jan 2024 09:43:50 +1100 Message-Id: <20240110224408.10444-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::b30; envelope-from=richard.henderson@linaro.org; helo=mail-yb1-xb30.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Signed-off-by: Richard Henderson Message-Id: <20231028194522.245170-12-richard.henderson@linaro.org> [PMD: Split from bigger patch, part 1/2] Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20231108145244.72421-1-philmd@linaro.org> Reviewed-by: Philippe Mathieu-Daudé --- tcg/arm/tcg-target.c.inc | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 0c29a3929b..66d71af8bf 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1191,6 +1191,13 @@ static void tcg_out_mb(TCGContext *s, TCGArg a0) } } +static TCGCond tcg_out_cmp(TCGContext *s, TCGCond cond, TCGReg a, + TCGArg b, int b_const) +{ + tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, a, b, b_const); + return cond; +} + static TCGCond tcg_out_cmp2(TCGContext *s, const TCGArg *args, const int *const_args) { @@ -1806,9 +1813,8 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, /* Constraints mean that v2 is always in the same register as dest, * so we only need to do "if condition passed, move v1 to dest". */ - tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, - args[1], args[2], const_args[2]); - tcg_out_dat_rIK(s, tcg_cond_to_arm_cond[args[5]], ARITH_MOV, + c = tcg_out_cmp(s, args[5], args[1], args[2], const_args[2]); + tcg_out_dat_rIK(s, tcg_cond_to_arm_cond[c], ARITH_MOV, ARITH_MVN, args[0], 0, args[3], const_args[3]); break; case INDEX_op_add_i32: @@ -1958,25 +1964,21 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, break; case INDEX_op_brcond_i32: - tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, - args[0], args[1], const_args[1]); - tcg_out_goto_label(s, tcg_cond_to_arm_cond[args[2]], - arg_label(args[3])); + c = tcg_out_cmp(s, args[2], args[0], args[1], const_args[1]); + tcg_out_goto_label(s, tcg_cond_to_arm_cond[c], arg_label(args[3])); break; case INDEX_op_setcond_i32: - tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, - args[1], args[2], const_args[2]); - tcg_out_dat_imm(s, tcg_cond_to_arm_cond[args[3]], + c = tcg_out_cmp(s, args[3], args[1], args[2], const_args[2]); + tcg_out_dat_imm(s, tcg_cond_to_arm_cond[c], ARITH_MOV, args[0], 0, 1); - tcg_out_dat_imm(s, tcg_cond_to_arm_cond[tcg_invert_cond(args[3])], + tcg_out_dat_imm(s, tcg_cond_to_arm_cond[tcg_invert_cond(c)], ARITH_MOV, args[0], 0, 0); break; case INDEX_op_negsetcond_i32: - tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, - args[1], args[2], const_args[2]); - tcg_out_dat_imm(s, tcg_cond_to_arm_cond[args[3]], + c = tcg_out_cmp(s, args[3], args[1], args[2], const_args[2]); + tcg_out_dat_imm(s, tcg_cond_to_arm_cond[c], ARITH_MVN, args[0], 0, 0); - tcg_out_dat_imm(s, tcg_cond_to_arm_cond[tcg_invert_cond(args[3])], + tcg_out_dat_imm(s, tcg_cond_to_arm_cond[tcg_invert_cond(c)], ARITH_MOV, args[0], 0, 0); break; From patchwork Wed Jan 10 22:43:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761474 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2112598wrz; Wed, 10 Jan 2024 14:47:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IEMCaTR+gMCaov3q7OKp0SYlg1pTHh7ffT4O+huW1Vty3FXYQCViY1IhLqHMMp5V6RN2vW9 X-Received: by 2002:a05:6214:c6b:b0:681:1864:cb3b with SMTP id t11-20020a0562140c6b00b006811864cb3bmr1243400qvj.32.1704926827909; Wed, 10 Jan 2024 14:47:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926827; cv=none; d=google.com; s=arc-20160816; b=BNq7/QeD0+OW3UCWYvEbK97bZrNUPkgPJFAfUKIrnkX6EbfmF2/Zca2UvgsxGA/Fap wO+gMIUl85ZE+Ch6cnTGb4Twp2hVjedI2EDMGMQGhSVEpaDUCkoh21UN9S1fHfJ+iUla 4GvLAWs8VB3PiKbXcVmzxRiTat1osIYOTA0wr/AD3VMptFdCP4re8qvUY3qfjxs1n2m1 bEUbjUdUi1eQyx7ZxQ1lQa6aEfvxLBdCSm7tdVdgddeK7TF6Z/ECmoaAG0Xkxn1DLsRc wnZLnAIC2mDDkjO5Vp+SFyjKM12ytyX4L+qLbL/IFX6u8nflM1QXuDhKbJu7NWDHUvMi nePQ== 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=PVv83mbHx+ti5Iw4ZVcFle0NjlrRtL0PCWiz47WVlUo=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=uwqSNgszUbPLBk6Fk74UWsLU2Thh3/rMuHBwC87HH0/0r+5XvO7HxYMssQLFHyEmpW KDt4mwYbJW+I+Qv2PQ5V5ktNtsCbyjE0W/TFARlxfAJEae03PAjpGF+RT5AGmgcGJf9m PsvdOb5VEQxLekXkdUlfIeGaN90k3HBLPJurWiF95XjeGJKCh/bYzId2LnF6XorVSyHf 3Xc/IfbOcOIXfn9hfx9tY32Jc1NjCMNch7sV1fdQEmen3BY4UCpOZz79Z0V+hae8CO1/ UcdmLkmI1J8V2UH2AgtdCd6RdxmqKVGaH+3Buj6oVKyO3nd7X/0VYQurDotSQcOygdHG izXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MP24Fs03; 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 f12-20020a0cf3cc000000b0067fd61f5a8asi5189186qvm.301.2024.01.10.14.47.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:47:07 -0800 (PST) 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=MP24Fs03; 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 1rNhLG-0006tB-Kx; Wed, 10 Jan 2024 17:46:36 -0500 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 1rNhKq-0006Ni-Am for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:16 -0500 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhKn-0003EP-Pm for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:07 -0500 Received: by mail-qt1-x832.google.com with SMTP id d75a77b69052e-429915eefa5so30454671cf.1 for ; Wed, 10 Jan 2024 14:46:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926765; x=1705531565; 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=PVv83mbHx+ti5Iw4ZVcFle0NjlrRtL0PCWiz47WVlUo=; b=MP24Fs03un2NGTxgkKG3vcv5aG54IoHF2jBRIbYsVTCvMwq16MfRj3XESnWjfjjCi0 w8Jn7lvko42hKpmjtv9+viD7ILb1n2HblDzUOWH0U9cvhVs2+nXViACaLu1YZBSrqkqz i/+sKLErI7cc8GPmMrFAMuo9Kqc7CgGcsJkQRjh8K9F/0nKz+hBDkpmBpCN7fk2V6amb 1BT14kLDN7q4oAHe7yKZIxweqaKfbJq69QE2IloM1YZUaZPEJSzHKN03k81v2nAAfFy+ PZC3CxCuZJ5B5aRwsvbC58hpM4AJ03KUJMSHcDLok/3Vzn4JedMcgFNIZD5r/IfSmib9 QiZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926765; x=1705531565; 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=PVv83mbHx+ti5Iw4ZVcFle0NjlrRtL0PCWiz47WVlUo=; b=L7ib8ZPkVJ03qYkBQPXZRXl7u58e+du9DPR4ewBz9lJvlbQpbEYhjftskd0Xj994TM HLXn/zEmW/SMus6JG1CUOeKk4DQPHV5JaK9Xt6SFZxTxdtcDnwRT4mf4xEG1HDPVwk2m vI0QxIq16GDOj8qGaHHckI1Bx3OE3E77g84RMitL6bc4opFnLjNIEtR20TzLcDV1hJqQ EC//2fHzcM5S2LXae0avaYVDw0mN5NA/3EzizR1CM6j7X/pFfojGex78SsJprTBq2386 E/3PxvdYanFG/yLiIlpxtrNY7QycXFMuzeoHQyaLIXQCg2Qy00EHes9dd4p5oCA3tEJA 9eYg== X-Gm-Message-State: AOJu0YwQ2hjHwWfr/ZZ2ZcF81SEEK6yR6erYc7M1eBM7fFJrmJHWJQVf xItUF3jbc5NB0hXUgvors797Gg+E6YoZkxC4eQ5vqfaZGBYfnlbp X-Received: by 2002:ac8:590a:0:b0:429:ad53:abe3 with SMTP id 10-20020ac8590a000000b00429ad53abe3mr1067615qty.41.1704926764927; Wed, 10 Jan 2024 14:46:04 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.46.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:46:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 21/38] tcg/arm: Support TCG_COND_TST{EQ,NE} Date: Thu, 11 Jan 2024 09:43:51 +1100 Message-Id: <20240110224408.10444-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::832; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x832.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Signed-off-by: Richard Henderson Message-Id: <20231028194522.245170-12-richard.henderson@linaro.org> [PMD: Split from bigger patch, part 2/2] Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20231108145244.72421-2-philmd@linaro.org> Reviewed-by: Philippe Mathieu-Daudé --- tcg/arm/tcg-target.h | 2 +- tcg/arm/tcg-target.c.inc | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index 7bf42045a7..a43875cb09 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -125,7 +125,7 @@ extern bool use_neon_instructions; #define TCG_TARGET_HAS_qemu_ldst_i128 0 -#define TCG_TARGET_HAS_tst 0 +#define TCG_TARGET_HAS_tst 1 #define TCG_TARGET_HAS_v64 use_neon_instructions #define TCG_TARGET_HAS_v128 use_neon_instructions diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 66d71af8bf..0fc7273b16 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1194,7 +1194,27 @@ static void tcg_out_mb(TCGContext *s, TCGArg a0) static TCGCond tcg_out_cmp(TCGContext *s, TCGCond cond, TCGReg a, TCGArg b, int b_const) { - tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, a, b, b_const); + if (!is_tst_cond(cond)) { + tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, a, b, b_const); + return cond; + } + + cond = tcg_tst_eqne_cond(cond); + if (b_const) { + int imm12 = encode_imm(b); + + /* + * The compare constraints allow rIN, but TST does not support N. + * Be prepared to load the constant into a scratch register. + */ + if (imm12 >= 0) { + tcg_out_dat_imm(s, COND_AL, ARITH_TST, 0, a, imm12); + return cond; + } + tcg_out_movi32(s, COND_AL, TCG_REG_TMP, b); + b = TCG_REG_TMP; + } + tcg_out_dat_reg(s, COND_AL, ARITH_TST, 0, a, b, SHIFT_IMM_LSL(0)); return cond; } @@ -1225,6 +1245,13 @@ static TCGCond tcg_out_cmp2(TCGContext *s, const TCGArg *args, tcg_out_dat_rI(s, COND_EQ, ARITH_CMP, 0, al, bl, const_bl); return cond; + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + /* Similar, but with TST instead of CMP. */ + tcg_out_dat_rI(s, COND_AL, ARITH_TST, 0, ah, bh, const_bh); + tcg_out_dat_rI(s, COND_EQ, ARITH_TST, 0, al, bl, const_bl); + return tcg_tst_eqne_cond(cond); + case TCG_COND_LT: case TCG_COND_GE: /* We perform a double-word subtraction and examine the result. From patchwork Wed Jan 10 22:43:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761476 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2112678wrz; Wed, 10 Jan 2024 14:47:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IH22VAavOTRfzcJ54va7gOZWQjJWos9zbEG0PszbtASEFoXXLA2xD/A32050j0EZQnq/zpQ X-Received: by 2002:a05:622a:181:b0:421:c349:73f6 with SMTP id s1-20020a05622a018100b00421c34973f6mr244815qtw.22.1704926847683; Wed, 10 Jan 2024 14:47:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926847; cv=none; d=google.com; s=arc-20160816; b=VvMlz1vSvWBpIcMkK3dxtmqgbXGzc5rz6EVLoIMtxftqkPOrCrFxwKBeHTBkpksXkG q0CGYqvCFaDKhk/yU5GvQm20S87Si2SHpOu7bYIR4Yee7gZm/9HqKTA+xU9woHnuxASN ykq7YfmxbQ3XW/8XsRKuV9Kf9y3X5c4T6h3FkNwGqiG1lODZFGBZK3FijStWpRz93S+l Yp76uoaX7c/NvbTWAmlrLTAyZoDVYlMTrAeg5gLdeWxnGfYMLIaDvyN9RuEWN6bcOf/h ZKNkSZYTQbwZ/vftp2VDlHRvHRnmdEog74sLRsTR7lUXPc1nASVkP7FsrloO5oC/H6dw JBLA== 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=hIn73/7L0/UvLzTpfBg1BsspTF3e93L6IUnQvuIa2EY=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=c5y05vg+GhyrdpUmwjSoMn3TdBXpZ+aUBBxre+W/PfXyo8VxinVsMPhnjshoZpxFmd p9g+ZJ7aqKftof0celN6+4TpGvU5RlR1cjmPopZhAvzH8TbrZ1/E2vQalfRHh3KgVTM1 EQaYlJYm2UA2t4A1DAYBPIFXFCAvBUlvl7J+QgWkGxckqzuWENMtMi3LEFF4vOtlsG6L 2gKeiP41JV8eeRvQqNaDfiP+NCV7snDZwJ00Vg6vW21kjrOsnHwuqM0pcRrWjdusVlS7 2H/R8LxAZ6kH6tVf7jks933rIhezAoSMNXi42HB+XVTh64n+echDy8IOaKWnAw8LpBnc GW3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xp+KOfok; 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 s38-20020a05622a1aa600b004298a439055si4698299qtc.566.2024.01.10.14.47.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:47:27 -0800 (PST) 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=Xp+KOfok; 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 1rNhLL-0007Mh-0h; Wed, 10 Jan 2024 17:46:39 -0500 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 1rNhKu-0006Oz-LV for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:16 -0500 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhKr-0003Fa-Pv for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:12 -0500 Received: by mail-qt1-x82f.google.com with SMTP id d75a77b69052e-4299e43a712so15455071cf.1 for ; Wed, 10 Jan 2024 14:46:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926768; x=1705531568; 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=hIn73/7L0/UvLzTpfBg1BsspTF3e93L6IUnQvuIa2EY=; b=Xp+KOfokdo8TOxX9F5RBZY7ktjN79N37LrQ3L9G7qUBVsFhwzhEkbOEXMxMc4WMTDE PjGQ46s2yNnv5EiFMc7I2cCxp49akRj4nzt3mBMoFuogtZg+fme6SkDVaNWGoPKiCpEn bxIb6KZ+UZPNh5caQQtGUvQ3KJzZC/nkq6ZWtKfHS3aSEg4qrYTtPtmfo8I322s/aK5I 4x1K12C41gE1zoc95moICDU6E3eS5FgBCGcdJCbm47A/YuraG7GVAunm3950cvSLP6i9 QO7cTDnytI2Hqid1Xem9RavqM6dGKmzJJcLBVxHC+Mf1zWgL1mCAvrLzQlt7YXRAAnfW qGNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926768; x=1705531568; 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=hIn73/7L0/UvLzTpfBg1BsspTF3e93L6IUnQvuIa2EY=; b=iD3h8oAX9oXn0JJChYGEpeLto6fO7+TPdIQ4OB63QxUHUjqCxI/uZQV2KbH7HSNYkA inMVvlnMNHxfIgv8st+30s+v1+qFwIXGyiZtKf/8kzAcd/bTRZFwDxp3wLh2YDeqJERG Vn2mKIbf9AsVhNw+JAIFiIgO7pp0W9a4AbDRN2zsKkql1o8JJln7NpH/FREqGZqVyXSA KwzEk2W3JzHetT+xjVNW0c2I7divw/rx0oeAR7rXSy8UgR4wGRovHX36NHISz9tn3myd EsYXt0vGcWREcKvRYcXIsG7+5C7vEGQU6pBtQncMCmdb/gocyEvw1OcLydq+F19yAQta Ty8g== X-Gm-Message-State: AOJu0YzoZjYAsfO0QpsgwNOXw4Mc3qrNTKCX+ZPgE8vjCJ9xKjDwhDjr NuoiRZlWffYS3V4zxX+4GJ09pc5uPDVBpvsw2TVOnD/PUeojCqe4 X-Received: by 2002:ac8:7f01:0:b0:429:bbf2:14bd with SMTP id f1-20020ac87f01000000b00429bbf214bdmr308764qtk.102.1704926768272; Wed, 10 Jan 2024 14:46:08 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.46.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:46:07 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 22/38] tcg/i386: Pass x86 condition codes to tcg_out_cmov Date: Thu, 11 Jan 2024 09:43:52 +1100 Message-Id: <20240110224408.10444-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82f; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82f.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Hoist the tcg_cond_to_jcc index outside the function. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.c.inc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index accaaa2660..2d6100a8f4 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1699,14 +1699,14 @@ static void tcg_out_setcond2(TCGContext *s, const TCGArg *args, } #endif -static void tcg_out_cmov(TCGContext *s, TCGCond cond, int rexw, +static void tcg_out_cmov(TCGContext *s, int jcc, int rexw, TCGReg dest, TCGReg v1) { if (have_cmov) { - tcg_out_modrm(s, OPC_CMOVCC | tcg_cond_to_jcc[cond] | rexw, dest, v1); + tcg_out_modrm(s, OPC_CMOVCC | jcc | rexw, dest, v1); } else { TCGLabel *over = gen_new_label(); - tcg_out_jxx(s, tcg_cond_to_jcc[tcg_invert_cond(cond)], over, 1); + tcg_out_jxx(s, jcc ^ 1, over, 1); tcg_out_mov(s, TCG_TYPE_I32, dest, v1); tcg_out_label(s, over); } @@ -1717,7 +1717,7 @@ static void tcg_out_movcond(TCGContext *s, int rexw, TCGCond cond, TCGReg v1) { tcg_out_cmp(s, c1, c2, const_c2, rexw); - tcg_out_cmov(s, cond, rexw, dest, v1); + tcg_out_cmov(s, tcg_cond_to_jcc[cond], rexw, dest, v1); } static void tcg_out_ctz(TCGContext *s, int rexw, TCGReg dest, TCGReg arg1, @@ -1729,12 +1729,12 @@ static void tcg_out_ctz(TCGContext *s, int rexw, TCGReg dest, TCGReg arg1, tcg_debug_assert(arg2 == (rexw ? 64 : 32)); } else { tcg_debug_assert(dest != arg2); - tcg_out_cmov(s, TCG_COND_LTU, rexw, dest, arg2); + tcg_out_cmov(s, JCC_JB, rexw, dest, arg2); } } else { tcg_debug_assert(dest != arg2); tcg_out_modrm(s, OPC_BSF + rexw, dest, arg1); - tcg_out_cmov(s, TCG_COND_EQ, rexw, dest, arg2); + tcg_out_cmov(s, JCC_JE, rexw, dest, arg2); } } @@ -1747,7 +1747,7 @@ static void tcg_out_clz(TCGContext *s, int rexw, TCGReg dest, TCGReg arg1, tcg_debug_assert(arg2 == (rexw ? 64 : 32)); } else { tcg_debug_assert(dest != arg2); - tcg_out_cmov(s, TCG_COND_LTU, rexw, dest, arg2); + tcg_out_cmov(s, JCC_JB, rexw, dest, arg2); } } else { tcg_debug_assert(!const_a2); @@ -1760,7 +1760,7 @@ static void tcg_out_clz(TCGContext *s, int rexw, TCGReg dest, TCGReg arg1, /* Since we have destroyed the flags from BSR, we have to re-test. */ tcg_out_cmp(s, arg1, 0, 1, rexw); - tcg_out_cmov(s, TCG_COND_EQ, rexw, dest, arg2); + tcg_out_cmov(s, JCC_JE, rexw, dest, arg2); } } From patchwork Wed Jan 10 22:43:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761502 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2114090wrz; Wed, 10 Jan 2024 14:51:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGtCfIHJKGTS7zLLjuqkjQO0ZYUokazv1BLe59Y5xS/bm7NARiU3EI/3pTI+MdWwRvxByG6 X-Received: by 2002:a05:6808:4496:b0:3bb:d6f6:1a71 with SMTP id eq22-20020a056808449600b003bbd6f61a71mr479097oib.111.1704927114886; Wed, 10 Jan 2024 14:51:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704927114; cv=none; d=google.com; s=arc-20160816; b=yf3ZJa27Ie6ckJ4Ji1PrHDCAc1T46GkDNvrJF+YeikLAQ4Du+mzdLzDWOpMa5FhS4w IqVS1sIWAtnPTlQg1sEXjQ+N392wWsYp1D8hTvF7SfNYrktXHGsjaxPzQd69nfeVzef/ SUPagnKcIbvzLI3st44coJvQUUma9oZjaeRL97WpBfhtqFVS2EoBQhKSED2OrfYytQCp q4hEAzQD0YD5XTZvx72Zl4ZztGYtfCLDCnCQ/ALCXOU+ZGufUffGy0zs+RqM1q3OyWS9 uC5i4SQxNO576avdXHwbDOOdraS6lV0egrptDYWbgUBmRs7JOy8yrMeerdHZ7YCDrvAt Le6A== 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=SYMLLwA9gva4L4uzAlLYH7HUcuo07hrL8DJH/YZuBt8=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=xtmuQ6n+W9eRhgqqElflcr3go4PrEuXYocFGDqpTF+OtI3C0U91iLV2vqvb8r4kjcG L/yO/g6UOrtL2dH5vqJrN/pirt9ktB14zFuYxa7wq7LpoI/HfBM/BSk6Z0t8R/5uQjra RG9Tcn34NeLM79HgRso/ZvR70BUXiHdsReW+kkh6e1PGHW+gWH0V+N3yCtlLiEpKzutv X2qIkS+ZVLByf8ATwtch3Fw3EB/V9cHNMXhuQbW6G5cW7L2PnZSWP99u2vT5yXS0dU5R PdHGXPEU0QfZNbh6y8CHSbxFtV5swjhrC67cOzx/eoNAhYBvq5kenwjDBO4WUHyXWCMg rB1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dOBJQBiX; 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 bd6-20020ad45686000000b00680cf7233dcsi5337038qvb.613.2024.01.10.14.51.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:51:54 -0800 (PST) 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=dOBJQBiX; 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 1rNhLM-0007bU-TB; Wed, 10 Jan 2024 17:46:41 -0500 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 1rNhL0-0006ZQ-38 for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:19 -0500 Received: from mail-yb1-xb2d.google.com ([2607:f8b0:4864:20::b2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhKv-0003IX-UR for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:17 -0500 Received: by mail-yb1-xb2d.google.com with SMTP id 3f1490d57ef6-dbed4b84667so4107654276.0 for ; Wed, 10 Jan 2024 14:46:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926772; x=1705531572; 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=SYMLLwA9gva4L4uzAlLYH7HUcuo07hrL8DJH/YZuBt8=; b=dOBJQBiX7IGwYiMXLqNTLkmDTKZYaSsFNePeAVBSpSVxPRb75qp8eQcbDxVYai5pvW 0sbUu+f6+u1Nsi2xk+LmlVJygH/ujMiNxihSzNKqN4ETSmfgSTgpueWImCagcEEDDs+K 92JhcfI5mWsCs7jSkAo8TWfQVDF3cafgAC2XKpYRsghY3sr70BWz1J0k9IEmooNa16Fh wu+KjdMXYNWlHA9WWjyk82wB+dSlxCmwLGCERiQ0BOvtaNZi2PJfSimQjbO3RHTDj9Nd wsIkVi0Y8eMvk6p62cZ5rvHuhga0ZWXxvr6BkCuFLOgmW6eZ28CRdfAQ8ooFRBLrkBpm m16w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926772; x=1705531572; 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=SYMLLwA9gva4L4uzAlLYH7HUcuo07hrL8DJH/YZuBt8=; b=jk0lh0Anl4xFShDtHG4R+Rf3A9urdQAk14BbBcjs8qaN0Fu/uqTqiJQEM7k05gGcX2 GKbrfiOWfzoatqaaS7BU/20WAfZtIAFDkA6FRdrzrZJxHEX8y+DtJYAhG/un6lvnVdYR RcsSuQaAIlU716aGWFSiMrdibs099dJxWe7TkwUw1S94Z6g/37GhwgEnc8I+2SreB4Sy oIRf94OQXCAEa8eizrf/0UZkkBBRop5Nhw2VN49j9HnKV08n6sUmDRAmyNMHUU4kbOPA XJQ1wKWHzHxACB+T+tJ29TrN/MLsZUqpKNcI7Cr2McO6OrBF0oqRS5CNan4sy8Mzk6t+ VVxQ== X-Gm-Message-State: AOJu0Yw5X5fl/ltFuic5fo9aefM9qdUhkNVi9M98XNXUfPZVzCDKcsBx rDNF0FqvFzF7abwR5WTeVrMVAY8tngDVJjWltJMJQ8NdEi3zDW6G X-Received: by 2002:a25:abc1:0:b0:dbe:a098:6cfc with SMTP id v59-20020a25abc1000000b00dbea0986cfcmr402400ybi.25.1704926771758; Wed, 10 Jan 2024 14:46:11 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.46.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:46:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 23/38] tcg/i386: Move tcg_cond_to_jcc[] into tcg_out_cmp Date: Thu, 11 Jan 2024 09:43:53 +1100 Message-Id: <20240110224408.10444-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::b2d; envelope-from=richard.henderson@linaro.org; helo=mail-yb1-xb2d.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Return the x86 condition codes to use after the compare. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.c.inc | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 2d6100a8f4..02718a02d8 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1449,8 +1449,8 @@ static void tcg_out_jxx(TCGContext *s, int opc, TCGLabel *l, bool small) } } -static void tcg_out_cmp(TCGContext *s, TCGArg arg1, TCGArg arg2, - int const_arg2, int rexw) +static int tcg_out_cmp(TCGContext *s, TCGCond cond, TCGArg arg1, + TCGArg arg2, int const_arg2, int rexw) { if (const_arg2) { if (arg2 == 0) { @@ -1462,14 +1462,15 @@ static void tcg_out_cmp(TCGContext *s, TCGArg arg1, TCGArg arg2, } else { tgen_arithr(s, ARITH_CMP + rexw, arg1, arg2); } + return tcg_cond_to_jcc[cond]; } static void tcg_out_brcond(TCGContext *s, int rexw, TCGCond cond, TCGArg arg1, TCGArg arg2, int const_arg2, TCGLabel *label, bool small) { - tcg_out_cmp(s, arg1, arg2, const_arg2, rexw); - tcg_out_jxx(s, tcg_cond_to_jcc[cond], label, small); + int jcc = tcg_out_cmp(s, cond, arg1, arg2, const_arg2, rexw); + tcg_out_jxx(s, jcc, label, small); } #if TCG_TARGET_REG_BITS == 32 @@ -1561,6 +1562,7 @@ static void tcg_out_setcond(TCGContext *s, int rexw, TCGCond cond, { bool inv = false; bool cleared; + int jcc; switch (cond) { case TCG_COND_NE: @@ -1597,7 +1599,7 @@ static void tcg_out_setcond(TCGContext *s, int rexw, TCGCond cond, * We can then use NEG or INC to produce the desired result. * This is always smaller than the SETCC expansion. */ - tcg_out_cmp(s, arg1, arg2, const_arg2, rexw); + tcg_out_cmp(s, TCG_COND_LTU, arg1, arg2, const_arg2, rexw); /* X - X - C = -C = (C ? -1 : 0) */ tgen_arithr(s, ARITH_SBB + (neg ? rexw : 0), dest, dest); @@ -1644,8 +1646,8 @@ static void tcg_out_setcond(TCGContext *s, int rexw, TCGCond cond, cleared = true; } - tcg_out_cmp(s, arg1, arg2, const_arg2, rexw); - tcg_out_modrm(s, OPC_SETCC | tcg_cond_to_jcc[cond], 0, dest); + jcc = tcg_out_cmp(s, cond, arg1, arg2, const_arg2, rexw); + tcg_out_modrm(s, OPC_SETCC | jcc, 0, dest); if (!cleared) { tcg_out_ext8u(s, dest, dest); @@ -1716,8 +1718,8 @@ static void tcg_out_movcond(TCGContext *s, int rexw, TCGCond cond, TCGReg dest, TCGReg c1, TCGArg c2, int const_c2, TCGReg v1) { - tcg_out_cmp(s, c1, c2, const_c2, rexw); - tcg_out_cmov(s, tcg_cond_to_jcc[cond], rexw, dest, v1); + int jcc = tcg_out_cmp(s, cond, c1, c2, const_c2, rexw); + tcg_out_cmov(s, jcc, rexw, dest, v1); } static void tcg_out_ctz(TCGContext *s, int rexw, TCGReg dest, TCGReg arg1, @@ -1759,8 +1761,8 @@ static void tcg_out_clz(TCGContext *s, int rexw, TCGReg dest, TCGReg arg1, tgen_arithi(s, ARITH_XOR + rexw, dest, rexw ? 63 : 31, 0); /* Since we have destroyed the flags from BSR, we have to re-test. */ - tcg_out_cmp(s, arg1, 0, 1, rexw); - tcg_out_cmov(s, JCC_JE, rexw, dest, arg2); + int jcc = tcg_out_cmp(s, TCG_COND_EQ, arg1, 0, 1, rexw); + tcg_out_cmov(s, jcc, rexw, dest, arg2); } } From patchwork Wed Jan 10 22:43:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761496 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2113205wrz; Wed, 10 Jan 2024 14:49:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IHmmGiuuAgG91BjrK6Stjg5dctMm+OgdQ0lqJ3nlIy6Az/bSF+H8suHmVEO+NyhM1RHByY8 X-Received: by 2002:a05:6214:5097:b0:681:118f:cfd2 with SMTP id kk23-20020a056214509700b00681118fcfd2mr227584qvb.89.1704926945331; Wed, 10 Jan 2024 14:49:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926945; cv=none; d=google.com; s=arc-20160816; b=Wkpl5pvHoSCf+krBWhYePG/VxRDeFHoIwEvrs/c19tSvYnoGgvJ8Rbit5FuVIAwk+b uHpA+MGxcfSY+7cdd3kpd9QW7QunR20PNpx6n8l9cIIHVlzEfB0HS8dsF7huf4CgCzyZ j+1tbNFa3KYKVDE4gbfXOkHgl+m31I01OG/iyI9jsNQ5wQxLR4p6Or62UOzDJIbsWYWl mUWI5uXXoyaKcQluQWuIkL4RnvK8iSh/GLMu3eS5ur6Mq2B91F54n/Qroq+wvghOTn8V mnkxGNuh78SOu+iwWnVQKY8h9qgskhgxheD2E2tBrBOi2satvz8BWFPRUS+dll534Lkz AkAg== 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=Od/xSXS8NstAz+sWZVmhj5MEuIknHRPAQGdZXQ5yceo=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=F5zI3nPSARfDp5RqQoq+lfKN2CH10xo+F5HS4SJaIIPh5kGdf3v3Mg5HQL+DPceXj/ aQo5PtGac79+KFOrZjG8ZS30gt6kxqlBAoZpQrxX7avj06TmipkU2h2Slq8s3EnsP8my UcfivhGl51pWwS58VCVfLdxyiHoN6c3xbMw6t0ca1T3grT7PshesgoAa377vFcFx6l0A mh9aDY8ayzp/iqzE0b20lBNRURbQ/ey4iCQw84BU9XOf5sOEMfSQ/hLB37a7eh6E3SaV 5KTTxtOyYMdAPioQWXYf/oa0Hm9prc93PuOAnfghV9iU0TVAay+BbM3Y1BxwCRveMQo2 mxgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Brt5TXx2; 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 e20-20020a0ce3d4000000b0067ef0702fe6si5233191qvl.512.2024.01.10.14.49.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:49:05 -0800 (PST) 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=Brt5TXx2; 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 1rNhLL-0007Op-9z; Wed, 10 Jan 2024 17:46:39 -0500 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 1rNhL2-0006di-0J for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:22 -0500 Received: from mail-qt1-x82e.google.com ([2607:f8b0:4864:20::82e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhKy-0003KF-JR for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:19 -0500 Received: by mail-qt1-x82e.google.com with SMTP id d75a77b69052e-429bb6677ebso3937601cf.2 for ; Wed, 10 Jan 2024 14:46:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926775; x=1705531575; 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=Od/xSXS8NstAz+sWZVmhj5MEuIknHRPAQGdZXQ5yceo=; b=Brt5TXx2g5QiDtF5lhWzY1RmULX7CDr0M++oKikO2u7MhYlPm4Cw3QOLB4vvSjgFLI kSfLr7ZE3eHsTO6LBxxEEOR1FNfIKu6X2J74ITZJS30CODoaHg+7f3WJaI91BzFS8MiC IrjavhGN1LPxctQuKcbNKUVqwXeRUPFhKVTDbIY3QbjJoubFmK8vfwnFLK7HWWQaKkg4 82yqdC6VW89xRg1tyjkM6uS6QpBCVDiugpIWBcPuEl4xjJNyBHsBT31jFF+wX7YbVP5Q bdI8suD+GxB9I43CZe9lgj8D7lTTrMaPRCPFjQT52vOuWoBwY0VxmEqB4TYf7Wmm8y6X lQRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926775; x=1705531575; 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=Od/xSXS8NstAz+sWZVmhj5MEuIknHRPAQGdZXQ5yceo=; b=nt/kvCTQ8kiUxuEcAL8usRJ6IeB+AsHjl154AY+i2UDipIMdmo7Fh5JBvlP2RldJDo DLLOvf1fcdW7+NeSdjQWx9k63T0g/P65lhtB+9RkceFoe0iPJJGNU5gwdDxEpa9Y2lUj ITFa8pkgWNZIKhpQsZx30FV4uQH66t/PsmbSH6ZGuN3+yZP7MbQpnOoDZIxAr5lUYCFf g6RqU4G4nOjbJricgK+DbWP4dkf5uj6N12U0/ZcnkKlWYDl59Iz3pJUyQgO+ebLSA9h7 SA1hoFERiaW1zevngwzWYSy/y4JtdWEvgXpiTfvgaUV1fwNwPqF/tahJsLw+DF0lHjEP HJ7A== X-Gm-Message-State: AOJu0Yyxc/zxi1/fncGDUNUpp8igzN6Nx6+2h2cD3baZuDeAXbEv04Lx Eg4iw5TM5F2Tj2K34OqYhu+/3CjIDOdLEEbatqeMoj4ICh7MnNEj X-Received: by 2002:a05:622a:18f:b0:429:bc01:b101 with SMTP id s15-20020a05622a018f00b00429bc01b101mr239691qtw.25.1704926775421; Wed, 10 Jan 2024 14:46:15 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.46.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:46:15 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 24/38] tcg/i386: Support TCG_COND_TST{EQ,NE} Date: Thu, 11 Jan 2024 09:43:54 +1100 Message-Id: <20240110224408.10444-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82e; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82e.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Merge tcg_out_testi into tcg_out_cmp and adjust the two uses. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.h | 2 +- tcg/i386/tcg-target.c.inc | 95 ++++++++++++++++++++++++--------------- 2 files changed, 60 insertions(+), 37 deletions(-) diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index 1dd917a680..a10d4e1fce 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -198,7 +198,7 @@ typedef enum { #define TCG_TARGET_HAS_qemu_ldst_i128 \ (TCG_TARGET_REG_BITS == 64 && (cpuinfo & CPUINFO_ATOMIC_VMOVDQA)) -#define TCG_TARGET_HAS_tst 0 +#define TCG_TARGET_HAS_tst 1 /* We do not support older SSE systems, only beginning with AVX1. */ #define TCG_TARGET_HAS_v64 have_avx1 diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 02718a02d8..f2414177bd 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -506,6 +506,8 @@ static const uint8_t tcg_cond_to_jcc[] = { [TCG_COND_GEU] = JCC_JAE, [TCG_COND_LEU] = JCC_JBE, [TCG_COND_GTU] = JCC_JA, + [TCG_COND_TSTEQ] = JCC_JE, + [TCG_COND_TSTNE] = JCC_JNE, }; #if TCG_TARGET_REG_BITS == 64 @@ -1452,17 +1454,49 @@ static void tcg_out_jxx(TCGContext *s, int opc, TCGLabel *l, bool small) static int tcg_out_cmp(TCGContext *s, TCGCond cond, TCGArg arg1, TCGArg arg2, int const_arg2, int rexw) { - if (const_arg2) { - if (arg2 == 0) { - /* test r, r */ + int jz; + + if (!is_tst_cond(cond)) { + if (!const_arg2) { + tgen_arithr(s, ARITH_CMP + rexw, arg1, arg2); + } else if (arg2 == 0) { tcg_out_modrm(s, OPC_TESTL + rexw, arg1, arg1); } else { + tcg_debug_assert(!rexw || arg2 == (int32_t)arg2); tgen_arithi(s, ARITH_CMP + rexw, arg1, arg2, 0); } - } else { - tgen_arithr(s, ARITH_CMP + rexw, arg1, arg2); + return tcg_cond_to_jcc[cond]; } - return tcg_cond_to_jcc[cond]; + + jz = tcg_cond_to_jcc[cond]; + + if (!const_arg2) { + tcg_out_modrm(s, OPC_TESTL + rexw, arg1, arg2); + return jz; + } + + if (arg2 <= 0xff && (TCG_TARGET_REG_BITS == 64 || arg1 < 4)) { + tcg_out_modrm(s, OPC_GRP3_Eb | P_REXB_RM, EXT3_TESTi, arg1); + tcg_out8(s, arg2); + return jz; + } + + if ((arg2 & ~0xff00) == 0 && arg1 < 4) { + tcg_out_modrm(s, OPC_GRP3_Eb, EXT3_TESTi, arg1 + 4); + tcg_out8(s, arg2 >> 8); + return jz; + } + + if (rexw) { + if (arg2 == (uint32_t)arg2) { + rexw = 0; + } else { + tcg_debug_assert(arg2 == (int32_t)arg2); + } + } + tcg_out_modrm(s, OPC_GRP3_Ev + rexw, EXT3_TESTi, arg1); + tcg_out32(s, arg2); + return jz; } static void tcg_out_brcond(TCGContext *s, int rexw, TCGCond cond, @@ -1479,18 +1513,21 @@ static void tcg_out_brcond2(TCGContext *s, const TCGArg *args, { TCGLabel *label_next = gen_new_label(); TCGLabel *label_this = arg_label(args[5]); + TCGCond cond = args[4]; - switch(args[4]) { + switch (cond) { case TCG_COND_EQ: - tcg_out_brcond(s, 0, TCG_COND_NE, args[0], args[2], const_args[2], - label_next, 1); - tcg_out_brcond(s, 0, TCG_COND_EQ, args[1], args[3], const_args[3], + case TCG_COND_TSTEQ: + tcg_out_brcond(s, 0, tcg_invert_cond(cond), + args[0], args[2], const_args[2], label_next, 1); + tcg_out_brcond(s, 0, cond, args[1], args[3], const_args[3], label_this, small); break; case TCG_COND_NE: - tcg_out_brcond(s, 0, TCG_COND_NE, args[0], args[2], const_args[2], + case TCG_COND_TSTNE: + tcg_out_brcond(s, 0, cond, args[0], args[2], const_args[2], label_this, small); - tcg_out_brcond(s, 0, TCG_COND_NE, args[1], args[3], const_args[3], + tcg_out_brcond(s, 0, cond, args[1], args[3], const_args[3], label_this, small); break; case TCG_COND_LT: @@ -1827,23 +1864,6 @@ static void tcg_out_nopn(TCGContext *s, int n) tcg_out8(s, 0x90); } -/* Test register R vs immediate bits I, setting Z flag for EQ/NE. */ -static void __attribute__((unused)) -tcg_out_testi(TCGContext *s, TCGReg r, uint32_t i) -{ - /* - * This is used for testing alignment, so we can usually use testb. - * For i686, we have to use testl for %esi/%edi. - */ - if (i <= 0xff && (TCG_TARGET_REG_BITS == 64 || r < 4)) { - tcg_out_modrm(s, OPC_GRP3_Eb | P_REXB_RM, EXT3_TESTi, r); - tcg_out8(s, i); - } else { - tcg_out_modrm(s, OPC_GRP3_Ev, EXT3_TESTi, r); - tcg_out32(s, i); - } -} - typedef struct { TCGReg base; int index; @@ -2104,16 +2124,17 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h, tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_L0, TCG_REG_L0, offsetof(CPUTLBEntry, addend)); } else if (a_mask) { - ldst = new_ldst_label(s); + int jcc; + ldst = new_ldst_label(s); ldst->is_ld = is_ld; ldst->oi = oi; ldst->addrlo_reg = addrlo; ldst->addrhi_reg = addrhi; - tcg_out_testi(s, addrlo, a_mask); /* jne slow_path */ - tcg_out_opc(s, OPC_JCC_long + JCC_JNE, 0, 0, 0); + jcc = tcg_out_cmp(s, TCG_COND_TSTNE, addrlo, a_mask, true, false); + tcg_out_opc(s, OPC_JCC_long + jcc, 0, 0, 0); ldst->label_ptr[0] = s->code_ptr; s->code_ptr += 4; } @@ -2259,9 +2280,10 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg datalo, TCGReg datahi, } else { TCGLabel *l1 = gen_new_label(); TCGLabel *l2 = gen_new_label(); + int jcc; - tcg_out_testi(s, h.base, 15); - tcg_out_jxx(s, JCC_JNE, l1, true); + jcc = tcg_out_cmp(s, TCG_COND_TSTNE, h.base, 15, true, false); + tcg_out_jxx(s, jcc, l1, true); tcg_out_vex_modrm_sib_offset(s, OPC_MOVDQA_VxWx + h.seg, TCG_TMP_VEC, 0, @@ -2387,9 +2409,10 @@ static void tcg_out_qemu_st_direct(TCGContext *s, TCGReg datalo, TCGReg datahi, } else { TCGLabel *l1 = gen_new_label(); TCGLabel *l2 = gen_new_label(); + int jcc; - tcg_out_testi(s, h.base, 15); - tcg_out_jxx(s, JCC_JNE, l1, true); + jcc = tcg_out_cmp(s, TCG_COND_TSTNE, h.base, 15, true, false); + tcg_out_jxx(s, jcc, l1, true); tcg_out_vex_modrm_sib_offset(s, OPC_MOVDQA_WxVx + h.seg, TCG_TMP_VEC, 0, From patchwork Wed Jan 10 22:43:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761486 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2112798wrz; Wed, 10 Jan 2024 14:47:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IH3+DSVbT1xrjjycOd5dUdQCzgikpuD10qnVnx2kHZ9JfmlGkWQbx0Xj+wXxboCQfl3nGd6 X-Received: by 2002:a05:6214:248b:b0:680:f736:d71b with SMTP id gi11-20020a056214248b00b00680f736d71bmr203815qvb.72.1704926870728; Wed, 10 Jan 2024 14:47:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926870; cv=none; d=google.com; s=arc-20160816; b=KkVnBf6xBO0SIFh6oMbiONNf5uLJecjUi6jQzrVbc2iY8sfpA0mypNraB6U3vB6IeM jHOdlei3ODJoFW2njrRoMR1SKPRYQ8SWKpF+G0XbYasLUPDuc7fYTP8QgE8QtXaJneTO fEdg8sa+qSRXypv5roTgNULtNWsUWjPtvDB58ivhGJ6vOR4oQJ3NLahYm6jdIRCVQPuy b7j2bjOloPhT5KQfss4q2jpTk2LJZn7LqX5AZhU/VH1tg1Wnyi5loHKZwTXZKroSLqJm SgiItHLT5EHfjbOokfWdif9H/HC+vv3spNq0wxN1buoqIUhXPeL8IUWuHxQN3717hBKC cglA== 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=1PZbgXf7h9mbijZSSPVJBmVbPzLYGP5B2/srtOcMXg4=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=tHlHNUeQjYUsOgIaccWrGWcC+KPL2eP9cs598/GzPW/+r6elliTg6J8VB2hAr6Xbg0 H7uVRyEPCy2HZuq8oTwsmZqUa6Lf50Glu7CnthhykW7W2l+NwM3mZVrST2ho6ax1Mibb ZuwX5OV+zMo/XZ/6ZTbtvoPhnhvETVhhndwx0g3QUflkUd034uzPZIwMGNtMMqeaG4Vv E5J4JgvtgIB5mdxWBnkX0UQCtE8TbHWGxzfpp05ePWVhFTcZAjPaLJ0lvE0bkBoJvW/j jCJ5gQUDJXP+prAew4Mu80CavQUa/awVklO+J1WVQBHbiL/2GMNPwv+wgDgMq4UkyMOy MrhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZD4MpuTv; 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 j6-20020a0cab86000000b0067a9d364535si5200944qvb.11.2024.01.10.14.47.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:47:50 -0800 (PST) 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=ZD4MpuTv; 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 1rNhLN-0007c0-Uu; Wed, 10 Jan 2024 17:46:42 -0500 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 1rNhL6-0006qG-IQ for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:28 -0500 Received: from mail-qt1-x82d.google.com ([2607:f8b0:4864:20::82d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhL3-0003OH-Ie for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:24 -0500 Received: by mail-qt1-x82d.google.com with SMTP id d75a77b69052e-429b76f129eso5485491cf.3 for ; Wed, 10 Jan 2024 14:46:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926779; x=1705531579; 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=1PZbgXf7h9mbijZSSPVJBmVbPzLYGP5B2/srtOcMXg4=; b=ZD4MpuTvHdcS1RTnLBac9sAla6Bo8P9t0XEho+bRt56f7lFfhferHrMco4oCrgWv+V kHRbGlsdsOTGxugqLmiPP9XPxRK6fR2ZMVdPX62bNMQ3E3YAXo1M5pUTAIuDGMm5mlnb QVUkhsesCcMgOlXIlTubkvVoIXrOK/f+S0j76Fv1BCLfEfgYLs/skNC+lNBJrk4swvrX MQTELcbiMbmyhXoILCpOvUHOiJLk3DO/MJ1gQh09Qarrf3s6GObqHTBBBtkjCKGx7PnE mI6SzqA11p1s/qhOheCseg4xPiCLXxhQG7qHA7/7FkjfAzkQBCm422FcJGokmP4uwdOq bB7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926779; x=1705531579; 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=1PZbgXf7h9mbijZSSPVJBmVbPzLYGP5B2/srtOcMXg4=; b=toiezqFMmpBMFC+hHZqbTDEe8D7GMPyWbDI1e00ZYxx1PLwGwtL5BU7bGhEMviJSag gY1D1ZdBRSlwMFfgEkxjPU2FJoRkWxTpECN75XjB5Cb0tYgsmbTHrHgBWHHKIlMQb1Cq iIC6ATqwibc0emzcWGpFJQrPdYvJCTr750fjl7riWnxd1wPCdPVyTtmSFgKmcAvFM2R5 3JM/u5lq8ZJNHsEq3RxYfYS/opKREolsLfL9rok8am1RUKvidfJUg2TrXxX+fUHoFOge Bhn96TO+D7UqvNrxg1nA8qurjtutxLiHCB+5t+VBCJM07ScAa9CpzpSc1QBNQOyrkNHn VPkg== X-Gm-Message-State: AOJu0YxEgeg7jWzxvnaxnuGjHMFPmWrylp/UjLH8gwBolcawVAQSDS+f zrhjFTW/cs26PKoExX3B/OoW+ipPYG3O9yqBoYURuzJq9EW2CAqp X-Received: by 2002:a05:622a:1c3:b0:429:9a2b:89d7 with SMTP id t3-20020a05622a01c300b004299a2b89d7mr286776qtw.92.1704926778742; Wed, 10 Jan 2024 14:46:18 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.46.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:46:18 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 25/38] tcg/i386: Improve TSTNE/TESTEQ vs powers of two Date: Thu, 11 Jan 2024 09:43:55 +1100 Message-Id: <20240110224408.10444-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82d; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82d.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, T_SCC_BODY_TEXT_LINE=-0.01 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 "test x,x" when the bit is one of the 4 sign bits. Use "bt imm,x" otherwise. Signed-off-by: Richard Henderson --- tcg/i386/tcg-target-con-set.h | 6 ++-- tcg/i386/tcg-target-con-str.h | 1 + tcg/i386/tcg-target.c.inc | 54 +++++++++++++++++++++++++++++++---- 3 files changed, 53 insertions(+), 8 deletions(-) diff --git a/tcg/i386/tcg-target-con-set.h b/tcg/i386/tcg-target-con-set.h index 7d00a7dde8..e24241cfa2 100644 --- a/tcg/i386/tcg-target-con-set.h +++ b/tcg/i386/tcg-target-con-set.h @@ -20,7 +20,7 @@ C_O0_I2(L, L) C_O0_I2(qi, r) C_O0_I2(re, r) C_O0_I2(ri, r) -C_O0_I2(r, re) +C_O0_I2(r, reT) C_O0_I2(s, L) C_O0_I2(x, r) C_O0_I3(L, L, L) @@ -34,7 +34,7 @@ C_O1_I1(r, r) C_O1_I1(x, r) C_O1_I1(x, x) C_O1_I2(q, 0, qi) -C_O1_I2(q, r, re) +C_O1_I2(q, r, reT) C_O1_I2(r, 0, ci) C_O1_I2(r, 0, r) C_O1_I2(r, 0, re) @@ -50,7 +50,7 @@ C_N1_I2(r, r, r) C_N1_I2(r, r, rW) C_O1_I3(x, 0, x, x) C_O1_I3(x, x, x, x) -C_O1_I4(r, r, re, r, 0) +C_O1_I4(r, r, reT, r, 0) C_O1_I4(r, r, r, ri, ri) C_O2_I1(r, r, L) C_O2_I2(a, d, a, r) diff --git a/tcg/i386/tcg-target-con-str.h b/tcg/i386/tcg-target-con-str.h index 95a30e58cd..cc22db227b 100644 --- a/tcg/i386/tcg-target-con-str.h +++ b/tcg/i386/tcg-target-con-str.h @@ -28,5 +28,6 @@ REGS('s', ALL_BYTEL_REGS & ~SOFTMMU_RESERVE_REGS) /* qemu_st8_i32 data */ */ CONST('e', TCG_CT_CONST_S32) CONST('I', TCG_CT_CONST_I32) +CONST('T', TCG_CT_CONST_TST) CONST('W', TCG_CT_CONST_WSZ) CONST('Z', TCG_CT_CONST_U32) diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index f2414177bd..0b8c60d021 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -132,6 +132,7 @@ static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) #define TCG_CT_CONST_U32 0x200 #define TCG_CT_CONST_I32 0x400 #define TCG_CT_CONST_WSZ 0x800 +#define TCG_CT_CONST_TST 0x1000 /* Registers used with L constraint, which are the first argument registers on x86_64, and two random call clobbered registers on @@ -202,7 +203,8 @@ static bool tcg_target_const_match(int64_t val, int ct, return 1; } if (type == TCG_TYPE_I32) { - if (ct & (TCG_CT_CONST_S32 | TCG_CT_CONST_U32 | TCG_CT_CONST_I32)) { + if (ct & (TCG_CT_CONST_S32 | TCG_CT_CONST_U32 | + TCG_CT_CONST_I32 | TCG_CT_CONST_TST)) { return 1; } } else { @@ -215,6 +217,17 @@ static bool tcg_target_const_match(int64_t val, int ct, if ((ct & TCG_CT_CONST_I32) && ~val == (int32_t)~val) { return 1; } + /* + * This will be used in combination with TCG_CT_CONST_S32, + * so "normal" TESTQ is already matched. Also accept: + * TESTQ -> TESTL (uint32_t) + * TESTQ -> BT (is_power_of_2) + */ + if ((ct & TCG_CT_CONST_TST) + && is_tst_cond(cond) + && (val == (uint32_t)val || is_power_of_2(val))) { + return 1; + } } if ((ct & TCG_CT_CONST_WSZ) && val == (type == TCG_TYPE_I32 ? 32 : 64)) { return 1; @@ -396,6 +409,7 @@ static bool tcg_target_const_match(int64_t val, int ct, #define OPC_SHLX (0xf7 | P_EXT38 | P_DATA16) #define OPC_SHRX (0xf7 | P_EXT38 | P_SIMDF2) #define OPC_SHRD_Ib (0xac | P_EXT) +#define OPC_TESTB (0x84) #define OPC_TESTL (0x85) #define OPC_TZCNT (0xbc | P_EXT | P_SIMDF3) #define OPC_UD2 (0x0b | P_EXT) @@ -442,6 +456,12 @@ static bool tcg_target_const_match(int64_t val, int ct, #define OPC_GRP3_Ev (0xf7) #define OPC_GRP5 (0xff) #define OPC_GRP14 (0x73 | P_EXT | P_DATA16) +#define OPC_GRPBT (0xba | P_EXT) + +#define OPC_GRPBT_BT 4 +#define OPC_GRPBT_BTS 5 +#define OPC_GRPBT_BTR 6 +#define OPC_GRPBT_BTC 7 /* Group 1 opcode extensions for 0x80-0x83. These are also used as modifiers for OPC_ARITH. */ @@ -1454,7 +1474,7 @@ static void tcg_out_jxx(TCGContext *s, int opc, TCGLabel *l, bool small) static int tcg_out_cmp(TCGContext *s, TCGCond cond, TCGArg arg1, TCGArg arg2, int const_arg2, int rexw) { - int jz; + int jz, js; if (!is_tst_cond(cond)) { if (!const_arg2) { @@ -1469,6 +1489,7 @@ static int tcg_out_cmp(TCGContext *s, TCGCond cond, TCGArg arg1, } jz = tcg_cond_to_jcc[cond]; + js = (cond == TCG_COND_TSTNE ? JCC_JS : JCC_JNS); if (!const_arg2) { tcg_out_modrm(s, OPC_TESTL + rexw, arg1, arg2); @@ -1476,17 +1497,40 @@ static int tcg_out_cmp(TCGContext *s, TCGCond cond, TCGArg arg1, } if (arg2 <= 0xff && (TCG_TARGET_REG_BITS == 64 || arg1 < 4)) { + if (arg2 == 0x80) { + tcg_out_modrm(s, OPC_TESTB | P_REXB_R, arg1, arg1); + return js; + } tcg_out_modrm(s, OPC_GRP3_Eb | P_REXB_RM, EXT3_TESTi, arg1); tcg_out8(s, arg2); return jz; } if ((arg2 & ~0xff00) == 0 && arg1 < 4) { + if (arg2 == 0x8000) { + tcg_out_modrm(s, OPC_TESTB, arg1 + 4, arg1 + 4); + return js; + } tcg_out_modrm(s, OPC_GRP3_Eb, EXT3_TESTi, arg1 + 4); tcg_out8(s, arg2 >> 8); return jz; } + if (is_power_of_2(rexw ? arg2 : (uint32_t)arg2)) { + int jc = (cond == TCG_COND_TSTNE ? JCC_JB : JCC_JAE); + int sh = ctz64(arg2); + + rexw = (sh & 32 ? P_REXW : 0); + if ((sh & 31) == 31) { + tcg_out_modrm(s, OPC_TESTL | rexw, arg1, arg1); + return js; + } else { + tcg_out_modrm(s, OPC_GRPBT | rexw, OPC_GRPBT_BT, arg1); + tcg_out8(s, sh); + return jc; + } + } + if (rexw) { if (arg2 == (uint32_t)arg2) { rexw = 0; @@ -3399,7 +3443,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_brcond_i32: case INDEX_op_brcond_i64: - return C_O0_I2(r, re); + return C_O0_I2(r, reT); case INDEX_op_bswap16_i32: case INDEX_op_bswap16_i64: @@ -3447,11 +3491,11 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_setcond_i64: case INDEX_op_negsetcond_i32: case INDEX_op_negsetcond_i64: - return C_O1_I2(q, r, re); + return C_O1_I2(q, r, reT); case INDEX_op_movcond_i32: case INDEX_op_movcond_i64: - return C_O1_I4(r, r, re, r, 0); + return C_O1_I4(r, r, reT, r, 0); case INDEX_op_div2_i32: case INDEX_op_div2_i64: From patchwork Wed Jan 10 22:43:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761480 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2112698wrz; Wed, 10 Jan 2024 14:47:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IF9293GG5p+yH/z0OptEXyZiTr5ZBbj5OiXYVHi6Aa8PMsGVkntCiB839WCWmGj6BNsxj2D X-Received: by 2002:a05:620a:149b:b0:783:2b35:30b6 with SMTP id w27-20020a05620a149b00b007832b3530b6mr318078qkj.33.1704926851779; Wed, 10 Jan 2024 14:47:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926851; cv=none; d=google.com; s=arc-20160816; b=r/r4+rVpalUTDWTgVH53X8DR24mYQsvSWtS+VuOrmE+wI/t1b4gw+0kNBkxb8y67sF eNklxYqdP0B5tQLaUnmekYTO7WdjyqQaqamP9KWHq6TC+JXeXergWiy5r+XGG3s83zVF Lbg8xNCxYK2kv4X5sFzDESyOSOH/j3Jj/XC3SxBHWAyJySk5mmllRECur724cWCqebjE uR1WV6dBvjyTuFmMnQcm3QbZOjdpvMC3sMWgs3ltgBDXQSxB/8cA80klVbvUmUmCwz2d IPsKkAihoshGNPZwPLXn71ob9/ZVN33k3QVcdWnmO+no69DpUN9kLWgr0ntX7N/WCtBN TbFQ== 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=m/PSbURQMO52LKiUV65FsmYmXzuvt6ozdqSCCbVOxK8=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=S64dIKkPUXhdqIFg3UbkgyGlVcPejqcbwQIXOG0wcQbW//0iqTYylhp3Uatyz1w55M ysssZt32/39EkKrQ4rNa+L3i0K+csS0MueqUQv53+ErM5gAbFHv7Yy5SvfyZEnclfIoJ cD9KbVh/C7kDe2VZSb7LxzsY0Uj077P+uBfSvT0D+PsopxFyDOxpJyMbR3hjNqYoBWky OLHfFZfmtI+UF+1TS7zP1FUY7IUoIk2dNVVapteLB6hyBpliTSsa4q3y1b43sryYkPN3 YfRjfi4tHn3oNLeChGOzMEyMO3kOWppewSntWfdr3nTyzFcA+bGsO9wd8qsuT6M52myH xy5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C065TA8G; 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 d6-20020a05620a158600b007815f50b903si4843638qkk.188.2024.01.10.14.47.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:47:31 -0800 (PST) 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=C065TA8G; 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 1rNhLS-0008MY-6S; Wed, 10 Jan 2024 17:46:46 -0500 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 1rNhL9-0006sy-99 for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:29 -0500 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhL6-0003QE-PB for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:26 -0500 Received: by mail-qt1-x832.google.com with SMTP id d75a77b69052e-429be9fe952so2186491cf.0 for ; Wed, 10 Jan 2024 14:46:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926782; x=1705531582; 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=m/PSbURQMO52LKiUV65FsmYmXzuvt6ozdqSCCbVOxK8=; b=C065TA8G0eeCEUZ49nPcOFNJjI6v78hrxOZ5nnrqUpXf23RARp6YlKJaSjDMUxF0jB ZUnU1EpPeupJi75H3IzP11qrb0IylxRyru93qGDnMcmqLPFPKfKSUNTJVCvhxcAv1QFL jvBTyNVMyVw0MiJpaI6jXtVV4iL85t4odQVjlQd+fM4hvyNQgYAqdBhTi49LgNsU8icI LlCdqkXFTiJVwFLDpCSVz2miOsIe71TUq1Pxs010eCfF9Ewab8Z6xIZeUjRlDsHa5g/i DbgZUUfB6uMP+Bx0QTDa28jA+wd2BhjVTPIjAXgIv6sxdYCvoyZO4bePehvQSiKHPB3i /zYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926782; x=1705531582; 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=m/PSbURQMO52LKiUV65FsmYmXzuvt6ozdqSCCbVOxK8=; b=iZhHSbM/8DsDfsUkiXBOBf7VkC5Ii/j3ZcqDExGQpoA2JUCuV1ACQsM0uTGKsae8wH dJadzQq+jQJx1g3aPFfhEjK02PIeZm0Q3v4+nmw6c/08X6ACXAKsUWSLe/qAD34Q0QtB 8KIm7V0nqqVT30UBUnboJfC8E6JcsABz+0YcERYaSHz2TIUy17pCFzZxnePY/ap0vG3M +lPajihs5mi9Jf94T3yEq5JDQsxChMhWyELe0Myx7yGcLtE5m6tj2FWAQ42TzxBtLY70 vU0ydk/mudpV5y2WyR9pj4Y8AfgayefHC2Xa5TN+dlvAJe1w1SGtl6aDRu50DBe6GV81 c1mg== X-Gm-Message-State: AOJu0YxHgA86hWCrYV0OhVfm9Bzjrp0F+rtQol0bT5nhFhNlVM+ksXcb pRl3HfMe6gr/s2wVfkf74y94AdZVsMpAoHxbQkVPhBCktaMGHVup X-Received: by 2002:ac8:4e4e:0:b0:429:bccc:31ca with SMTP id e14-20020ac84e4e000000b00429bccc31camr265106qtw.46.1704926782170; Wed, 10 Jan 2024 14:46:22 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.46.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:46:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 26/38] tcg/i386: Use TEST r,r to test 8/16/32 bits Date: Thu, 11 Jan 2024 09:43:56 +1100 Message-Id: <20240110224408.10444-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::832; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x832.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Paolo Bonzini Just like when testing against the sign bits, TEST r,r can be used when the immediate is 0xff, 0xff00, 0xffff, 0xffffffff. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tcg/i386/tcg-target.c.inc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 0b8c60d021..c6ba498623 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1501,6 +1501,10 @@ static int tcg_out_cmp(TCGContext *s, TCGCond cond, TCGArg arg1, tcg_out_modrm(s, OPC_TESTB | P_REXB_R, arg1, arg1); return js; } + if (arg2 == 0xff) { + tcg_out_modrm(s, OPC_TESTB | P_REXB_R, arg1, arg1); + return jz; + } tcg_out_modrm(s, OPC_GRP3_Eb | P_REXB_RM, EXT3_TESTi, arg1); tcg_out8(s, arg2); return jz; @@ -1511,11 +1515,24 @@ static int tcg_out_cmp(TCGContext *s, TCGCond cond, TCGArg arg1, tcg_out_modrm(s, OPC_TESTB, arg1 + 4, arg1 + 4); return js; } + if (arg2 == 0xff00) { + tcg_out_modrm(s, OPC_TESTB, arg1 + 4, arg1 + 4); + return jz; + } tcg_out_modrm(s, OPC_GRP3_Eb, EXT3_TESTi, arg1 + 4); tcg_out8(s, arg2 >> 8); return jz; } + if (arg2 == 0xffff) { + tcg_out_modrm(s, OPC_TESTL | P_DATA16, arg1, arg1); + return jz; + } + if (arg2 == 0xffffffffu) { + tcg_out_modrm(s, OPC_TESTL, arg1, arg1); + return jz; + } + if (is_power_of_2(rexw ? arg2 : (uint32_t)arg2)) { int jc = (cond == TCG_COND_TSTNE ? JCC_JB : JCC_JAE); int sh = ctz64(arg2); From patchwork Wed Jan 10 22:43:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761494 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2113170wrz; Wed, 10 Jan 2024 14:49:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IGgPmNEKdfvCpPKzmYePHCl6qb+ESn4uEau7w12O4+hdwHE8JeG+mrQAdUetxyJbRK2WINP X-Received: by 2002:ac8:5d54:0:b0:429:b213:3864 with SMTP id g20-20020ac85d54000000b00429b2133864mr270458qtx.28.1704926940692; Wed, 10 Jan 2024 14:49:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926940; cv=none; d=google.com; s=arc-20160816; b=u/qKKjo1cUD62ePtNhsnG22Cp4CgcYq7NYuaQR6a3xQRHhnxcsW61UUi1b3JO12iSC Wqe2mafWGZ/BiEE88GGEnVZ2fzqGv+rgt9KFhUJDOXcujZ5nm/CsgZhHyAIKVmxrFF/y UByXaLs+/H4lKyGsNLs17klbadsZd8GTZfsBG3Ny1ypmfM/lJ/UFmpxPvs3oBLdNVL2V QJdCWuGjKMnHdd4mEsPF3BoiREWycyujOvWHHU9G4h67ZsEIxwcnKvl0geUBnBIB+4w/ GNItBdPb1ULhHhru7cH+nttiBrztySq/7UTp54p4aBI1M6EdI44TU4x7zMAZqMdeVnKG jl4A== 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=w7DMJgHEIfczGa+x10sgEDsRXfwUGwOd6p01k71b3vA=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=vB7kif7PYi9b7Xw3i5Hq1Vs08EaHtFe1s3yQ2XnXWsERKYTFJt74QwMR2iFAONdCjM VTHyh9Ve83xGB7xXy/h7JlR908yeOrde53BqJ6vYWY+o6/BIkesEoubURjyKGWxafX2E iK/Zbd2m6F/D8k5ZaU/Hmkacv5mYgJWlFiVTJVR42VEV8C2L/tu9ePiDkYNOHAANHUsR VivkpJ3PGf3QuBeWWXqQJU6lXk1fX7ogCjNZQz5yiWSjj6mkrdpHK0kpx2E1X0dP9OLq VzI0CAdT3VnLXnDqduoCiwFNmSt6YbYf2827VhswKj4CxCBI1gXtsg+GmmQe0pam9SLK 6yDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j82y+K2l; 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 m17-20020a05622a055100b00429948c78d3si4970872qtx.652.2024.01.10.14.49.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:49:00 -0800 (PST) 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=j82y+K2l; 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 1rNhLT-0008PF-Uy; Wed, 10 Jan 2024 17:46:48 -0500 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 1rNhLA-0006tC-Oe for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:30 -0500 Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhL9-0003Rt-0P for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:28 -0500 Received: by mail-qt1-x835.google.com with SMTP id d75a77b69052e-429bd0f2768so4531611cf.0 for ; Wed, 10 Jan 2024 14:46:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926786; x=1705531586; 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=w7DMJgHEIfczGa+x10sgEDsRXfwUGwOd6p01k71b3vA=; b=j82y+K2l0leGQgZ+QZmTUgdXc2zK9PzMCQEt7BAdQVZZiXooUZQKPysSaXpOieTVkN 3glsoxyrcSeVlYCdqafJaa2A+bVaL8Y7XV6Vu/A6yFDOeqmedCrgVGTGBEnNqJrycTr7 509Jo7AAYb4ljkGwSy6e9pWBi0M6bjBD3AGv/agcallmYSm83QfFgo629Ybj0YqMZO7f k702TsuzPA+GRluINsXaviVirrkAIinuXBCnfuEjuaJQbfISB464ro3UUitKy+Jgg34o +pnkkOvhz1xAzwFkWCVrAGdjtUVQlT2FRkwu8zlRDDXkJzs4AQhtX6ThVIBI1IVfnQAU JGGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926786; x=1705531586; 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=w7DMJgHEIfczGa+x10sgEDsRXfwUGwOd6p01k71b3vA=; b=HHcqsL3M5oqct1tANhp9m34ocdYDh7RfhwNFAcUdi6iwJ/ODq25urGuVZbz/1N9mbz wfT11dwlSw0aODi142PbCgwMGKSI0OsJkvvzBg0CCwKiPxYVxVW1XPQNJ8nBKyQcoIVL szjzeTFSeA0Jwnu0kULtceMR5e8+Tro6CBs4cvEcT0TKkTEaaR+GSFf8ZpjtLKHZTBRm 4KDFx162DcmEhYgGNrDI8ttCnq7yCAl7d2UqAmZZyzHGT5Cdka/wYbXLVpL29JqVPyqp gpCzCXFU0yg3Wgu/GAkZzwafreEL0B1uui0DfnGbPRprxTm0K/wNgfMv6tOspU3g2aVz JM3A== X-Gm-Message-State: AOJu0Yyyh6PfrAcX3xd8PTtpMnOIXuHCQwWbR8Xwi1Hkag1SD0iduA/q EFmwER+bfIpqasscWyN//iCfLDwJGzu3GCqeiDXsaXK1lNak6vdq X-Received: by 2002:ac8:60c5:0:b0:429:bdd1:7f3d with SMTP id i5-20020ac860c5000000b00429bdd17f3dmr948355qtm.8.1704926785743; Wed, 10 Jan 2024 14:46:25 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.46.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:46:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 27/38] tcg/sparc64: Hoist read of tcg_cond_to_rcond Date: Thu, 11 Jan 2024 09:43:57 +1100 Message-Id: <20240110224408.10444-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::835; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x835.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, T_SCC_BODY_TEXT_LINE=-0.01 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. Reviewed-by: Philippe Mathieu-Daudé 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 ac86b92b75..e16b25e309 100644 --- a/tcg/sparc64/tcg-target.c.inc +++ b/tcg/sparc64/tcg-target.c.inc @@ -620,7 +620,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, @@ -679,7 +679,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) { @@ -688,7 +689,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); @@ -696,11 +697,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))); } @@ -711,9 +711,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); @@ -788,6 +788,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: @@ -807,9 +809,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); From patchwork Wed Jan 10 22:43:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761501 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2114063wrz; Wed, 10 Jan 2024 14:51:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEDv9SU8PrpaIMOF0lBxIAgV3/CBEq97rFVjCRjE73L/b0SiqfekRBRA9Xl0QHJ3iiVj0Sn X-Received: by 2002:a05:6214:2a84:b0:680:caa6:9612 with SMTP id jr4-20020a0562142a8400b00680caa69612mr209520qvb.111.1704927109476; Wed, 10 Jan 2024 14:51:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704927109; cv=none; d=google.com; s=arc-20160816; b=ApqCB4hQxubohbfQVmTL3M8Wq7YHnJ4NBy4wl8LTIsY2BbBl3+nrvPZPo/DX19/ZSr /MEdPYRySWhpIv54UDu9LEV+fBIFu/RIg7HdJ7JQQgpoHbT12vrVaFeRQe+BvM4tzlQ2 rAlRb3F63zrQqHTVVu/E6JkPGTh2HOEG25siVemSYRqvkoI0uhFx071t0qhFr/rw5bMD Ekvcly5J7k8X45xbfAeRTUCAD4R+3azw83+BOz/agLOSfSxBPghlX5/8TGAhUTPURkj0 dPT+GQfFt2Gr8EIeB4uOqNHlyp4v4fwv4A7fbUgcZusyreVXnRf1L55MMKdTkvOlWsOC 4MTA== 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=XTZQ8U70bvvwDjHMDYUT6Xyjxfqygw11gwaeaagFYFE=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=xY9cyIHTrn2GNcb5JNUEYBgMjpX9tilD0K5ZhfWhaMmdECfCnhCtxJSrrid8odseby 5lSji2rATmD3Q4xfB8+T47dnXTUD2L81hVDxDHPnjKhNAopgTuZhei73on4IrU3Uk8B6 /jXHJI/WphwlwMgV7+jjjsyvcc9/2QaBLAk5mEdMzeDEt97CTvrn4j7JRI6Mnnio4UQg uDE94lv14OElm6bZdkIx/1QODEM7WklnKv9946iplUbV7aQQWeqCg46RkUhVR7mFWHvz n3Q+ChpMpkyQO8unbYBGRL3S00WA59rzPy5uFdSfSV4a2CSB68VBEMwPi8HnMyZBul8V IHBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="g15M/3H/"; 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 g13-20020a0cf08d000000b0067aa3dc3f68si5417326qvk.193.2024.01.10.14.51.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:51:49 -0800 (PST) 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="g15M/3H/"; 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 1rNhLR-0007ns-75; Wed, 10 Jan 2024 17:46:45 -0500 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 1rNhLF-0006z6-0a for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:34 -0500 Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhLC-0003Tc-Pr for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:32 -0500 Received: by mail-qk1-x72e.google.com with SMTP id af79cd13be357-78315243c11so329011685a.3 for ; Wed, 10 Jan 2024 14:46:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926789; x=1705531589; 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=XTZQ8U70bvvwDjHMDYUT6Xyjxfqygw11gwaeaagFYFE=; b=g15M/3H/vDmAZQVaIMz1eFhJ064GVoRA2JATYebIPDdqiTLksGB49UwDzPYAlE2c7R mxYzSApTpRKssQbpQo3R6ScX48x+SxGd9KgaWW28gS/iCJvFhrzSmI7vDSoNnUDVOEfM ASUAlniP29IWzhAjnPcNeyc417VmVmKQGIomHPbPesJ9OEgDuEYlRuteo8u8o35vnNy+ l0klal7gYG1CFoUZMxy7i4HGVCzFWbqytExhyp82fTD/xYcRqA4D7E3cuZ4pVzLO3ttd OQokVmhoETVMSNLFiUtaDpIsk7Jy7lRbICxotdkvycTd25+J0RccSMUqxFdTLv5kZQfS YqEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926789; x=1705531589; 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=XTZQ8U70bvvwDjHMDYUT6Xyjxfqygw11gwaeaagFYFE=; b=LnJIRLBtfZMJOUmukWrTQvI8LjQN9421FzPyQs2zEKfQhrhvmYSNGJN87uYfxonoCb X4rtUSsWXZejflvRHI5kt+eP9gzVwn0imui37Z/PqhacSy91aPknmsLANTASrVpnH+Rk jghCLTCt6L2v5DePv5loOO/hcNubEgeId0K2bQ3p+IK2fFmD1HWHkMvwxUAURlcxIzMu QUwEdZeOSTbGogTdyms3yEyeSdh5cB98z+OOXmp4+YPuyyXVfmzQNotB5l9b5Kdoj5T8 bnd9boBY6fczppfTX3y4ZD0AwMqmdmiay1Tz9kREaVy4cS+E/xhtIEtfCuRG9DOEbA6Q NaHA== X-Gm-Message-State: AOJu0YwjzM5ol0nD3UoPEqYLSFuNN8sgHVl6aMMF0S+Xhh6hrs924DXa ME9CV0xz0lynepgY+BD9WZuNgt70B53w9LfxycBVV+3JR27SUGsN X-Received: by 2002:ac8:7d13:0:b0:429:899c:7387 with SMTP id g19-20020ac87d13000000b00429899c7387mr246384qtb.128.1704926789658; Wed, 10 Jan 2024 14:46:29 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.46.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:46:28 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 28/38] tcg/sparc64: Pass TCGCond to tcg_out_cmp Date: Thu, 11 Jan 2024 09:43:58 +1100 Message-Id: <20240110224408.10444-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::72e; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72e.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/sparc64/tcg-target.c.inc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc index e16b25e309..10fb8a1a0d 100644 --- a/tcg/sparc64/tcg-target.c.inc +++ b/tcg/sparc64/tcg-target.c.inc @@ -646,7 +646,8 @@ static void tcg_out_bpcc(TCGContext *s, int scond, int flags, TCGLabel *l) tcg_out_bpcc0(s, scond, flags, off19); } -static void tcg_out_cmp(TCGContext *s, TCGReg c1, int32_t c2, int c2const) +static void tcg_out_cmp(TCGContext *s, TCGCond cond, + TCGReg c1, int32_t c2, int c2const) { tcg_out_arithc(s, TCG_REG_G0, c1, c2, c2const, ARITH_SUBCC); } @@ -654,7 +655,7 @@ static void tcg_out_cmp(TCGContext *s, TCGReg c1, int32_t c2, int c2const) static void tcg_out_brcond_i32(TCGContext *s, TCGCond cond, TCGReg arg1, int32_t arg2, int const_arg2, TCGLabel *l) { - tcg_out_cmp(s, arg1, arg2, const_arg2); + tcg_out_cmp(s, cond, arg1, arg2, const_arg2); tcg_out_bpcc(s, tcg_cond_to_bcond[cond], BPCC_ICC | BPCC_PT, l); tcg_out_nop(s); } @@ -671,7 +672,7 @@ static void tcg_out_movcond_i32(TCGContext *s, TCGCond cond, TCGReg ret, TCGReg c1, int32_t c2, int c2const, int32_t v1, int v1const) { - tcg_out_cmp(s, c1, c2, c2const); + tcg_out_cmp(s, cond, c1, c2, c2const); tcg_out_movcc(s, cond, MOVCC_ICC, ret, v1, v1const); } @@ -691,7 +692,7 @@ static void tcg_out_brcond_i64(TCGContext *s, TCGCond cond, TCGReg arg1, tcg_out32(s, INSN_OP(0) | INSN_OP2(3) | BPR_PT | INSN_RS1(arg1) | INSN_COND(rcond) | off16); } else { - tcg_out_cmp(s, arg1, arg2, const_arg2); + tcg_out_cmp(s, cond, arg1, arg2, const_arg2); tcg_out_bpcc(s, tcg_cond_to_bcond[cond], BPCC_XCC | BPCC_PT, l); } tcg_out_nop(s); @@ -715,7 +716,7 @@ static void tcg_out_movcond_i64(TCGContext *s, TCGCond cond, TCGReg ret, 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_cmp(s, cond, c1, c2, c2const); tcg_out_movcc(s, cond, MOVCC_XCC, ret, v1, v1const); } } @@ -759,13 +760,13 @@ static void tcg_out_setcond_i32(TCGContext *s, TCGCond cond, TCGReg ret, /* FALLTHRU */ default: - tcg_out_cmp(s, c1, c2, c2const); + tcg_out_cmp(s, cond, c1, c2, c2const); tcg_out_movi_s13(s, ret, 0); tcg_out_movcc(s, cond, MOVCC_ICC, ret, neg ? -1 : 1, 1); return; } - tcg_out_cmp(s, c1, c2, c2const); + tcg_out_cmp(s, cond, c1, c2, c2const); if (cond == TCG_COND_LTU) { if (neg) { /* 0 - 0 - C = -C = (C ? -1 : 0) */ @@ -799,7 +800,7 @@ static void tcg_out_setcond_i64(TCGContext *s, TCGCond cond, TCGReg ret, c2 = c1, c2const = 0, c1 = TCG_REG_G0; /* FALLTHRU */ case TCG_COND_LTU: - tcg_out_cmp(s, c1, c2, c2const); + tcg_out_cmp(s, cond, c1, c2, c2const); tcg_out_arith(s, ret, TCG_REG_G0, TCG_REG_G0, ARITH_ADDXC); return; default: @@ -814,7 +815,7 @@ static void tcg_out_setcond_i64(TCGContext *s, TCGCond cond, TCGReg ret, tcg_out_movi_s13(s, ret, 0); tcg_out_movr(s, rcond, ret, c1, neg ? -1 : 1, 1); } else { - tcg_out_cmp(s, c1, c2, c2const); + tcg_out_cmp(s, cond, c1, c2, c2const); tcg_out_movi_s13(s, ret, 0); tcg_out_movcc(s, cond, MOVCC_XCC, ret, neg ? -1 : 1, 1); } @@ -1102,7 +1103,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h, tcg_out_movi_s32(s, TCG_REG_T3, compare_mask); tcg_out_arith(s, TCG_REG_T3, addr_reg, TCG_REG_T3, ARITH_AND); } - tcg_out_cmp(s, TCG_REG_T2, TCG_REG_T3, 0); + tcg_out_cmp(s, TCG_COND_NE, TCG_REG_T2, TCG_REG_T3, 0); ldst = new_ldst_label(s); ldst->is_ld = is_ld; From patchwork Wed Jan 10 22:43:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761500 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2113284wrz; Wed, 10 Jan 2024 14:49:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IFdkGRMJe2LhVAjrm0Bk/28T9xOxcsNgRPzz1WB6rIVUvHNV6/cerGvUzdHUtXNDRtgkdWW X-Received: by 2002:ac8:5a12:0:b0:429:b138:ddc7 with SMTP id n18-20020ac85a12000000b00429b138ddc7mr300843qta.47.1704926956490; Wed, 10 Jan 2024 14:49:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926956; cv=none; d=google.com; s=arc-20160816; b=oL3YPSOA5BakQ3ci9F1P6ILrTnq3V0ZtugnW0+Cr8GQp3mnOQ4Z7aHeWFZmnc8emZB Rjln/rI5KXn+LQKqeoCU5hwXnp5PuHv3NeEFWVlNMqOFHJ5XU8efpwcV9dul6jp3REcr FqFqU4Hg20XA5LjCTOxL4U3Le0xHkFPXCs9mMCfO0pGcEPpKJ2wPq3SPDyJiatN2ZwIP rRtdmBty4/1s8SisLBSX/5fR1ht/yHLe+or5qRYXx/Qs0IdIH4yRoliYqOroTIrIDmqt z22XjW9yDkrAdq9Ovzob/kbEGlYbkzsELWWnyty9ePIzLfiymyLoohE3xizyvNaYdYbE 4meg== 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=J7nkcnvR7yCW819cN0Z1TIqZ24aA0LLfk5m6dHETDfI=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=clJdHSIAw613im5sxht1xyvQ2DbCE3obUrjDUjDdJYWmvxhRCYLILdK2M+0vxuZxvN WIvFNvQE9skr9ZGNgTTbE1BuUuFN/f8HSYwWTifU87KXbfsHbAuF+JMOMwi77gNssn5D q4KJS6lnN7vJ7f3J9X8oO00PHlQl8LfnonyE5h+ozR+NMpnsBaxoFhTFa4+Ini1cCcra kCpw7Y4N0j0YQUGYyHpQG84MCubpwy+iWkvEVDKeZMKNf8tlarjI8aYJtGK5EfTZwgRy 6upePzY5qWcpF1Zi/cQWimaFBxjjBWqj+CCqrhPpg520XA2QV4uYmSBT+mVfaXI/3VKT 6fTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MkjhyO09; 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 h10-20020ac8584a000000b004297c14453asi5191600qth.780.2024.01.10.14.49.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:49:16 -0800 (PST) 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=MkjhyO09; 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 1rNhLT-0008P2-PH; Wed, 10 Jan 2024 17:46:47 -0500 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 1rNhLI-00073i-KO for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:36 -0500 Received: from mail-qt1-x82b.google.com ([2607:f8b0:4864:20::82b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhLG-0003Vd-5s for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:35 -0500 Received: by mail-qt1-x82b.google.com with SMTP id d75a77b69052e-427e55a172bso31676561cf.2 for ; Wed, 10 Jan 2024 14:46:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926793; x=1705531593; 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=J7nkcnvR7yCW819cN0Z1TIqZ24aA0LLfk5m6dHETDfI=; b=MkjhyO09ZUxeIt5xe8bRl8Ew8h/ojQ5fd10BMTx+0GIteKd5jPInzsdUSkEdQLQ7D5 OPnXZVsu0npI9O7fhyuWk7TDF6NJdn95N9Kg7UZb+dGrlNQKEsPg9EDjtCHBpEgfanQa Ngy2m+wxqeHGwZwnUN07ofkNB2XhrJbKHtny1M3o37LlYg1VQurv10ot0wz20t/sCjOE 3AKjFATTNkAp7YKLMdA/w8woq8yrWyYJcyZGrdXBkRjnL5GDl9ejJyYBhqIGQVnX2Fbz w/DgujUzTaR81yYtY+AfWsyz3nDIE0NNAsrJNIq+7guRgKIRHsbIR8gPCwb4gI1ARaOX ektg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926793; x=1705531593; 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=J7nkcnvR7yCW819cN0Z1TIqZ24aA0LLfk5m6dHETDfI=; b=QuhtGxAs5zk425oAPhaWPuZJZ2FblFZe+Ee8O7SLFEbQCBOj3BSDXoeOHfLs6tx0+p nZ6Q6ZW7U5kQMEdhXJhqIyXihveF52i+MI1+DaWf83up1mhwX2ihAh8t2uJzAtCjZ9yD oASlNvWUqCAmq3/qfRZ20YAV7VlDVbCMUvQXBv0jdn+6kKPvg8168YpKvi/OqrmnnC2T qj4rfJAAy7QqUM0pNOYj70WdjolnOJ6xC2Q78YGxJBHnHjfGcaNHqJ7+eb1AX9lghZBM /i9y0FkmyAVbPSd/2aLHD3zZaEWAFL0Ud0q5LqeFipAaGGXSBgE03+CrtQpXoGclyep+ UE1g== X-Gm-Message-State: AOJu0YyxL3rARZAMTavId2wssWIuHQJy6bllKix6wfJ4qGdlcpSA1XuL oY+O6MrJtSWpXjOz2J0CZA9Jjh1+COvY0HnP+X+CtmnIkoCpLHKk X-Received: by 2002:a05:622a:301:b0:429:a565:8df9 with SMTP id q1-20020a05622a030100b00429a5658df9mr291761qtw.61.1704926793059; Wed, 10 Jan 2024 14:46:33 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.46.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:46:32 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 29/38] tcg/sparc64: Support TCG_COND_TST{EQ,NE} Date: Thu, 11 Jan 2024 09:43:59 +1100 Message-Id: <20240110224408.10444-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82b; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82b.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/sparc64/tcg-target.h | 2 +- tcg/sparc64/tcg-target.c.inc | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tcg/sparc64/tcg-target.h b/tcg/sparc64/tcg-target.h index ae2910c4ee..a18906a14e 100644 --- a/tcg/sparc64/tcg-target.h +++ b/tcg/sparc64/tcg-target.h @@ -149,7 +149,7 @@ extern bool use_vis3_instructions; #define TCG_TARGET_HAS_qemu_ldst_i128 0 -#define TCG_TARGET_HAS_tst 0 +#define TCG_TARGET_HAS_tst 1 #define TCG_AREG0 TCG_REG_I0 diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc index 10fb8a1a0d..176c98740b 100644 --- a/tcg/sparc64/tcg-target.c.inc +++ b/tcg/sparc64/tcg-target.c.inc @@ -607,9 +607,11 @@ static void tcg_out_div32(TCGContext *s, TCGReg rd, TCGReg rs1, uns ? ARITH_UDIV : ARITH_SDIV); } -static const uint8_t tcg_cond_to_bcond[] = { +static const uint8_t tcg_cond_to_bcond[16] = { [TCG_COND_EQ] = COND_E, [TCG_COND_NE] = COND_NE, + [TCG_COND_TSTEQ] = COND_E, + [TCG_COND_TSTNE] = COND_NE, [TCG_COND_LT] = COND_L, [TCG_COND_GE] = COND_GE, [TCG_COND_LE] = COND_LE, @@ -649,7 +651,8 @@ static void tcg_out_bpcc(TCGContext *s, int scond, int flags, TCGLabel *l) static void tcg_out_cmp(TCGContext *s, TCGCond cond, TCGReg c1, int32_t c2, int c2const) { - tcg_out_arithc(s, TCG_REG_G0, c1, c2, c2const, ARITH_SUBCC); + tcg_out_arithc(s, TCG_REG_G0, c1, c2, c2const, + is_tst_cond(cond) ? ARITH_ANDCC : ARITH_SUBCC); } static void tcg_out_brcond_i32(TCGContext *s, TCGCond cond, TCGReg arg1, @@ -744,6 +747,15 @@ static void tcg_out_setcond_i32(TCGContext *s, TCGCond cond, TCGReg ret, cond = (cond == TCG_COND_EQ ? TCG_COND_GEU : TCG_COND_LTU); break; + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + /* Transform to inequality vs zero. */ + tcg_out_arithc(s, TCG_REG_T1, c1, c2, c2const, ARITH_AND); + c1 = TCG_REG_G0; + c2 = TCG_REG_T1, c2const = 0; + cond = (cond == TCG_COND_TSTEQ ? TCG_COND_GEU : TCG_COND_LTU); + break; + case TCG_COND_GTU: case TCG_COND_LEU: /* If we don't need to load a constant into a register, we can From patchwork Wed Jan 10 22:44:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761485 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2112795wrz; Wed, 10 Jan 2024 14:47:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IFLJDXo7rXk3vkOVQnEOTiTL/ER+hXOHQihQfbSdJxvH537PVTqGMGRqa4LXNnsFY/gD05T X-Received: by 2002:a05:6214:1bc5:b0:681:2461:5ca with SMTP id m5-20020a0562141bc500b00681246105camr244873qvc.37.1704926870268; Wed, 10 Jan 2024 14:47:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926870; cv=none; d=google.com; s=arc-20160816; b=TpbM7cY0z2IyE8K21IVTVyyzNw0qzu8ibIYkXPA6ndzhf/D3xfys+zMzx/00ovDxfT VRzTWNZshXd/veogPtVVIpTfTymBLt7W7UeYEJ/j5GkRQOS3278rCmqpWIpR6Bi1eLCA pznMMgK/RWYu8vGxBMBBciFWIESsZQ8JPmw4KtLJvp/ZvYEM/g2eEvMbmbsPEit4bPTA RQxpH2OQ9FWdw4ml65/bwjr1M05bUjWyeGyWCUXwWtY48150qPOQg4T+KAuvFm5UNukJ O10VB0mpMmX1GXPafONmMUJ3XytJ/rVP8/8eLuPs9cuv08nlbeZx4Wh6Rby/X6FGl7hu VBjQ== 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=Njou8078FZIGaih/KmoVshAEm+KpvJ/TDJRnizv9npg=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=bdJMPAwSZlOws07L6lboQPXX15F4q87Yzjh0JOCZ7FpvTnhxlKrBMRD1KQHQrMsx6l USxpR8bUJkJMqiAKqKrJKKTdY2AD4WnMz6PS4Oi/f54EmSBRZ58KR3g9YTkhxj2Z2BFo vPGUglqzil3Pspe5QzgRF3IR3D4lqqdDUSaWhkRsU3zDl5wb+h10b8JIJb8idjGglS2a YdD4K2kKFJAUIwAnHGzNpZsUAk8oJZXeU1hz3xEq3qtWDIaD1ENZOVYvGQHmpR4O9fKV WiCnyOaPyv29jvhGw5KDIomwDS/T9AVMuYExXlwRqYDT/3qbUKZ/Tdk6FOvInA3R8Jtf I5Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=laCXAx+1; 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 d5-20020a0ce445000000b0067f14fbeb3dsi5251886qvm.51.2024.01.10.14.47.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:47:50 -0800 (PST) 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=laCXAx+1; 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 1rNhLV-0008Sn-JM; Wed, 10 Jan 2024 17:46:49 -0500 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 1rNhLL-0007UC-Jh for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:39 -0500 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhLJ-0003Yj-K9 for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:39 -0500 Received: by mail-qt1-x834.google.com with SMTP id d75a77b69052e-427f21ced6aso30334331cf.1 for ; Wed, 10 Jan 2024 14:46:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926796; x=1705531596; 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=Njou8078FZIGaih/KmoVshAEm+KpvJ/TDJRnizv9npg=; b=laCXAx+1wcStctR2BZGWoWFTvb8aRcK6iSGCh0GIL6BhcG6k1PWpMwBvj8OYp1LVWF /S/QatoEU/tCrNtOl/oVm245XqvS64shICZc1ibOeRfztHNW5P3L475J2l/uDU7OBh24 3x6qBo5pqIBfxThrRXMS8o8XxQ+vzoakNlZhJhFILU6itzqwmVbHjMVeYdTJjB5aMHVt wBB6D1+RL/jgEms/tm5SPR1vz2IT6W3ZGIAgFFIu/bBSPWgoSOlw37j7NZNPd697I2Ox /Xd01KL0fNIdAQlrJLRsgz66lYLjyJBBOvEaU75qEYH9R2IlKv4XCOmJlnxYwNffzYcE OwOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926796; x=1705531596; 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=Njou8078FZIGaih/KmoVshAEm+KpvJ/TDJRnizv9npg=; b=Fl/PreJ7mFulk1aBpRgkWmhhlTrioXYn7W5lchVQBCdwoewbF+sItXxG/QTDAiM8cv ZYU0uma5hPevMrBgeE2geB9vplVEMApGO+y87lqpdOwYb9ii/rYmiWP4HlI3KxBNUCVs e0+fKGOYvQfhpUfOkxUwbDX8oma5CsE65W5zFAlNpOX5SkIx74suRwmvbO5wpEnEaJtZ 8zL16vEzQkgEPlY/UUajH30w5p6xETT/HFzvDBfCqrbPQqVd7PVCHpZYmEbjdD0zYcgN 7usNrWPjhjJi7jOEBhn05C2ZtaxDEnotXyhsZ37rPnsemq5A1S+sHegMCHo0Ctr2Ehql S88Q== X-Gm-Message-State: AOJu0YwDRNkSInQ9wHrTsRb1joAm7A47AJ1/EO8aYB4QPpetldKXfY8g jkmJQbINFh7gS8C7ELfPB7vK24wFy2AtspvSKt/8/xx+fYGFHVKw X-Received: by 2002:a05:622a:3c9:b0:429:7f89:4868 with SMTP id k9-20020a05622a03c900b004297f894868mr293924qtx.65.1704926796708; Wed, 10 Jan 2024 14:46:36 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.46.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:46:36 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 30/38] tcg/ppc: Sink tcg_to_bc usage into tcg_out_bc Date: Thu, 11 Jan 2024 09:44:00 +1100 Message-Id: <20240110224408.10444-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::834; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x834.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Rename the current tcg_out_bc function to tcg_out_bc_lab, and create a new function that takes an integer displacement + link. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 850ace98b2..830d2fe73a 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -1946,14 +1946,20 @@ static void tcg_out_setcond(TCGContext *s, TCGType type, TCGCond cond, } } -static void tcg_out_bc(TCGContext *s, int bc, TCGLabel *l) +static void tcg_out_bc(TCGContext *s, TCGCond cond, int bd) { + tcg_out32(s, tcg_to_bc[cond] | bd); +} + +static void tcg_out_bc_lab(TCGContext *s, TCGCond cond, TCGLabel *l) +{ + int bd = 0; if (l->has_value) { - bc |= reloc_pc14_val(tcg_splitwx_to_rx(s->code_ptr), l->u.value_ptr); + bd = reloc_pc14_val(tcg_splitwx_to_rx(s->code_ptr), l->u.value_ptr); } else { tcg_out_reloc(s, s->code_ptr, R_PPC_REL14, l, 0); } - tcg_out32(s, bc); + tcg_out_bc(s, cond, bd); } static void tcg_out_brcond(TCGContext *s, TCGCond cond, @@ -1961,7 +1967,7 @@ static void tcg_out_brcond(TCGContext *s, TCGCond cond, TCGLabel *l, TCGType type) { tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 7, type); - tcg_out_bc(s, tcg_to_bc[cond], l); + tcg_out_bc_lab(s, cond, l); } static void tcg_out_movcond(TCGContext *s, TCGType type, TCGCond cond, @@ -2003,7 +2009,7 @@ static void tcg_out_movcond(TCGContext *s, TCGType type, TCGCond cond, } } /* Branch forward over one insn */ - tcg_out32(s, tcg_to_bc[cond] | 8); + tcg_out_bc(s, cond, 8); if (v2 == 0) { tcg_out_movi(s, type, dest, 0); } else { @@ -2024,11 +2030,11 @@ static void tcg_out_cntxz(TCGContext *s, TCGType type, uint32_t opc, tcg_out32(s, opc | RA(TCG_REG_R0) | RS(a1)); tcg_out32(s, tcg_to_isel[TCG_COND_EQ] | TAB(a0, a2, TCG_REG_R0)); } else if (!const_a2 && a0 == a2) { - tcg_out32(s, tcg_to_bc[TCG_COND_EQ] | 8); + tcg_out_bc(s, TCG_COND_EQ, 8); tcg_out32(s, opc | RA(a0) | RS(a1)); } else { tcg_out32(s, opc | RA(a0) | RS(a1)); - tcg_out32(s, tcg_to_bc[TCG_COND_NE] | 8); + tcg_out_bc(s, TCG_COND_NE, 8); if (const_a2) { tcg_out_movi(s, type, a0, 0); } else { @@ -2108,11 +2114,11 @@ static void tcg_out_setcond2(TCGContext *s, const TCGArg *args, tcg_out_rlw(s, RLWINM, args[0], TCG_REG_R0, 31, 31, 31); } -static void tcg_out_brcond2 (TCGContext *s, const TCGArg *args, - const int *const_args) +static void tcg_out_brcond2(TCGContext *s, const TCGArg *args, + const int *const_args) { tcg_out_cmp2(s, args, const_args); - tcg_out_bc(s, BC | BI(7, CR_EQ) | BO_COND_TRUE, arg_label(args[5])); + tcg_out_bc_lab(s, TCG_COND_EQ, arg_label(args[5])); } static void tcg_out_mb(TCGContext *s, TCGArg a0) @@ -2446,7 +2452,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h, /* Load a pointer into the current opcode w/conditional branch-link. */ ldst->label_ptr[0] = s->code_ptr; - tcg_out32(s, BC | BI(7, CR_EQ) | BO_COND_FALSE | LK); + tcg_out_bc(s, TCG_COND_NE, LK); h->base = TCG_REG_TMP1; } else { From patchwork Wed Jan 10 22:44:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761483 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2112777wrz; Wed, 10 Jan 2024 14:47:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IGtETxol0pywQcEe32b6Wl1KRKZ8g8DoFIPC0DhYodq/GrCNN6TnTWglpcKlROK5xbCwDuw X-Received: by 2002:a05:620a:2701:b0:783:2870:e816 with SMTP id b1-20020a05620a270100b007832870e816mr342614qkp.150.1704926867866; Wed, 10 Jan 2024 14:47:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926867; cv=none; d=google.com; s=arc-20160816; b=Clth4vt1eOshO/IH91qNSlk+Kvk3aUVqpH7TZWGCQsMVgdKMH0uMs2L8E3RdUx4v3l +h7i7McRd7iifPEYQOIlCmeqafHGwWUJvM8bwovMzOn2/VD2gp2nu5pgBJXQXl1Z83nN Y/nDDZgneqa0FVMqkhTngqbLIYPDpiptHQJDxEAJ15wJzQoOsFwxKAz1DY5htU4zk+ei jeFfKwsyks7jdycqRDk+Mj/JrGGxSYPKE5ZfwvCAJThU0QQCC91USG9KAXw8kvO6EzJV urGwenyTaTMBTvrAxx6cZ1q4bjMo0oKrGHgjpxXe+6JqbpioqRvtirk7NbhRwJVoOJa8 egSA== 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=3V+CWkXdNqNJeKthv/lyY08kBwUymIwSbvahoKExcsA=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=MdeHRKK3a+ez+dMBQYAyq+FJPGXJg7bgz9eTQLRXMAn+JgU1UFb3bXCe7njfrOVPeP Ib6oY9Kq0KMb1YBqnjXbr4A0JyVdHq79TXpfPUUqLzzM35yrY2AKruF9xY1MDoAG4HzM zehAAv7ji/o9oeMub3W5fGbBCipgnYdvvwhUkrE1ERP6+Kz6Dn/FsnWXVy8mUtxC8CTE v7kzRtv+DxkDHIIIEPtIDj5ev37dMLgUQn+fiucH45c23HwIpgVzD0slHQPBtmn01Pqz CUUWL9wVzsJBLqmBUjIVJWSMiFGRqxjB1u7n8QHdbi7HV0L9Y8D+kp8HQthvDPj7/hC9 B3dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sgQcaqVD; 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 pc18-20020a05620a841200b007831ed5564fsi4781060qkn.321.2024.01.10.14.47.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:47:47 -0800 (PST) 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=sgQcaqVD; 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 1rNhLX-0000JP-MW; Wed, 10 Jan 2024 17:46:51 -0500 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 1rNhLR-0008L8-2H for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:45 -0500 Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhLO-0003bY-8o for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:44 -0500 Received: by mail-qt1-x833.google.com with SMTP id d75a77b69052e-4299400fd94so20948261cf.2 for ; Wed, 10 Jan 2024 14:46:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926800; x=1705531600; 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=3V+CWkXdNqNJeKthv/lyY08kBwUymIwSbvahoKExcsA=; b=sgQcaqVDhrxnO4ZeTdfSaIJMdKeX46Fd6pjNoYtaS4wEuUtAzg8VLlzyUkBpIgLslL LQwx7pmB6u4Lee5DNroQx7jSsxIu8MjhEMxyr7RZyLEJGzBMOV9RcDMtNgi7zQfM8nea jIf0LMsMOOAmTWyN0d6CG0b3r8qEOumg4s8VpEKK58+MNmjQINOHaBiqQrvl8ay52EcT NQ4nVV8aZ6wULoOLN90iDUoXzvC1GmKUzVJdH8xQnnHr9POjn9LiT8Q3xAvXeAy3f1gF t3MbHEUoreOceIZubKqEwFLPgD4yRBj/JPT7xg7vak8TnOsJN/txBrawFx4uoLKSAdhc mzSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926800; x=1705531600; 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=3V+CWkXdNqNJeKthv/lyY08kBwUymIwSbvahoKExcsA=; b=RGtXSXtR9D2EEKn7dMRrMI9uRGCOcx6jtL20uaO0JmpLcynFuX13CW9M6bcsSzdoIa ZXRv3EeOTgdE6pdTHCn3Quu3pEvGsPqfefHWO/c+IJzBuC2p1gbrBmNYBnPO1C91MySp SMjb8T7fKY/kRjwAcDSfEINzT/ms1d4T3rH4+++jOSUKT+3gr94nkMq+FEZJ7TiNyOB1 F7pVnLEoMB3+h4yykmRJUATbKNaBKEguMXxAbT6WihG19uBo9sxPrqppccBhcAwljj8/ zkHSGR6WJxRYRrR/O+G78o/ZwcheeeTW+EZkLgKSK48OzZQfmL+C7FiQd4/BSV5oypGu Ni1g== X-Gm-Message-State: AOJu0Yxmk004Sjib7gPqAMXEwCeyGAFaRjtJjrn1Aj6j0+U0FfRqHlzO +aO2UoV0bgVHlM7/ybHp+mgz5qH6xpNIejucXsn10QNki1sKUXFb X-Received: by 2002:a05:622a:110:b0:429:c15c:7d91 with SMTP id u16-20020a05622a011000b00429c15c7d91mr27654qtw.137.1704926800705; Wed, 10 Jan 2024 14:46:40 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.46.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:46:40 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 31/38] tcg/ppc: Use cr0 in tcg_to_bc and tcg_to_isel Date: Thu, 11 Jan 2024 09:44:01 +1100 Message-Id: <20240110224408.10444-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::833; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x833.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Using cr0 means we could choose to use rc=1 to compute the condition. Adjust the tables and tcg_out_cmp that feeds them. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tcg/ppc/tcg-target.c.inc | 68 ++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 830d2fe73a..b9323baa86 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -671,30 +671,30 @@ enum { }; static const uint32_t tcg_to_bc[] = { - [TCG_COND_EQ] = BC | BI(7, CR_EQ) | BO_COND_TRUE, - [TCG_COND_NE] = BC | BI(7, CR_EQ) | BO_COND_FALSE, - [TCG_COND_LT] = BC | BI(7, CR_LT) | BO_COND_TRUE, - [TCG_COND_GE] = BC | BI(7, CR_LT) | BO_COND_FALSE, - [TCG_COND_LE] = BC | BI(7, CR_GT) | BO_COND_FALSE, - [TCG_COND_GT] = BC | BI(7, CR_GT) | BO_COND_TRUE, - [TCG_COND_LTU] = BC | BI(7, CR_LT) | BO_COND_TRUE, - [TCG_COND_GEU] = BC | BI(7, CR_LT) | BO_COND_FALSE, - [TCG_COND_LEU] = BC | BI(7, CR_GT) | BO_COND_FALSE, - [TCG_COND_GTU] = BC | BI(7, CR_GT) | BO_COND_TRUE, + [TCG_COND_EQ] = BC | BI(0, CR_EQ) | BO_COND_TRUE, + [TCG_COND_NE] = BC | BI(0, CR_EQ) | BO_COND_FALSE, + [TCG_COND_LT] = BC | BI(0, CR_LT) | BO_COND_TRUE, + [TCG_COND_GE] = BC | BI(0, CR_LT) | BO_COND_FALSE, + [TCG_COND_LE] = BC | BI(0, CR_GT) | BO_COND_FALSE, + [TCG_COND_GT] = BC | BI(0, CR_GT) | BO_COND_TRUE, + [TCG_COND_LTU] = BC | BI(0, CR_LT) | BO_COND_TRUE, + [TCG_COND_GEU] = BC | BI(0, CR_LT) | BO_COND_FALSE, + [TCG_COND_LEU] = BC | BI(0, CR_GT) | BO_COND_FALSE, + [TCG_COND_GTU] = BC | BI(0, CR_GT) | BO_COND_TRUE, }; /* The low bit here is set if the RA and RB fields must be inverted. */ static const uint32_t tcg_to_isel[] = { - [TCG_COND_EQ] = ISEL | BC_(7, CR_EQ), - [TCG_COND_NE] = ISEL | BC_(7, CR_EQ) | 1, - [TCG_COND_LT] = ISEL | BC_(7, CR_LT), - [TCG_COND_GE] = ISEL | BC_(7, CR_LT) | 1, - [TCG_COND_LE] = ISEL | BC_(7, CR_GT) | 1, - [TCG_COND_GT] = ISEL | BC_(7, CR_GT), - [TCG_COND_LTU] = ISEL | BC_(7, CR_LT), - [TCG_COND_GEU] = ISEL | BC_(7, CR_LT) | 1, - [TCG_COND_LEU] = ISEL | BC_(7, CR_GT) | 1, - [TCG_COND_GTU] = ISEL | BC_(7, CR_GT), + [TCG_COND_EQ] = ISEL | BC_(0, CR_EQ), + [TCG_COND_NE] = ISEL | BC_(0, CR_EQ) | 1, + [TCG_COND_LT] = ISEL | BC_(0, CR_LT), + [TCG_COND_GE] = ISEL | BC_(0, CR_LT) | 1, + [TCG_COND_LE] = ISEL | BC_(0, CR_GT) | 1, + [TCG_COND_GT] = ISEL | BC_(0, CR_GT), + [TCG_COND_LTU] = ISEL | BC_(0, CR_LT), + [TCG_COND_GEU] = ISEL | BC_(0, CR_LT) | 1, + [TCG_COND_LEU] = ISEL | BC_(0, CR_GT) | 1, + [TCG_COND_GTU] = ISEL | BC_(0, CR_GT), }; static bool patch_reloc(tcg_insn_unit *code_ptr, int type, @@ -1827,7 +1827,7 @@ static void tcg_out_setcond(TCGContext *s, TCGType type, TCGCond cond, if (have_isa_3_10) { tcg_insn_unit bi, opc; - tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 7, type); + tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 0, type); /* Re-use tcg_to_bc for BI and BO_COND_{TRUE,FALSE}. */ bi = tcg_to_bc[cond] & (0x1f << 16); @@ -1880,7 +1880,7 @@ static void tcg_out_setcond(TCGContext *s, TCGType type, TCGCond cond, if (have_isel) { int isel, tab; - tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 7, type); + tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 0, type); isel = tcg_to_isel[cond]; @@ -1966,7 +1966,7 @@ static void tcg_out_brcond(TCGContext *s, TCGCond cond, TCGArg arg1, TCGArg arg2, int const_arg2, TCGLabel *l, TCGType type) { - tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 7, type); + tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 0, type); tcg_out_bc_lab(s, cond, l); } @@ -1980,7 +1980,7 @@ static void tcg_out_movcond(TCGContext *s, TCGType type, TCGCond cond, return; } - tcg_out_cmp(s, cond, c1, c2, const_c2, 7, type); + tcg_out_cmp(s, cond, c1, c2, const_c2, 0, type); if (have_isel) { int isel = tcg_to_isel[cond]; @@ -2024,7 +2024,7 @@ static void tcg_out_cntxz(TCGContext *s, TCGType type, uint32_t opc, if (const_a2 && a2 == (type == TCG_TYPE_I32 ? 32 : 64)) { tcg_out32(s, opc | RA(a0) | RS(a1)); } else { - tcg_out_cmp(s, TCG_COND_EQ, a1, 0, 1, 7, type); + tcg_out_cmp(s, TCG_COND_EQ, a1, 0, 1, 0, type); /* Note that the only other valid constant for a2 is 0. */ if (have_isel) { tcg_out32(s, opc | RA(TCG_REG_R0) | RS(a1)); @@ -2079,7 +2079,7 @@ static void tcg_out_cmp2(TCGContext *s, const TCGArg *args, do_equality: tcg_out_cmp(s, cond, al, bl, blconst, 6, TCG_TYPE_I32); tcg_out_cmp(s, cond, ah, bh, bhconst, 7, TCG_TYPE_I32); - tcg_out32(s, op | BT(7, CR_EQ) | BA(6, CR_EQ) | BB(7, CR_EQ)); + tcg_out32(s, op | BT(0, CR_EQ) | BA(6, CR_EQ) | BB(7, CR_EQ)); break; case TCG_COND_LT: @@ -2097,8 +2097,8 @@ static void tcg_out_cmp2(TCGContext *s, const TCGArg *args, tcg_out_cmp(s, cond, ah, bh, bhconst, 6, TCG_TYPE_I32); tcg_out_cmp(s, cond2, al, bl, blconst, 7, TCG_TYPE_I32); - tcg_out32(s, op | BT(7, CR_EQ) | BA(6, CR_EQ) | BB(7, bit2)); - tcg_out32(s, CROR | BT(7, CR_EQ) | BA(6, bit1) | BB(7, CR_EQ)); + tcg_out32(s, op | BT(0, CR_EQ) | BA(6, CR_EQ) | BB(7, bit2)); + tcg_out32(s, CROR | BT(0, CR_EQ) | BA(6, bit1) | BB(0, CR_EQ)); break; default: @@ -2110,8 +2110,8 @@ static void tcg_out_setcond2(TCGContext *s, const TCGArg *args, const int *const_args) { tcg_out_cmp2(s, args + 1, const_args + 1); - tcg_out32(s, MFOCRF | RT(TCG_REG_R0) | FXM(7)); - tcg_out_rlw(s, RLWINM, args[0], TCG_REG_R0, 31, 31, 31); + tcg_out32(s, MFOCRF | RT(TCG_REG_R0) | FXM(0)); + tcg_out_rlw(s, RLWINM, args[0], TCG_REG_R0, CR_EQ + 0*4 + 1, 31, 31); } static void tcg_out_brcond2(TCGContext *s, const TCGArg *args, @@ -2442,12 +2442,12 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h, tcg_out_cmp(s, TCG_COND_EQ, addrhi, TCG_REG_TMP2, 0, 6, TCG_TYPE_I32); - /* Combine comparisons into cr7. */ - tcg_out32(s, CRAND | BT(7, CR_EQ) | BA(6, CR_EQ) | BB(7, CR_EQ)); + /* Combine comparisons into cr0. */ + tcg_out32(s, CRAND | BT(0, CR_EQ) | BA(6, CR_EQ) | BB(7, CR_EQ)); } else { - /* Full comparison into cr7. */ + /* Full comparison into cr0. */ tcg_out_cmp(s, TCG_COND_EQ, TCG_REG_R0, TCG_REG_TMP2, - 0, 7, addr_type); + 0, 0, addr_type); } /* Load a pointer into the current opcode w/conditional branch-link. */ From patchwork Wed Jan 10 22:44:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761487 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2112864wrz; Wed, 10 Jan 2024 14:48:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IGT26XakjpL+qn2yYJA0HR4BinZ+RVjYGqmoEKH+3cUmwCAyBX/WioHRJQt2YkS7Odra01z X-Received: by 2002:ad4:5d6e:0:b0:67a:3506:afdf with SMTP id fn14-20020ad45d6e000000b0067a3506afdfmr221212qvb.61.1704926885227; Wed, 10 Jan 2024 14:48:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926885; cv=none; d=google.com; s=arc-20160816; b=rF+kqKwFUvUKcsjtX5BJ8HCucfgcLFTt7JSWGUS1UjBAveeRYCZYWuNz4Ioj/skNH1 G0Tpl63heg6Kc6HSb5JyG7rwthHT0B0VVcnYy7lUj4a6gq0s0gBsmV1d08j3Uvp8ou9n RUSAFzfc7rZxbpNpKve9aXw7wIyxDaELUhJcxaw0fv2Bi3suO5MGZ4N0iB+A1X3NLppS COerctfzUXxWfOZ4y/i3JBMLIDQsKs6Fx6dQVbub6dZZ9RnL3wu39e4LKcG3uUrimEh4 wpRsprr9HJWjXl18Y9UrjtErXqkzSYt35HAHB9wTelsnaRxG+3tj7OtZztbZ9aSV6xPx Oy0w== 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=l6wrsnSxRLOGGrrUU+5wUcOLIX0LsFSMqYGfjSPgVvg=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=BmjnJ1P3WdSwL375VNcOXhrvYPY1xIM8HFsIdhmNXj5lXlUWsqU1Pifux+Am9FJdl2 cD6eocl9hKytwNNJK6lW6zVxVEhjZDmPJpgVakbxelP1m9emyrsp6i1rhqZ1rGGHJIIF IR4Yf6XApDanngXkQKkcWjatJTlIWVEkgdcT4s+DtMJY8m4Mp4SXsn6yMuMPdClIavcH zwK5V4XVDZxlPT/IZzORco/TXqupVh8tXFENtfaTEj3WeugTxpQRKbr2NFX8+0KfrgbE +uPFekwpnxvRSl1VvB5GrFbN25zt0EKASE69DUKzZjUE6vMJuDgKGKCWFvI0s1BDox1i GBWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ggFbARp8; 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 x12-20020a0c8e8c000000b00680640b9976si5177881qvb.549.2024.01.10.14.48.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:48:05 -0800 (PST) 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=ggFbARp8; 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 1rNhLa-0000iK-04; Wed, 10 Jan 2024 17:46:54 -0500 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 1rNhLT-0008O7-3N for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:47 -0500 Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhLR-0003eh-0e for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:46 -0500 Received: by mail-qt1-x835.google.com with SMTP id d75a77b69052e-4299f424e55so13856471cf.1 for ; Wed, 10 Jan 2024 14:46:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926804; x=1705531604; 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=l6wrsnSxRLOGGrrUU+5wUcOLIX0LsFSMqYGfjSPgVvg=; b=ggFbARp8NPvInqFOwGI5nHC0vFTLa36s3vWpz6isQtkVfzjzJCV4zro3TJ70xUMHna qjqwkOwCliguvY3EWxnj8n5FNQccG3coDrIcfMLKEMfPqzq7dGTyvNSglxn48b2crU0v G2nBiHtmif05hWZIGz3VKfo2GKcfIyztk0L3lR1QhCuT59warXhNxdjP1igDkQQtaK+s Rc777fIk1f1zAGRjZ5tGTLS5drWE7JQKXAPc29Vnipvym2l0dFkJJkviO9B7JpmVAUWV B5uiDZ2aBhMPMNGzAQNk+qkzeKxqCqUSBkpjh8v2q2OcSv9vDK9RRTCu1fBwNZvnQydf axSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926804; x=1705531604; 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=l6wrsnSxRLOGGrrUU+5wUcOLIX0LsFSMqYGfjSPgVvg=; b=N3CPFD72RBgigbGn5Zx0gIjbRziPiBj8Yzaq4AejIp7RjNmpRoQsoQUybPl05++9Uu 5QossCJcXNAtUSPfjRINTZeMyLx3Ej3yjGyVPHBK7wFsjYHv1jokenVP/GjndGb+OTO4 +987LowWaFKHTcSFooa/AfqPDouJrn9r7/LmNlr2QnLf3a0mcA2ImkKy6LiDPDEGjURz uMvqQYBvibA/zUARJ6/4VAyizSoL8l82Oat5FgqjGMwMyRjLe0vWTlhty3C79EXo+RDA YACOlXhBbcCf2TLQIh5kKVFpxryncQ7OcBwMas32ORB2LMuJBm6j+reOpB1IsLc1IiMU kEVQ== X-Gm-Message-State: AOJu0Yy9sJj08flJE7RPyTWJNnMNA41fzlN5hEiJUuvr76YiJxPELsyg kmgC9bP6X21+dA3j9OjTvd2+AFaXODWYTjX/seMeahSfU4+x5iF5 X-Received: by 2002:ac8:7f10:0:b0:429:9b17:5910 with SMTP id f16-20020ac87f10000000b004299b175910mr296003qtk.136.1704926804016; Wed, 10 Jan 2024 14:46:44 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.46.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:46:43 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 32/38] tcg/ppc: Tidy up tcg_target_const_match Date: Thu, 11 Jan 2024 09:44:02 +1100 Message-Id: <20240110224408.10444-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::835; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x835.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index b9323baa86..26e0bc31d7 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -282,31 +282,36 @@ static bool reloc_pc34(tcg_insn_unit *src_rw, const tcg_insn_unit *target) } /* test if a constant matches the constraint */ -static bool tcg_target_const_match(int64_t val, int ct, +static bool tcg_target_const_match(int64_t sval, int ct, TCGType type, TCGCond cond, int vece) { + uint64_t uval = sval; + if (ct & TCG_CT_CONST) { return 1; } - /* The only 32-bit constraint we use aside from - TCG_CT_CONST is TCG_CT_CONST_S16. */ if (type == TCG_TYPE_I32) { - val = (int32_t)val; + uval = (uint32_t)sval; + sval = (int32_t)sval; } - if ((ct & TCG_CT_CONST_S16) && val == (int16_t)val) { + if ((ct & TCG_CT_CONST_S16) && sval == (int16_t)sval) { return 1; - } else if ((ct & TCG_CT_CONST_S32) && val == (int32_t)val) { + } + if ((ct & TCG_CT_CONST_S32) && sval == (int32_t)sval) { return 1; - } else if ((ct & TCG_CT_CONST_U32) && val == (uint32_t)val) { + } + if ((ct & TCG_CT_CONST_U32) && uval == (uint32_t)uval) { return 1; - } else if ((ct & TCG_CT_CONST_ZERO) && val == 0) { + } + if ((ct & TCG_CT_CONST_ZERO) && sval == 0) { return 1; - } else if ((ct & TCG_CT_CONST_MONE) && val == -1) { + } + if ((ct & TCG_CT_CONST_MONE) && sval == -1) { return 1; - } else if ((ct & TCG_CT_CONST_WSZ) - && val == (type == TCG_TYPE_I32 ? 32 : 64)) { + } + if ((ct & TCG_CT_CONST_WSZ) && sval == (type == TCG_TYPE_I32 ? 32 : 64)) { return 1; } return 0; From patchwork Wed Jan 10 22:44:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761482 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2112746wrz; Wed, 10 Jan 2024 14:47:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IH35WgXPVH5v0bvFzxks8Ao2sBl4hvE5UIevhDhILBRU1AcQa92NMBnID+f1SgF+CS6vdHZ X-Received: by 2002:a05:620a:21c5:b0:77f:2ba4:9720 with SMTP id h5-20020a05620a21c500b0077f2ba49720mr378073qka.50.1704926862170; Wed, 10 Jan 2024 14:47:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926862; cv=none; d=google.com; s=arc-20160816; b=y07/32YhYNQ/fs9Li3S6P+RZhntppUUdiS7VXdVaL+TNxBtY/gVyLK3Km0g1fzzveF 9BKIZQQxpEYvnHy9m9I6a6bpJDCacTHlL/kiuO4ttdZiDhPtws4CZLOFg1l2p/0to/Bp X0F9TjQEXoGoxKXuO1JQ9NiWM05MGh4tKsG9kQxCXBfB+jWg0pJYNko4MFjH3b9nCzFQ pyWqZEkpcXTq9mpJ6VT2em69k9h743/5pJLSdp3IuTg6/ygnvgz3K7SR9F8aw1wRy/dL mkk7hH2CSiOR4f0XGH9iwm6Zwu3rGPWviAsUcVHEt9QOBiq2kgtC4nFKZnF2WGL7/QNn ygLw== 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=zjHxyGR5DOw/0X5t4FNhTcg/ySO1/KXOrl0SiEd+H80=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=0ahhX0kRe5xmyTn4QofdK2mLPMLu6umXnZAEQUq220e2ssJ1eX1MLr+ZSIocA3iwaK TxKQ+x2G42icDwOjBf643VGXOsob4fV65DqjIgmpE+yT3Deyn62+YS3R4j1qXUSNIDkn KRU9Fei6l9C9TtRHyUfyCf/BlGJ+1iF+sHUMh0BIrlX2/L2PF2rzy5o6tKpC9NptMh4T UfJwfrlxIdnYQ2JkfBovDYg/r1dQ6hsn8NFGcVynBpk2SmxhVFKZJTTPWbtCTEU+MAtc QjGDjKxtvzpFxHELnfhaKEU2NRoW/F4wIjeaBBSltUMnAj8qHyzZ90h7SDISzrpD6JUe uMbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uN2yJ0HU; 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 m14-20020a05620a214e00b0078326e6f1casi4730182qkm.202.2024.01.10.14.47.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:47:42 -0800 (PST) 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=uN2yJ0HU; 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 1rNhLb-0000vW-LG; Wed, 10 Jan 2024 17:46:55 -0500 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 1rNhLW-0000AV-KC for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:50 -0500 Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhLU-0003hh-EI for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:50 -0500 Received: by mail-qt1-x833.google.com with SMTP id d75a77b69052e-429b459aa98so6554541cf.0 for ; Wed, 10 Jan 2024 14:46:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926807; x=1705531607; 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=zjHxyGR5DOw/0X5t4FNhTcg/ySO1/KXOrl0SiEd+H80=; b=uN2yJ0HUHf20YQWuDeorXQ3cLD+QoXJIutHjV4OC73piITEyhGUdfmzmLi7daRh7em ypjyHfYJMsgU1n159WrprxU/pCDlxpAZ3GCRt/EV/LJYKxoebmQDJWRaWe8hQp3Co+mO pTVqGqBRaqa6aEzQyTVbx+oZQenw697Z3D0sgEDsNOOHLZS6fVya/055rlV8eslVA6RV 1MD9WfUYdUGayc/N6aKuduoBKbxaaMqlg/R5Dz2C38wS0cBRllzB96M+8iqwvNDa1IJk 9UOspOF+yoNwsMfdXHJd+jLtud+AFjvIL5jTxYGP2+klW5Lhe2UYZBlDUiPFaq0IKWkX /ADA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926807; x=1705531607; 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=zjHxyGR5DOw/0X5t4FNhTcg/ySO1/KXOrl0SiEd+H80=; b=MnGANKZidv2hZ1MO3H1qskD65dHENIGQWwIPFjfmgIDx0JMSv2+WG+bsXV/2xtFkdC 5S6v0r8XqN4zwplGN16kwD9a931T33GECAszDtIsN5fmHqDmH1mQfltF5Ly/yI83uZEP crzGVqONAUORr9ps6tCP9+xJJ+Ocf/Exsq/e0+Zj8fdBZoDwYyHNWVCjau5hfQAq6lg2 yR9b8gi9l8TFrdxicMAH3RYwWOQ8chXeFEkZIqruFK1Egri0cc4Q7jnzEBhSvjOhOXO7 E5oHOy5mrbyaO7AV1McULnY4lpjSgLFF5msKLzJR2gju9JvADtAmbP3g/qvxRnzzft6c o6dw== X-Gm-Message-State: AOJu0Yz1HWSPoVsGYarThzUWgGkDNOFLAM6xdqrMGQ4lnC5SBcAaeJXB 2aHI/lrvKF2gBfBzDdBrKJePm72xOq9Z2N7CcjD3nyF5xiLSwT4A X-Received: by 2002:a05:622a:294:b0:429:99d9:213a with SMTP id z20-20020a05622a029400b0042999d9213amr324133qtw.17.1704926807465; Wed, 10 Jan 2024 14:46:47 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.46.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:46:47 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 33/38] tcg/ppc: Add TCG_CT_CONST_CMP Date: Thu, 11 Jan 2024 09:44:03 +1100 Message-Id: <20240110224408.10444-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::833; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x833.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Better constraint for tcg_out_cmp, based on the comparison. We can't yet remove the fallback to load constants into a scratch because of tcg_out_cmp2, but that path should not be as frequent. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tcg/ppc/tcg-target-con-set.h | 5 ++-- tcg/ppc/tcg-target-con-str.h | 1 + tcg/ppc/tcg-target.c.inc | 48 ++++++++++++++++++++++++++++++------ 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/tcg/ppc/tcg-target-con-set.h b/tcg/ppc/tcg-target-con-set.h index cb47b29452..9f99bde505 100644 --- a/tcg/ppc/tcg-target-con-set.h +++ b/tcg/ppc/tcg-target-con-set.h @@ -11,7 +11,7 @@ */ C_O0_I1(r) C_O0_I2(r, r) -C_O0_I2(r, ri) +C_O0_I2(r, rC) C_O0_I2(v, r) C_O0_I3(r, r, r) C_O0_I3(o, m, r) @@ -26,13 +26,14 @@ C_O1_I2(r, rI, ri) C_O1_I2(r, rI, rT) C_O1_I2(r, r, r) C_O1_I2(r, r, ri) +C_O1_I2(r, r, rC) C_O1_I2(r, r, rI) C_O1_I2(r, r, rT) C_O1_I2(r, r, rU) C_O1_I2(r, r, rZW) C_O1_I2(v, v, v) C_O1_I3(v, v, v, v) -C_O1_I4(r, r, ri, rZ, rZ) +C_O1_I4(r, r, rC, rZ, rZ) C_O1_I4(r, r, r, ri, ri) C_O2_I1(r, r, r) C_N1O1_I1(o, m, r) diff --git a/tcg/ppc/tcg-target-con-str.h b/tcg/ppc/tcg-target-con-str.h index 20846901de..16b687216e 100644 --- a/tcg/ppc/tcg-target-con-str.h +++ b/tcg/ppc/tcg-target-con-str.h @@ -16,6 +16,7 @@ REGS('v', ALL_VECTOR_REGS) * Define constraint letters for constants: * CONST(letter, TCG_CT_CONST_* bit set) */ +CONST('C', TCG_CT_CONST_CMP) CONST('I', TCG_CT_CONST_S16) CONST('M', TCG_CT_CONST_MONE) CONST('T', TCG_CT_CONST_S32) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 26e0bc31d7..535ef2cbe7 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -92,11 +92,13 @@ #define SZR (TCG_TARGET_REG_BITS / 8) #define TCG_CT_CONST_S16 0x100 +#define TCG_CT_CONST_U16 0x200 #define TCG_CT_CONST_S32 0x400 #define TCG_CT_CONST_U32 0x800 #define TCG_CT_CONST_ZERO 0x1000 #define TCG_CT_CONST_MONE 0x2000 #define TCG_CT_CONST_WSZ 0x4000 +#define TCG_CT_CONST_CMP 0x8000 #define ALL_GENERAL_REGS 0xffffffffu #define ALL_VECTOR_REGS 0xffffffff00000000ull @@ -296,9 +298,35 @@ static bool tcg_target_const_match(int64_t sval, int ct, sval = (int32_t)sval; } + if (ct & TCG_CT_CONST_CMP) { + switch (cond) { + case TCG_COND_EQ: + case TCG_COND_NE: + ct |= TCG_CT_CONST_S16 | TCG_CT_CONST_U16; + break; + case TCG_COND_LT: + case TCG_COND_GE: + case TCG_COND_LE: + case TCG_COND_GT: + ct |= TCG_CT_CONST_S16; + break; + case TCG_COND_LTU: + case TCG_COND_GEU: + case TCG_COND_LEU: + case TCG_COND_GTU: + ct |= TCG_CT_CONST_U16; + break; + default: + g_assert_not_reached(); + } + } + if ((ct & TCG_CT_CONST_S16) && sval == (int16_t)sval) { return 1; } + if ((ct & TCG_CT_CONST_U16) && uval == (uint16_t)uval) { + return 1; + } if ((ct & TCG_CT_CONST_S32) && sval == (int32_t)sval) { return 1; } @@ -1682,7 +1710,10 @@ static void tcg_out_cmp(TCGContext *s, int cond, TCGArg arg1, TCGArg arg2, tcg_debug_assert(TCG_TARGET_REG_BITS == 64 || type == TCG_TYPE_I32); - /* Simplify the comparisons below wrt CMPI. */ + /* + * Simplify the comparisons below wrt CMPI. + * All of the tests are 16-bit, so a 32-bit sign extend always works. + */ if (type == TCG_TYPE_I32) { arg2 = (int32_t)arg2; } @@ -3991,8 +4022,6 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_sar_i32: case INDEX_op_rotl_i32: case INDEX_op_rotr_i32: - case INDEX_op_setcond_i32: - case INDEX_op_negsetcond_i32: case INDEX_op_and_i64: case INDEX_op_andc_i64: case INDEX_op_shl_i64: @@ -4000,8 +4029,6 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_sar_i64: case INDEX_op_rotl_i64: case INDEX_op_rotr_i64: - case INDEX_op_setcond_i64: - case INDEX_op_negsetcond_i64: return C_O1_I2(r, r, ri); case INDEX_op_mul_i32: @@ -4045,11 +4072,16 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_brcond_i32: case INDEX_op_brcond_i64: - return C_O0_I2(r, ri); - + return C_O0_I2(r, rC); + case INDEX_op_setcond_i32: + case INDEX_op_setcond_i64: + case INDEX_op_negsetcond_i32: + case INDEX_op_negsetcond_i64: + return C_O1_I2(r, r, rC); case INDEX_op_movcond_i32: case INDEX_op_movcond_i64: - return C_O1_I4(r, r, ri, rZ, rZ); + return C_O1_I4(r, r, rC, rZ, rZ); + case INDEX_op_deposit_i32: case INDEX_op_deposit_i64: return C_O1_I2(r, 0, rZ); From patchwork Wed Jan 10 22:44:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761488 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2112996wrz; Wed, 10 Jan 2024 14:48:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFPnvOO28Hw3I8+jPVK4aI5W6gbMG7GMCgAWEbP9EvUeZ1cMpNVCr36+sbWtnb+c5QQH7/v X-Received: by 2002:a25:ab0c:0:b0:dbe:346b:b9e with SMTP id u12-20020a25ab0c000000b00dbe346b0b9emr322631ybi.19.1704926908227; Wed, 10 Jan 2024 14:48:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926908; cv=none; d=google.com; s=arc-20160816; b=YHXwGbW3m8EM0n/sRR1ehguoulHwmMPA5sFqOlZmxJ2DYnVMOd7/011cdDQwqbsvPi UlwRTfC+rLXCeyjZ5fcG86Wovl1j+SDLPNCnsQkEFz676fwDcJUkvEjS1X+r5/+MVped 4LgOFNbx5QsSWm9Oy889umCh41hfpy21ua+eGGEuuHtZiIo38zlgSfleflFzaHXZ6j3P MBc0jXIXHNgzkBDXwPLR/1/NxbEpE8loPin1q4FmdSL3W/Qj5h3dH6Er4tEj7k7ZcYBm ONz2CSxc1TgnsaMqGFpjoW5ZFGaK75aFfi0JP+SVVS7gLKLaBMFsRQCFyhjjgX9acSHh xwSg== 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=+m2bQ+EJZL+KCOl+ulw6p2ASMsIl7BSAfdsffaeaSYk=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=Z/vHdUYkXj48EXeiJ7yknyXGxeY+VGk0tSuyW5HeyL+v2247mQQ0xfP2+1WXwWj5Mk jZQ4iSdAp/XQWC16tcOwwzLEA9p2mOwOye2lROtqZmStx88ESpwgaHrQoE6dF5lU3CUt x8n3OfMcgqpFWI/VS0ZMR3DOod/o9VGYZmMDrDhZUT5P5bvIDR/PhlFbCwN6E8RRQv3X 64z5sPXEqoav7E8ze246t7CXpU1oWLhm/5ACzuHJsfLWys1iTx4lKxNOh76D5v0M1g4U 6iCXnf1uucZBTJKnf+D/QSh666koiY2UfXvNqB/8zFsSv6QI+3iiICXmPOTFuTzCn/Kk 3Jbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=l5Sk8J1Z; 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 c8-20020ac85a88000000b004298ca778e9si5211178qtc.356.2024.01.10.14.48.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:48:28 -0800 (PST) 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=l5Sk8J1Z; 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 1rNhLg-0001TP-2N; Wed, 10 Jan 2024 17:47:00 -0500 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 1rNhLc-00010n-L9 for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:56 -0500 Received: from mail-qk1-x72b.google.com ([2607:f8b0:4864:20::72b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhLY-0003jw-95 for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:55 -0500 Received: by mail-qk1-x72b.google.com with SMTP id af79cd13be357-7831389c7daso381109385a.2 for ; Wed, 10 Jan 2024 14:46:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926811; x=1705531611; 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=+m2bQ+EJZL+KCOl+ulw6p2ASMsIl7BSAfdsffaeaSYk=; b=l5Sk8J1Zv1/2Q89KLy9fdpBnOjnBxIJfF0sE5E7XGzNBl309MGn6ZwgrNiE01eNGqW A7czBwprAJ22NTXyJNj+EsJSafoe6+9iKNPQ1DP1Z+zyA7a4dii0U6uQWmbwTTqmAKhW RbUWiMJm7rmoyJykZbxvbQtlds2gGRqvCqy/jPj3KdN9SplND7uNPrIXYRS9Nz4d+DkO mkrfu+QKO0rP3StToZQzhb9yCr76yHBHfH1psfChWfcPwNXIFGZr4nvLFivXXUZ6Zho3 MwNqsDx7nDSAks0w5wganNjn9/HbDb91ocik5jOBFzmLUAdU0f0d85CeSj6dmmRiwG4W sxLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926811; x=1705531611; 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=+m2bQ+EJZL+KCOl+ulw6p2ASMsIl7BSAfdsffaeaSYk=; b=jrCbpdaUH/HYDu+K17uVJj9duU2cn1iMjGzmxlwO7jBdEVdR4alEO872TWlWnkqBHx QTqhUDKofv8uZC0PWuzxXYM/WJipRtsHWq7GTq0V+/U5yY+l6C7AxQ51n8ePCeF6GOyB kXHF3biyayWll9GmVX2zIIm7R7w2mThrLrcXM7zjIxzicL8dmAMmlH/1NAozGTchYF27 VVnpn3glGcC5Dv2oL7F6zJm3KVxivND9dfecrcd2D72RwEl3TTW0TV3ZBLVGi3SwtLO0 NGoXzCb59c5KEymeMARCx008Q8hiqgg0mqXF0gOpvmJtCVMVsuL/XxS2HJGRbOSIqdwG doIg== X-Gm-Message-State: AOJu0YwfTHWnlc+uy0Q44VBLNIMPpW2pMjVX3F09reJjtnBMu3AHxh/T 2jFxttcndMQlzgYuGi0pnneMITsuW0vUYyOGDExugyJxETaddFeb X-Received: by 2002:a05:622a:1049:b0:429:b6c8:5e37 with SMTP id f9-20020a05622a104900b00429b6c85e37mr253399qte.86.1704926810845; Wed, 10 Jan 2024 14:46:50 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.46.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:46:50 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 34/38] tcg/ppc: Support TCG_COND_TST{EQ,NE} Date: Thu, 11 Jan 2024 09:44:04 +1100 Message-Id: <20240110224408.10444-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::72b; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72b.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tcg/ppc/tcg-target.h | 2 +- tcg/ppc/tcg-target.c.inc | 122 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 115 insertions(+), 9 deletions(-) diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index 60ce49e672..04a7aba4d3 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -143,7 +143,7 @@ typedef enum { #define TCG_TARGET_HAS_qemu_ldst_i128 \ (TCG_TARGET_REG_BITS == 64 && have_isa_2_07) -#define TCG_TARGET_HAS_tst 0 +#define TCG_TARGET_HAS_tst 1 /* * While technically Altivec could support V64, it has no 64-bit store diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 535ef2cbe7..7f3829beeb 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -283,11 +283,15 @@ static bool reloc_pc34(tcg_insn_unit *src_rw, const tcg_insn_unit *target) return false; } +static bool mask_operand(uint32_t c, int *mb, int *me); +static bool mask64_operand(uint64_t c, int *mb, int *me); + /* test if a constant matches the constraint */ static bool tcg_target_const_match(int64_t sval, int ct, TCGType type, TCGCond cond, int vece) { uint64_t uval = sval; + int mb, me; if (ct & TCG_CT_CONST) { return 1; @@ -316,6 +320,17 @@ static bool tcg_target_const_match(int64_t sval, int ct, case TCG_COND_GTU: ct |= TCG_CT_CONST_U16; break; + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + if ((uval & ~0xffff) == 0 || (uval & ~0xffff0000ull) == 0) { + return 1; + } + if (TCG_TARGET_REG_BITS == 32 || type == TCG_TYPE_I32 + ? mask_operand(uval, &mb, &me) + : mask64_operand(uval << clz64(uval), &mb, &me)) { + return 1; + } + return 0; default: g_assert_not_reached(); } @@ -703,9 +718,11 @@ enum { CR_SO }; -static const uint32_t tcg_to_bc[] = { +static const uint32_t tcg_to_bc[16] = { [TCG_COND_EQ] = BC | BI(0, CR_EQ) | BO_COND_TRUE, [TCG_COND_NE] = BC | BI(0, CR_EQ) | BO_COND_FALSE, + [TCG_COND_TSTEQ] = BC | BI(0, CR_EQ) | BO_COND_TRUE, + [TCG_COND_TSTNE] = BC | BI(0, CR_EQ) | BO_COND_FALSE, [TCG_COND_LT] = BC | BI(0, CR_LT) | BO_COND_TRUE, [TCG_COND_GE] = BC | BI(0, CR_LT) | BO_COND_FALSE, [TCG_COND_LE] = BC | BI(0, CR_GT) | BO_COND_FALSE, @@ -717,9 +734,11 @@ static const uint32_t tcg_to_bc[] = { }; /* The low bit here is set if the RA and RB fields must be inverted. */ -static const uint32_t tcg_to_isel[] = { +static const uint32_t tcg_to_isel[16] = { [TCG_COND_EQ] = ISEL | BC_(0, CR_EQ), [TCG_COND_NE] = ISEL | BC_(0, CR_EQ) | 1, + [TCG_COND_TSTEQ] = ISEL | BC_(0, CR_EQ), + [TCG_COND_TSTNE] = ISEL | BC_(0, CR_EQ) | 1, [TCG_COND_LT] = ISEL | BC_(0, CR_LT), [TCG_COND_GE] = ISEL | BC_(0, CR_LT) | 1, [TCG_COND_LE] = ISEL | BC_(0, CR_GT) | 1, @@ -872,19 +891,31 @@ static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) return true; } -static inline void tcg_out_rld(TCGContext *s, int op, TCGReg ra, TCGReg rs, - int sh, int mb) +static void tcg_out_rld_rc(TCGContext *s, int op, TCGReg ra, TCGReg rs, + int sh, int mb, bool rc) { tcg_debug_assert(TCG_TARGET_REG_BITS == 64); sh = SH(sh & 0x1f) | (((sh >> 5) & 1) << 1); mb = MB64((mb >> 5) | ((mb << 1) & 0x3f)); - tcg_out32(s, op | RA(ra) | RS(rs) | sh | mb); + tcg_out32(s, op | RA(ra) | RS(rs) | sh | mb | rc); } -static inline void tcg_out_rlw(TCGContext *s, int op, TCGReg ra, TCGReg rs, - int sh, int mb, int me) +static void tcg_out_rld(TCGContext *s, int op, TCGReg ra, TCGReg rs, + int sh, int mb) { - tcg_out32(s, op | RA(ra) | RS(rs) | SH(sh) | MB(mb) | ME(me)); + tcg_out_rld_rc(s, op, ra, rs, sh, mb, false); +} + +static void tcg_out_rlw_rc(TCGContext *s, int op, TCGReg ra, TCGReg rs, + int sh, int mb, int me, bool rc) +{ + tcg_out32(s, op | RA(ra) | RS(rs) | SH(sh) | MB(mb) | ME(me) | rc); +} + +static void tcg_out_rlw(TCGContext *s, int op, TCGReg ra, TCGReg rs, + int sh, int mb, int me) +{ + tcg_out_rlw_rc(s, op, ra, rs, sh, mb, me, false); } static void tcg_out_ext8s(TCGContext *s, TCGType type, TCGReg dst, TCGReg src) @@ -1702,6 +1733,50 @@ static inline bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, return false; } +/* + * Set dest non-zero if and only if (arg1 & arg2) is non-zero. + * If RC, then also set RC0. + */ +static void tcg_out_test(TCGContext *s, TCGReg dest, TCGReg arg1, TCGArg arg2, + bool const_arg2, TCGType type, bool rc) +{ + int mb, me; + + if (!const_arg2) { + tcg_out32(s, AND | SAB(arg1, dest, arg2) | rc); + return; + } + + if (type == TCG_TYPE_I32) { + arg2 = (uint32_t)arg2; + } else if (arg2 == (uint32_t)arg2) { + type = TCG_TYPE_I32; + } + + if ((arg2 & ~0xffff) == 0) { + tcg_out32(s, ANDI | SAI(arg1, dest, arg2)); + return; + } + if ((arg2 & ~0xffff0000ull) == 0) { + tcg_out32(s, ANDIS | SAI(arg1, dest, arg2 >> 16)); + return; + } + if (TCG_TARGET_REG_BITS == 32 || type == TCG_TYPE_I32) { + if (mask_operand(arg2, &mb, &me)) { + tcg_out_rlw_rc(s, RLWINM, dest, arg1, 0, mb, me, rc); + return; + } + } else { + int sh = clz64(arg2); + if (mask64_operand(arg2 << sh, &mb, &me)) { + tcg_out_rld_rc(s, RLDICR, dest, arg1, sh, me, rc); + return; + } + } + /* Constraints should satisfy this. */ + g_assert_not_reached(); +} + static void tcg_out_cmp(TCGContext *s, int cond, TCGArg arg1, TCGArg arg2, int const_arg2, int cr, TCGType type) { @@ -1736,6 +1811,12 @@ static void tcg_out_cmp(TCGContext *s, int cond, TCGArg arg1, TCGArg arg2, imm = 0; break; + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + tcg_debug_assert(cr == 0); + tcg_out_test(s, TCG_REG_R0, arg1, arg2, const_arg2, type, true); + return; + case TCG_COND_LT: case TCG_COND_GE: case TCG_COND_LE: @@ -1946,6 +2027,16 @@ static void tcg_out_setcond(TCGContext *s, TCGType type, TCGCond cond, tcg_out_setcond_ne0(s, type, arg0, arg1, neg); break; + case TCG_COND_TSTEQ: + tcg_out_test(s, TCG_REG_R0, arg1, arg2, const_arg2, type, false); + tcg_out_setcond_eq0(s, type, arg0, TCG_REG_R0, neg); + break; + + case TCG_COND_TSTNE: + tcg_out_test(s, TCG_REG_R0, arg1, arg2, const_arg2, type, false); + tcg_out_setcond_ne0(s, type, arg0, TCG_REG_R0, neg); + break; + case TCG_COND_LE: case TCG_COND_LEU: inv = true; @@ -2118,6 +2209,21 @@ static void tcg_out_cmp2(TCGContext *s, const TCGArg *args, tcg_out32(s, op | BT(0, CR_EQ) | BA(6, CR_EQ) | BB(7, CR_EQ)); break; + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + if (blconst) { + tcg_out_andi32(s, TCG_REG_R0, al, bl); + } else { + tcg_out32(s, AND | SAB(al, TCG_REG_R0, bl)); + } + if (bhconst) { + tcg_out_andi32(s, TCG_REG_TMP1, ah, bh); + } else { + tcg_out32(s, AND | SAB(ah, TCG_REG_TMP1, bh)); + } + tcg_out32(s, OR | SAB(TCG_REG_R0, TCG_REG_R0, TCG_REG_TMP1) | 1); + break; + case TCG_COND_LT: case TCG_COND_LE: case TCG_COND_GT: From patchwork Wed Jan 10 22:44:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761477 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2112682wrz; Wed, 10 Jan 2024 14:47:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IH6sHMUC8bYUpLyl4b/c+HosWEY1YO5qFO6CmF/D58zFfTvo31Vm2mzmHpz9bhFT6yuo5d8 X-Received: by 2002:a05:6214:2a4c:b0:681:16ee:2cf6 with SMTP id jf12-20020a0562142a4c00b0068116ee2cf6mr236059qvb.12.1704926848715; Wed, 10 Jan 2024 14:47:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926848; cv=none; d=google.com; s=arc-20160816; b=RKiAPo+VfiBbqNFrEwHxjWKlMfBzH5RHaKxvcTRgHdJIpQhHF99NfjwtI1KL7oVEdJ zBfvT3c4xgVV6mrA8kujueAiE5WyH4zUzExdj5VW5pags6br1rt6HnolfA2++3XF7B0L pwHAe/4XpPwweiZHbtvh6xkyw9ZGyfFCsJ1KLkmI3dCGyKQaXnA6+gWjrmDD4DC3vxRk yN9/4J7pOWDE0MmA2cUKyCMkm61T1+VX3NLbJ3FsGQlhgXPl8a+2bjupufWeX88ezrAR 7tpgnb990WCKz4pe9ttwlOdyNJbrSeC2yLqJVJ1rSicVmefODOKSCsAt0gpHt9sMjUd0 3ojg== 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=SG+rKuUVbaUxXp+EMRwo0KDiuCri6E6fV9fOpbonh9A=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=g50ZQWPXsQx/RAgNTb2CG3jzQCj7dQsFArHu9MFFsevlyy2KVdpS/1jJA5KleF4y6V 5b15vl7jkOvong9t3AWXJMePxI/Mofjv/kf+YYXeHI5bftFlpXzjOukkcFplYRpcvUfH Zv+vY+ASRzmG/XPNQunHKj9Fq/++18bzb6+XnLElPdH4JTNkJvlOx2Llyosglbk8lTGs 305l5lt8fODlozZUOtrhU1uWzg4X2WPA9rgygbFjJUFLNMf7oY7+a1vgSUF6iSjeGx2S 4kFX+B3o6H0WG+06Sdr6/RnM36g4qqOgPZ0zJZGSmXJY7xz32Ej2htHbnvsvu4dWmQk1 i2hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HGkrDq4E; 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 l4-20020ad44084000000b0067f41a37e60si5123572qvp.610.2024.01.10.14.47.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:47:28 -0800 (PST) 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=HGkrDq4E; 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 1rNhLv-0002VO-BY; Wed, 10 Jan 2024 17:47:15 -0500 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 1rNhLd-0001Cl-No for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:57 -0500 Received: from mail-yb1-xb33.google.com ([2607:f8b0:4864:20::b33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhLb-0003o9-Q0 for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:57 -0500 Received: by mail-yb1-xb33.google.com with SMTP id 3f1490d57ef6-dbe69afb431so3938482276.1 for ; Wed, 10 Jan 2024 14:46:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926814; x=1705531614; 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=SG+rKuUVbaUxXp+EMRwo0KDiuCri6E6fV9fOpbonh9A=; b=HGkrDq4EnloOo6sjKM2CNrWf9LOTbA3o2esx0G+rJZ8G1EEJZnaDtw0XWj19SPXPHA FyGzTBqRMYrInpqVIzzvXgGj4FinG58+tLQZTiATqOEkD4GM1Af/kz4X+NsQsw/NN53s JCfmOdiVrr14cQWGkKiG2TiyjSBMQoc0dOI57cyC3XCQ5Vxftt3oD19FWTGuDCli0mh9 KfxK5SHe1xhs2f8vQz3u7yb7FeKEXxOnZO2LutMNCGwVdcMWLpWnzW0UDmRgRq0xgW5+ MIX4KNy228nZQJhXbewcmWSuD4rPA2tY87TAwgS9bMggyJQI9HQZsMuPmZKDyumkDCAL iFgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926814; x=1705531614; 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=SG+rKuUVbaUxXp+EMRwo0KDiuCri6E6fV9fOpbonh9A=; b=CapMDIse9WzCtvT+R9q2xsd7CIWs8YVrHSsoNB2Li+hRB+9i0YLc1yXl2gtEwy0qNc qK2FeqmCRBI6cRwxkNK2mYkqwpvsOL3yc8J6tXcsMPW4ztrtkaXa7h/yDdvRM1fwhWgr 3LxYV3yRpG2whcsBGBIiArU00T4EmZTcxB9yvLSbe6d/fgi+ZrZg3lOuhj7934zcotp7 oGl2Fpn3WQ9ss7n737OCn1Lk8dqyI1Oayu02Em05MBmfII944dX7Z1mwyvFiU7ynvInv y/Rn1rkXvEeHgzan90s1hI8QjeI8dwt5E9CmDGk5r6FsQMCNgv3ciatiS3TVY5+6ehKb OxNQ== X-Gm-Message-State: AOJu0YxMNLDQ1FQ7SL8j1JDm9Ah2WiMu4fKLVs6nMc4T5/1FEt4b4MUP cFKT5jWXmpy3e3OfH4/f4DfUPZII/qPXMSdDy66aEReXXaDPRJ9F X-Received: by 2002:a25:ac15:0:b0:dbc:ecba:70fe with SMTP id w21-20020a25ac15000000b00dbcecba70femr374693ybi.65.1704926814636; Wed, 10 Jan 2024 14:46:54 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.46.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:46:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 35/38] tcg/s390x: Split constraint A into J+U Date: Thu, 11 Jan 2024 09:44:05 +1100 Message-Id: <20240110224408.10444-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::b33; envelope-from=richard.henderson@linaro.org; helo=mail-yb1-xb33.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Signed 33-bit == signed 32-bit + unsigned 32-bit. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tcg/s390x/tcg-target-con-set.h | 8 ++++---- tcg/s390x/tcg-target-con-str.h | 2 +- tcg/s390x/tcg-target.c.inc | 36 +++++++++++++++++----------------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/tcg/s390x/tcg-target-con-set.h b/tcg/s390x/tcg-target-con-set.h index 9a42037499..665851d84a 100644 --- a/tcg/s390x/tcg-target-con-set.h +++ b/tcg/s390x/tcg-target-con-set.h @@ -15,7 +15,7 @@ C_O0_I1(r) C_O0_I2(r, r) C_O0_I2(r, ri) -C_O0_I2(r, rA) +C_O0_I2(r, rJU) C_O0_I2(v, r) C_O0_I3(o, m, r) C_O1_I1(r, r) @@ -27,7 +27,7 @@ C_O1_I2(r, 0, rI) C_O1_I2(r, 0, rJ) C_O1_I2(r, r, r) C_O1_I2(r, r, ri) -C_O1_I2(r, r, rA) +C_O1_I2(r, r, rJU) C_O1_I2(r, r, rI) C_O1_I2(r, r, rJ) C_O1_I2(r, r, rK) @@ -39,10 +39,10 @@ C_O1_I2(v, v, r) C_O1_I2(v, v, v) C_O1_I3(v, v, v, v) C_O1_I4(r, r, ri, rI, r) -C_O1_I4(r, r, rA, rI, r) +C_O1_I4(r, r, rJU, rI, r) C_O2_I1(o, m, r) C_O2_I2(o, m, 0, r) C_O2_I2(o, m, r, r) C_O2_I3(o, m, 0, 1, r) C_N1_O1_I4(r, r, 0, 1, ri, r) -C_N1_O1_I4(r, r, 0, 1, rA, r) +C_N1_O1_I4(r, r, 0, 1, rJU, r) diff --git a/tcg/s390x/tcg-target-con-str.h b/tcg/s390x/tcg-target-con-str.h index 25675b449e..9d2cb775dc 100644 --- a/tcg/s390x/tcg-target-con-str.h +++ b/tcg/s390x/tcg-target-con-str.h @@ -16,10 +16,10 @@ REGS('o', 0xaaaa) /* odd numbered general regs */ * Define constraint letters for constants: * CONST(letter, TCG_CT_CONST_* bit set) */ -CONST('A', TCG_CT_CONST_S33) CONST('I', TCG_CT_CONST_S16) CONST('J', TCG_CT_CONST_S32) CONST('K', TCG_CT_CONST_P32) CONST('N', TCG_CT_CONST_INV) CONST('R', TCG_CT_CONST_INVRISBG) +CONST('U', TCG_CT_CONST_U32) CONST('Z', TCG_CT_CONST_ZERO) diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc index 08fe00a392..a317ccd3a5 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -30,7 +30,7 @@ #define TCG_CT_CONST_S16 (1 << 8) #define TCG_CT_CONST_S32 (1 << 9) -#define TCG_CT_CONST_S33 (1 << 10) +#define TCG_CT_CONST_U32 (1 << 10) #define TCG_CT_CONST_ZERO (1 << 11) #define TCG_CT_CONST_P32 (1 << 12) #define TCG_CT_CONST_INV (1 << 13) @@ -542,22 +542,23 @@ static bool tcg_target_const_match(int64_t val, int ct, TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { - return 1; + return true; } - if (type == TCG_TYPE_I32) { val = (int32_t)val; } - /* The following are mutually exclusive. */ - if (ct & TCG_CT_CONST_S16) { - return val == (int16_t)val; - } else if (ct & TCG_CT_CONST_S32) { - return val == (int32_t)val; - } else if (ct & TCG_CT_CONST_S33) { - return val >= -0xffffffffll && val <= 0xffffffffll; - } else if (ct & TCG_CT_CONST_ZERO) { - return val == 0; + if ((ct & TCG_CT_CONST_S32) && val == (int32_t)val) { + return true; + } + if ((ct & TCG_CT_CONST_U32) && val == (uint32_t)val) { + return true; + } + if ((ct & TCG_CT_CONST_S16) && val == (int16_t)val) { + return true; + } + if ((ct & TCG_CT_CONST_ZERO) && val == 0) { + return true; } if (ct & TCG_CT_CONST_INV) { @@ -573,8 +574,7 @@ static bool tcg_target_const_match(int64_t val, int ct, if ((ct & TCG_CT_CONST_INVRISBG) && risbg_mask(~val)) { return true; } - - return 0; + return false; } /* Emit instructions according to the given instruction format. */ @@ -3137,7 +3137,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) return C_O1_I2(r, r, ri); case INDEX_op_setcond_i64: case INDEX_op_negsetcond_i64: - return C_O1_I2(r, r, rA); + return C_O1_I2(r, r, rJU); case INDEX_op_clz_i64: return C_O1_I2(r, r, rI); @@ -3187,7 +3187,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_brcond_i32: return C_O0_I2(r, ri); case INDEX_op_brcond_i64: - return C_O0_I2(r, rA); + return C_O0_I2(r, rJU); case INDEX_op_bswap16_i32: case INDEX_op_bswap16_i64: @@ -3240,7 +3240,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_movcond_i32: return C_O1_I4(r, r, ri, rI, r); case INDEX_op_movcond_i64: - return C_O1_I4(r, r, rA, rI, r); + return C_O1_I4(r, r, rJU, rI, r); case INDEX_op_div2_i32: case INDEX_op_div2_i64: @@ -3259,7 +3259,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_add2_i64: case INDEX_op_sub2_i64: - return C_N1_O1_I4(r, r, 0, 1, rA, r); + return C_N1_O1_I4(r, r, 0, 1, rJU, r); case INDEX_op_st_vec: return C_O0_I2(v, r); From patchwork Wed Jan 10 22:44:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761497 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2113223wrz; Wed, 10 Jan 2024 14:49:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IFIZWvTwnkIf6umqBuATeGK4sRomGY8vdRFbiQn6dlHiqdFGbq/6idWoAu9zbAqIzUFBeoV X-Received: by 2002:ad4:5b8b:0:b0:681:9bb:e3db with SMTP id 11-20020ad45b8b000000b0068109bbe3dbmr240472qvp.98.1704926947996; Wed, 10 Jan 2024 14:49:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926947; cv=none; d=google.com; s=arc-20160816; b=ehNA9/2D9f1aFjaQtdGIkROGiqeY43ZrbiRFWbeDTrUEKQwF1hzJLXjH+ManQTg5oE u5n8i9l3zbyQbQ+ftEIM6SDnqcCa1LPkT5MPQUo66+kaV25I2rFokm96PjgqkJGeXthB FbxlV1MmLZcVZMXsLl4ueAq9peS+TdIx2qAG8LnIGv6TYFJDJWyL/LCwjuSZBwpU2/Rk Nhzuzxan9pCT1ZWJnIzxCJBYFjpPP0xqGQyoVjJOSaebzJxGGphiqM1tbfTjk4Go/N6f EbkrxMGLVDx0Z1oRL1kTQP77R4WlXZLmX0JLctBAUTKjci7LxQ9nbIv3v32L3ul4mb/E +VRA== 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=aJQydxS3NvJxT4eWGTovhRM0Zt2nynj/3g50i7a6gMo=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=K4f+MFq73/7AZ+EDzYW/gtQKhbQbTOjTb5M4bqlyCaQ4uq1GMGG+i8oAVQyDaskr1i bCO8AMuqjqAIatJydgULxafMsidcVFXBr9/IA+isxOF/TIAJo+SpqMT/Bw1ixso/ckO1 Bj21mfnIN/fJXC5mgy+/FLEkAMmd3qAoWppvm/+i/yQGLjgxPm8uZgQjgGLePRjiOygS Ph3c0dJ2iwtOK+Ck6ijBCGO3LcqIUmR0lTFdBvP48KjFgazmp0KQ8Wht0eQV3LQ3Nfiy 8dXNV1MsDNF3UEYy+kFIRzV3QBahncecPNKuZPjm1tGrNCdQFqH99OQ+oFIsyliNCO9W Cz1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RkmQEvFB; 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 q3-20020a0cf5c3000000b0067f8c1fcfb4si5465667qvm.166.2024.01.10.14.49.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:49:07 -0800 (PST) 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=RkmQEvFB; 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 1rNhLz-0002gR-NY; Wed, 10 Jan 2024 17:47:20 -0500 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 1rNhLi-0002Jh-FI for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:47:06 -0500 Received: from mail-yb1-xb35.google.com ([2607:f8b0:4864:20::b35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhLf-0003p1-KJ for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:47:01 -0500 Received: by mail-yb1-xb35.google.com with SMTP id 3f1490d57ef6-dbedb1ee3e4so3975360276.3 for ; Wed, 10 Jan 2024 14:46:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926818; x=1705531618; 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=aJQydxS3NvJxT4eWGTovhRM0Zt2nynj/3g50i7a6gMo=; b=RkmQEvFBZZeJ5bbJqsjpUKh3bM5QAoBd6LjFW2vcvEm0I7FIxBrkh919H/1wxwppEt OLHjo0YkEJRFESY8F4swDJu0JdMfHI7IJGgM37IsJvER8bdTgAXTWRZodI/trJY1UMju YzS6B12whqvPiiPE15I6eL/Tn59g9GZqKyseoAfwS/EWl+g25YYf1aDQ9Gl/E0MIA6h2 uUQYwiIW9qqGIDeo/tSkzasrCzrzxXZsKPbc4a64dVLQkazp/Llql6W5yWKRNLnkHXPN Hj+a4zwg/bfW3rSDph2ry0x3357KTd5eutmZkE6I1phpPT7nRz8w2+f9Uqm5rdCMlTmB Ci7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926818; x=1705531618; 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=aJQydxS3NvJxT4eWGTovhRM0Zt2nynj/3g50i7a6gMo=; b=GOgvAL8CL73Whv8y5uaQOAWE2eAqiEEufKIXGYYo1QD2aJBLHSBBQTl30S8fUEDUAK b/kH7Hvgb1csT3eopXWcb3RQbQi6E0XMpncjK1AL7il9lX3U0l1lL/7SB+LSuwLNkY1a 1IEaOqbSipEzjpfPQcXJbHBMqIkMrKUdfe1UL2ZceDq4jtPoWJweKjYnRmw3v+I0sVg8 6ULVRSP5OND4QjoLWwFAzc43cYEE3/xVYEzljRcEUJw5OfoJyNUkuKZl7ZxR4cMT5K39 4EU69vYWrxwp3IiT5LPFO0ji5xBHzReNMOdVeFGA5vN0ASg16a6tsaRH9A6kesN08cfm xdUw== X-Gm-Message-State: AOJu0Yyk5VYqZtOxKRfqXH/Aqh04E6czpewKqm/EjZvUBz8H2UE8JfSI xO8KSsPoAmKYemmDj33i6kinU4pVk/cq5xEJmWwkyZEDEoXEau1k X-Received: by 2002:a25:2613:0:b0:db0:2b47:aa1 with SMTP id m19-20020a252613000000b00db02b470aa1mr235685ybm.40.1704926818238; Wed, 10 Jan 2024 14:46:58 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.46.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:46:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 36/38] tcg/s390x: Add TCG_CT_CONST_CMP Date: Thu, 11 Jan 2024 09:44:06 +1100 Message-Id: <20240110224408.10444-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::b35; envelope-from=richard.henderson@linaro.org; helo=mail-yb1-xb35.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Better constraint for tcg_out_cmp, based on the comparison. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tcg/s390x/tcg-target-con-set.h | 6 +-- tcg/s390x/tcg-target-con-str.h | 1 + tcg/s390x/tcg-target.c.inc | 72 +++++++++++++++++++++++++--------- 3 files changed, 58 insertions(+), 21 deletions(-) diff --git a/tcg/s390x/tcg-target-con-set.h b/tcg/s390x/tcg-target-con-set.h index 665851d84a..f75955eaa8 100644 --- a/tcg/s390x/tcg-target-con-set.h +++ b/tcg/s390x/tcg-target-con-set.h @@ -15,7 +15,7 @@ C_O0_I1(r) C_O0_I2(r, r) C_O0_I2(r, ri) -C_O0_I2(r, rJU) +C_O0_I2(r, rC) C_O0_I2(v, r) C_O0_I3(o, m, r) C_O1_I1(r, r) @@ -27,7 +27,7 @@ C_O1_I2(r, 0, rI) C_O1_I2(r, 0, rJ) C_O1_I2(r, r, r) C_O1_I2(r, r, ri) -C_O1_I2(r, r, rJU) +C_O1_I2(r, r, rC) C_O1_I2(r, r, rI) C_O1_I2(r, r, rJ) C_O1_I2(r, r, rK) @@ -39,7 +39,7 @@ C_O1_I2(v, v, r) C_O1_I2(v, v, v) C_O1_I3(v, v, v, v) C_O1_I4(r, r, ri, rI, r) -C_O1_I4(r, r, rJU, rI, r) +C_O1_I4(r, r, rC, rI, r) C_O2_I1(o, m, r) C_O2_I2(o, m, 0, r) C_O2_I2(o, m, r, r) diff --git a/tcg/s390x/tcg-target-con-str.h b/tcg/s390x/tcg-target-con-str.h index 9d2cb775dc..745f6c0df5 100644 --- a/tcg/s390x/tcg-target-con-str.h +++ b/tcg/s390x/tcg-target-con-str.h @@ -16,6 +16,7 @@ REGS('o', 0xaaaa) /* odd numbered general regs */ * Define constraint letters for constants: * CONST(letter, TCG_CT_CONST_* bit set) */ +CONST('C', TCG_CT_CONST_CMP) CONST('I', TCG_CT_CONST_S16) CONST('J', TCG_CT_CONST_S32) CONST('K', TCG_CT_CONST_P32) diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc index a317ccd3a5..86ec737768 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -35,6 +35,7 @@ #define TCG_CT_CONST_P32 (1 << 12) #define TCG_CT_CONST_INV (1 << 13) #define TCG_CT_CONST_INVRISBG (1 << 14) +#define TCG_CT_CONST_CMP (1 << 15) #define ALL_GENERAL_REGS MAKE_64BIT_MASK(0, 16) #define ALL_VECTOR_REGS MAKE_64BIT_MASK(32, 32) @@ -548,6 +549,29 @@ static bool tcg_target_const_match(int64_t val, int ct, val = (int32_t)val; } + if (ct & TCG_CT_CONST_CMP) { + switch (cond) { + case TCG_COND_EQ: + case TCG_COND_NE: + ct |= TCG_CT_CONST_S32 | TCG_CT_CONST_U32; /* CGFI or CLGFI */ + break; + case TCG_COND_LT: + case TCG_COND_GE: + case TCG_COND_LE: + case TCG_COND_GT: + ct |= TCG_CT_CONST_S32; /* CGFI */ + break; + case TCG_COND_LTU: + case TCG_COND_GEU: + case TCG_COND_LEU: + case TCG_COND_GTU: + ct |= TCG_CT_CONST_U32; /* CLGFI */ + break; + default: + g_assert_not_reached(); + } + } + if ((ct & TCG_CT_CONST_S32) && val == (int32_t)val) { return true; } @@ -1229,22 +1253,34 @@ static int tgen_cmp2(TCGContext *s, TCGType type, TCGCond c, TCGReg r1, goto exit; } - /* - * Constraints are for a signed 33-bit operand, which is a - * convenient superset of this signed/unsigned test. - */ - if (c2 == (is_unsigned ? (TCGArg)(uint32_t)c2 : (TCGArg)(int32_t)c2)) { - op = (is_unsigned ? RIL_CLGFI : RIL_CGFI); - tcg_out_insn_RIL(s, op, r1, c2); - goto exit; + /* Should match TCG_CT_CONST_CMP. */ + switch (c) { + case TCG_COND_LT: + case TCG_COND_GE: + case TCG_COND_LE: + case TCG_COND_GT: + tcg_debug_assert(c2 == (int32_t)c2); + op = RIL_CGFI; + break; + case TCG_COND_EQ: + case TCG_COND_NE: + if (c2 == (int32_t)c2) { + op = RIL_CGFI; + break; + } + /* fall through */ + case TCG_COND_LTU: + case TCG_COND_GEU: + case TCG_COND_LEU: + case TCG_COND_GTU: + tcg_debug_assert(c2 == (uint32_t)c2); + op = RIL_CLGFI; + break; + default: + g_assert_not_reached(); } - - /* Load everything else into a register. */ - tcg_out_movi(s, TCG_TYPE_I64, TCG_TMP0, c2); - c2 = TCG_TMP0; - } - - if (type == TCG_TYPE_I32) { + tcg_out_insn_RIL(s, op, r1, c2); + } else if (type == TCG_TYPE_I32) { op = (is_unsigned ? RR_CLR : RR_CR); tcg_out_insn_RR(s, op, r1, c2); } else { @@ -3137,7 +3173,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) return C_O1_I2(r, r, ri); case INDEX_op_setcond_i64: case INDEX_op_negsetcond_i64: - return C_O1_I2(r, r, rJU); + return C_O1_I2(r, r, rC); case INDEX_op_clz_i64: return C_O1_I2(r, r, rI); @@ -3187,7 +3223,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_brcond_i32: return C_O0_I2(r, ri); case INDEX_op_brcond_i64: - return C_O0_I2(r, rJU); + return C_O0_I2(r, rC); case INDEX_op_bswap16_i32: case INDEX_op_bswap16_i64: @@ -3240,7 +3276,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_movcond_i32: return C_O1_I4(r, r, ri, rI, r); case INDEX_op_movcond_i64: - return C_O1_I4(r, r, rJU, rI, r); + return C_O1_I4(r, r, rC, rI, r); case INDEX_op_div2_i32: case INDEX_op_div2_i64: From patchwork Wed Jan 10 22:44:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761498 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2113258wrz; Wed, 10 Jan 2024 14:49:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IHSnT/zTMrPryeitcT+nszp3XDfMJ+xSmpHGjNjWU/pBKsmeQEt3MhwLuYn3dHv8qB//UUo X-Received: by 2002:a05:620a:3635:b0:77f:25ef:eb92 with SMTP id da53-20020a05620a363500b0077f25efeb92mr1078098qkb.27.1704926952287; Wed, 10 Jan 2024 14:49:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926952; cv=none; d=google.com; s=arc-20160816; b=FXhh9nQOrMhc78JYhdTryRDkG8HNKVizXIVXbHNvMDzZLjcC3mC3NT5VXlfr/euLwP E8D85V3HBGqeAVm5IKmTwgt0znAJEtgLlpQ2uM8Vi2rXir9urx8Tezgr8Nz2+qyz0Jlq 86hhUI0IZPJz+hHxYXM7HJ6u8Gg2wF269tgzEtcyAEPTsLYnVlGvvbJrabz/Q4Tg+H5K K00x9diwy1VY1yca5tOdImAN4/wXAc1fGIrLI8DpqYXJ7bOJ2cJL7D2rKsr7ePkrtPkD Qknjxerxi2UZyX4BzUsudpwKhadKrLbhVXjWE+MImK3BwiauE4DNfUC2LEgbJZyUnlpk f+3Q== 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=wZ0H1HwSFXvLC8Z3KY83cUGJjMMhIte+R5upodq3iGE=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=o7/mOK5YAccDDWbA/skxscH80/CM6LycEWRjHkzF/3luXld43Qy9AY5RCKTm+1RNf6 x4bY3t7lZXeP1RMlX4+pG/62d73p8KtOu+0DM4ghSLYCG6LJfWzj8I7jdkDuqkFBT+0A Qv74pUwKpRU6BloTpmozsDSE6/a7oosBgSFd7vAKIF5Ya1+fRZSxA9NZHHbw5m62Aq/r 69FeeZ3Ys8xlB8tWcuHgbgtsBwGAHv003/VfcBAd7NKvgZJjnAwwbqXuTOX7ZyYtJBr1 VylScXckvB7LeqhngkznUEcdfB8eiiH/EgMRIKVx/xIhRDBoVePNwBelv+C6vX97OdUX dTbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ceQQM6cJ; 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 d26-20020a0cb2da000000b00680b1a549a6si5279669qvf.380.2024.01.10.14.49.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:49:12 -0800 (PST) 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=ceQQM6cJ; 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 1rNhM1-0002x3-IZ; Wed, 10 Jan 2024 17:47:21 -0500 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 1rNhLt-0002d4-Hr for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:47:15 -0500 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhLj-0003pk-SM for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:47:07 -0500 Received: by mail-qt1-x829.google.com with SMTP id d75a77b69052e-429915eefa5so30460081cf.1 for ; Wed, 10 Jan 2024 14:47:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926822; x=1705531622; 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=wZ0H1HwSFXvLC8Z3KY83cUGJjMMhIte+R5upodq3iGE=; b=ceQQM6cJOeEm9f2DV9MAdPAbMKHNEb6sxd6kAxNaYR/xVRWwNdK/MOo3uhz06RtqG6 WFq38ww5FtjMQ/sFrkw5875SpX/l4Qo27j8u5bn+5hX0bjQXpxWG8IOowVz2cuY8RudS onR0TCoDwMOWuyBNvtOdhOEhQNgL9jwM5Jjd0SE/g6x3LeHFn7DsFt9bvhffHEfO/lJ/ bEnU1P9eV8O1XOOIhdoSQ+oIs7su5/cfaG0M9gd4H1bVNcqbuopZa0AMx+E7LlmUJX0o ZzxViYAdlI+uZ2Bz4+SEeYOu1tFIxqIxsH4zgqXlAWqspSPQhzgNerXh86T5Ox9LkkeM EUWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926822; x=1705531622; 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=wZ0H1HwSFXvLC8Z3KY83cUGJjMMhIte+R5upodq3iGE=; b=heVZeQNathsUOeKlw00OPsMYMpVxjJXsXkq5ZpE65K7cCEdhWT1eQQPZvRZ00i8klW RTOqyxYVchsShixN1klWDbBhA43LbKYCuNvZNtScoYjlOk0TGVEv8WcoAxvetHLTB8Z+ WhwzYpN5EODniTZiFtOkqZsHwGbzodMU06yMIZ2/TYZzO0Zeq56mlIeXo+g/ekxpQKbJ DVQa+lMc50qUK4OePcfge1hzypoUxaarxceVeUfgtRG+V3kAyPNpPfTKFdF7QDvY275k aKg1jHIcm4eLlwnBcvkS2arb7VhJb5FlLEI7BbHUXxVmEIQ4M0MzcIFFK1LzXYHpA93T uHWg== X-Gm-Message-State: AOJu0YyUSh6VwCFBVmQDwgaec5F18PUZU6FPQYwkyQqDcVGK5ad1XJ+W 9G0OfWgAqD5e4bs/KT42CZ4EBY5diZ3rDdr304HnKniiHMYt/VZh X-Received: by 2002:a05:622a:346:b0:429:a498:14a1 with SMTP id r6-20020a05622a034600b00429a49814a1mr1222900qtw.28.1704926822322; Wed, 10 Jan 2024 14:47:02 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.46.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:47:01 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 37/38] tcg/s390x: Support TCG_COND_TST{EQ,NE} Date: Thu, 11 Jan 2024 09:44:07 +1100 Message-Id: <20240110224408.10444-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::829; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x829.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Signed-off-by: Richard Henderson --- tcg/s390x/tcg-target.h | 2 +- tcg/s390x/tcg-target.c.inc | 139 +++++++++++++++++++++++++------------ 2 files changed, 97 insertions(+), 44 deletions(-) diff --git a/tcg/s390x/tcg-target.h b/tcg/s390x/tcg-target.h index 53bed8c8d2..ae448c3a3a 100644 --- a/tcg/s390x/tcg-target.h +++ b/tcg/s390x/tcg-target.h @@ -138,7 +138,7 @@ extern uint64_t s390_facilities[3]; #define TCG_TARGET_HAS_qemu_ldst_i128 1 -#define TCG_TARGET_HAS_tst 0 +#define TCG_TARGET_HAS_tst 1 #define TCG_TARGET_HAS_v64 HAVE_FACILITY(VECTOR) #define TCG_TARGET_HAS_v128 HAVE_FACILITY(VECTOR) diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc index 86ec737768..cb1693c9cf 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -112,6 +112,9 @@ typedef enum S390Opcode { RI_OILH = 0xa50a, RI_OILL = 0xa50b, RI_TMLL = 0xa701, + RI_TMLH = 0xa700, + RI_TMHL = 0xa703, + RI_TMHH = 0xa702, RIEb_CGRJ = 0xec64, RIEb_CLGRJ = 0xec65, @@ -404,10 +407,15 @@ static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) #define S390_CC_NEVER 0 #define S390_CC_ALWAYS 15 +#define S390_TM_EQ 8 /* CC == 0 */ +#define S390_TM_NE 7 /* CC in {1,2,3} */ + /* Condition codes that result from a COMPARE and COMPARE LOGICAL. */ -static const uint8_t tcg_cond_to_s390_cond[] = { +static const uint8_t tcg_cond_to_s390_cond[16] = { [TCG_COND_EQ] = S390_CC_EQ, [TCG_COND_NE] = S390_CC_NE, + [TCG_COND_TSTEQ] = S390_CC_EQ, + [TCG_COND_TSTNE] = S390_CC_NE, [TCG_COND_LT] = S390_CC_LT, [TCG_COND_LE] = S390_CC_LE, [TCG_COND_GT] = S390_CC_GT, @@ -421,9 +429,11 @@ static const uint8_t tcg_cond_to_s390_cond[] = { /* Condition codes that result from a LOAD AND TEST. Here, we have no unsigned instruction variation, however since the test is vs zero we can re-map the outcomes appropriately. */ -static const uint8_t tcg_cond_to_ltr_cond[] = { +static const uint8_t tcg_cond_to_ltr_cond[16] = { [TCG_COND_EQ] = S390_CC_EQ, [TCG_COND_NE] = S390_CC_NE, + [TCG_COND_TSTEQ] = S390_CC_ALWAYS, + [TCG_COND_TSTNE] = S390_CC_NEVER, [TCG_COND_LT] = S390_CC_LT, [TCG_COND_LE] = S390_CC_LE, [TCG_COND_GT] = S390_CC_GT, @@ -542,10 +552,13 @@ static bool risbg_mask(uint64_t c) static bool tcg_target_const_match(int64_t val, int ct, TCGType type, TCGCond cond, int vece) { + uint64_t uval = val; + if (ct & TCG_CT_CONST) { return true; } if (type == TCG_TYPE_I32) { + uval = (uint32_t)val; val = (int32_t)val; } @@ -567,6 +580,15 @@ static bool tcg_target_const_match(int64_t val, int ct, case TCG_COND_GTU: ct |= TCG_CT_CONST_U32; /* CLGFI */ break; + case TCG_COND_TSTNE: + case TCG_COND_TSTEQ: + if (is_const_p16(uval) >= 0) { + return true; /* TMxx */ + } + if (risbg_mask(uval)) { + return true; /* RISBG */ + } + break; default: g_assert_not_reached(); } @@ -588,10 +610,6 @@ static bool tcg_target_const_match(int64_t val, int ct, if (ct & TCG_CT_CONST_INV) { val = ~val; } - /* - * Note that is_const_p16 is a subset of is_const_p32, - * so we don't need both constraints. - */ if ((ct & TCG_CT_CONST_P32) && is_const_p32(val) >= 0) { return true; } @@ -868,6 +886,9 @@ static const S390Opcode oi_insns[4] = { static const S390Opcode lif_insns[2] = { RIL_LLILF, RIL_LLIHF, }; +static const S390Opcode tm_insns[4] = { + RI_TMLL, RI_TMLH, RI_TMHL, RI_TMHH +}; /* load a register with an immediate value */ static void tcg_out_movi(TCGContext *s, TCGType type, @@ -1228,6 +1249,36 @@ static int tgen_cmp2(TCGContext *s, TCGType type, TCGCond c, TCGReg r1, TCGCond inv_c = tcg_invert_cond(c); S390Opcode op; + if (is_tst_cond(c)) { + tcg_debug_assert(!need_carry); + + if (!c2const) { + if (type == TCG_TYPE_I32) { + tcg_out_insn(s, RRFa, NRK, TCG_REG_R0, r1, c2); + } else { + tcg_out_insn(s, RRFa, NGRK, TCG_REG_R0, r1, c2); + } + goto exit; + } + + if (type == TCG_TYPE_I32) { + c2 = (uint32_t)c2; + } + + int i = is_const_p16(c2); + if (i >= 0) { + tcg_out_insn_RI(s, tm_insns[i], r1, c2 >> (i * 16)); + *inv_cc = TCG_COND_TSTEQ ? S390_TM_NE : S390_TM_EQ; + return *inv_cc ^ 15; + } + + if (risbg_mask(c2)) { + tgen_andi_risbg(s, TCG_REG_R0, r1, c2); + goto exit; + } + g_assert_not_reached(); + } + if (c2const) { if (c2 == 0) { if (!(is_unsigned && need_carry)) { @@ -1553,46 +1604,49 @@ static void tgen_brcond(TCGContext *s, TCGType type, TCGCond c, TCGReg r1, TCGArg c2, int c2const, TCGLabel *l) { int cc; - bool is_unsigned = is_unsigned_cond(c); - bool in_range; - S390Opcode opc; - cc = tcg_cond_to_s390_cond[c]; + if (!is_tst_cond(c)) { + bool is_unsigned = is_unsigned_cond(c); + bool in_range; + S390Opcode opc; - if (!c2const) { - opc = (type == TCG_TYPE_I32 - ? (is_unsigned ? RIEb_CLRJ : RIEb_CRJ) - : (is_unsigned ? RIEb_CLGRJ : RIEb_CGRJ)); - tgen_compare_branch(s, opc, cc, r1, c2, l); - return; - } + cc = tcg_cond_to_s390_cond[c]; - /* - * COMPARE IMMEDIATE AND BRANCH RELATIVE has an 8-bit immediate field. - * If the immediate we've been given does not fit that range, we'll - * fall back to separate compare and branch instructions using the - * larger comparison range afforded by COMPARE IMMEDIATE. - */ - if (type == TCG_TYPE_I32) { - if (is_unsigned) { - opc = RIEc_CLIJ; - in_range = (uint32_t)c2 == (uint8_t)c2; - } else { - opc = RIEc_CIJ; - in_range = (int32_t)c2 == (int8_t)c2; + if (!c2const) { + opc = (type == TCG_TYPE_I32 + ? (is_unsigned ? RIEb_CLRJ : RIEb_CRJ) + : (is_unsigned ? RIEb_CLGRJ : RIEb_CGRJ)); + tgen_compare_branch(s, opc, cc, r1, c2, l); + return; } - } else { - if (is_unsigned) { - opc = RIEc_CLGIJ; - in_range = (uint64_t)c2 == (uint8_t)c2; + + /* + * COMPARE IMMEDIATE AND BRANCH RELATIVE has an 8-bit immediate field. + * If the immediate we've been given does not fit that range, we'll + * fall back to separate compare and branch instructions using the + * larger comparison range afforded by COMPARE IMMEDIATE. + */ + if (type == TCG_TYPE_I32) { + if (is_unsigned) { + opc = RIEc_CLIJ; + in_range = (uint32_t)c2 == (uint8_t)c2; + } else { + opc = RIEc_CIJ; + in_range = (int32_t)c2 == (int8_t)c2; + } } else { - opc = RIEc_CGIJ; - in_range = (int64_t)c2 == (int8_t)c2; + if (is_unsigned) { + opc = RIEc_CLGIJ; + in_range = (uint64_t)c2 == (uint8_t)c2; + } else { + opc = RIEc_CGIJ; + in_range = (int64_t)c2 == (int8_t)c2; + } + } + if (in_range) { + tgen_compare_imm_branch(s, opc, cc, r1, c2, l); + return; } - } - if (in_range) { - tgen_compare_imm_branch(s, opc, cc, r1, c2, l); - return; } cc = tgen_cmp(s, type, c, r1, c2, c2const, false); @@ -1871,11 +1925,10 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h, ldst->oi = oi; ldst->addrlo_reg = addr_reg; - /* We are expecting a_bits to max out at 7, much lower than TMLL. */ tcg_debug_assert(a_mask <= 0xffff); tcg_out_insn(s, RI, TMLL, addr_reg, a_mask); - tcg_out16(s, RI_BRC | (7 << 4)); /* CC in {1,2,3} */ + tcg_out16(s, RI_BRC | (S390_TM_NE << 4)); ldst->label_ptr[0] = s->code_ptr++; } @@ -1956,7 +2009,7 @@ static void tcg_out_qemu_ldst_i128(TCGContext *s, TCGReg datalo, TCGReg datahi, l2 = gen_new_label(); tcg_out_insn(s, RI, TMLL, addr_reg, 15); - tgen_branch(s, 7, l1); /* CC in {1,2,3} */ + tgen_branch(s, S390_TM_NE, l1); } tcg_debug_assert(!need_bswap); From patchwork Wed Jan 10 22:44:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761499 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2113261wrz; Wed, 10 Jan 2024 14:49:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IHjh4y9UhmStff9a8kMlqVhEaNgdXnoi1/5S4D1wX3TaraNzrXPXiu939Ypu0q90SVPZOex X-Received: by 2002:a81:c44b:0:b0:5e8:45b6:5b8a with SMTP id s11-20020a81c44b000000b005e845b65b8amr400850ywj.6.1704926952518; Wed, 10 Jan 2024 14:49:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704926952; cv=none; d=google.com; s=arc-20160816; b=udOjcI/PkVzWxPnuUhikSKU5Yjop9M5xF+OSAIObJnRVTSp0dLkrekWJ9mjpibaAQH VI3+i2C+jdWNVxNwEcwCtZ7kZS68FmiQJPu5m0OO/MeFlIBPIKK51mKoDh+k/zp2Kma+ 9XKneN9cJx0YOKsqUwfRjcZRsoSzyGUJh72Yo19L8w0lG5YnQhZ6P5vHfqhYqKH1qxTQ Tddg80NhWs+7y8YVrKtGMUvBoDLNTnn6oJIhiWn1cgceYqF32s+E686fdIYlueYnXsCm ehfEDP9+YbGS175vg28nc/Tq6QbNgT1C5ZkhxZokn49M41TGv1XCo2WVd7dRJOhGzVHB ZA6w== 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=qTBa5jnTmGPw5Fiyw2n1vRD4BYHoTuI+qXkHnySYH1Q=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=YqJXUe6hDQ64F15ZQ4tv9nAXMYb1m2doWuSHhAz3yGKnmBetLwp4WO00uUyE949GYL Ng0K/tvOe1ZFLXmPfT/C686chkVPWGtKmi8OOE6qD0k0atdbivDYChp7ntx7cH8CTFv2 EzFnZLl5ZezNQfzMKN5AbgvSzLCaQS4iXFPnns4IJfv1pOI+ch6xCKKrS+LmCaR/on08 H3j9UO8CsLY3vMK5CeEe2/legzo+J7SoXShleTdWlj9S/ID0jphLPmD+dvF789VuXYrI c/YQ9X5NqqJWk0Z98RkQoMul/nfPPmJ/gLFirm4KpQhVgyv8ABeDTTKeW/IAPMSQWAbR sTAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q6PDwtMa; 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 v15-20020a05622a014f00b00429b91ea4e5si1513419qtw.458.2024.01.10.14.49.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:49:12 -0800 (PST) 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=q6PDwtMa; 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 1rNhM1-00034p-Vv; Wed, 10 Jan 2024 17:47:22 -0500 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 1rNhLu-0002d9-GE for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:47:15 -0500 Received: from mail-qk1-x729.google.com ([2607:f8b0:4864:20::729]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhLn-0003q4-0U for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:47:11 -0500 Received: by mail-qk1-x729.google.com with SMTP id af79cd13be357-783137d8049so430515885a.2 for ; Wed, 10 Jan 2024 14:47:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926826; x=1705531626; 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=qTBa5jnTmGPw5Fiyw2n1vRD4BYHoTuI+qXkHnySYH1Q=; b=q6PDwtMaTNwqQLbyr3qCzvVrJZOehoFEkK16IgQdxMCI8gXiEoyvqt1JR99APEwRuy Da+ey0pMXp8p3Hi7H6WzD8bWt0u8tGO18MeQHS1G20VcOwaRtTiGtyO3BgBKpfwUaZv6 TrMhE+nRwFvxC0GurCrdjf0yuWs17XDF71c678IX14jmFR/BXMnqXo1K22WCwZcR44BY LYPy6sT91SytcnQQHckTWQhydJKyv4GGAvWl/Z8Nxe6P+N+e1fX9+eKoFXpQIZBLxnB3 u0dbyKly/DfvW1T4BcZ6kAiwoAVoPPm1pk55q7itcxvZCZBZTQ5n3da1KRNqPjnz9Hzs GqRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926826; x=1705531626; 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=qTBa5jnTmGPw5Fiyw2n1vRD4BYHoTuI+qXkHnySYH1Q=; b=tOTEK0yFrwbfFGDadwUCKvaxI7QaH4p44D3dXPjydbSULaYFgdmlkALlxc4tw+WSdY s/Y5nIm+FV4duTP5HscTZwVFqESUSJhc8kG+UR0JaoudyvWfj0sPMfkUtAazVw6MgDyV 49MG/EKSr9zBo5ejNPnDU8YYYzl9S8qUWscTqhhtAwG2n6Xbva6j2c3xrnYfg2kzsjrg 9Ya8sXJhtKJN6BmblPYevbAdcLbqNad/ASgn5/5McXNxcCkQ5MUQVPeV+f2waqAqrYD5 wCvZfRuwXsNDrtrjhpHNVsEIouOcvt7s5096628yXlrzLkOetB+fW0juvfXq/gRIpik3 PbYQ== X-Gm-Message-State: AOJu0Yy6vbcJro4ZiNm7TCqfJF6TlxalmVyOLoOuTZXK8ypjBCfgYeXd 1CrTqgPIIthVhjm71mEo589hxYjccjn5sXPZG6HUj2YJvDKnbiZR X-Received: by 2002:a05:622a:216:b0:429:7dbd:1e50 with SMTP id b22-20020a05622a021600b004297dbd1e50mr246941qtx.110.1704926825914; Wed, 10 Jan 2024 14:47:05 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.47.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:47:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 38/38] tcg/tci: Support TCG_COND_TST{EQ,NE} Date: Thu, 11 Jan 2024 09:44:08 +1100 Message-Id: <20240110224408.10444-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::729; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x729.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, T_SCC_BODY_TEXT_LINE=-0.01 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 Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/tci/tcg-target.h | 2 +- tcg/tci.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index 609b2f4e4a..a076f401d2 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -117,7 +117,7 @@ #define TCG_TARGET_HAS_qemu_ldst_i128 0 -#define TCG_TARGET_HAS_tst 0 +#define TCG_TARGET_HAS_tst 1 /* Number of registers available. */ #define TCG_TARGET_NB_REGS 16 diff --git a/tcg/tci.c b/tcg/tci.c index 3cc851b7bd..39adcb7d82 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -228,6 +228,12 @@ static bool tci_compare32(uint32_t u0, uint32_t u1, TCGCond condition) case TCG_COND_GTU: result = (u0 > u1); break; + case TCG_COND_TSTEQ: + result = (u0 & u1) == 0; + break; + case TCG_COND_TSTNE: + result = (u0 & u1) != 0; + break; default: g_assert_not_reached(); } @@ -270,6 +276,12 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TCGCond condition) case TCG_COND_GTU: result = (u0 > u1); break; + case TCG_COND_TSTEQ: + result = (u0 & u1) == 0; + break; + case TCG_COND_TSTNE: + result = (u0 & u1) != 0; + break; default: g_assert_not_reached(); } @@ -1041,6 +1053,8 @@ static const char *str_c(TCGCond c) [TCG_COND_GEU] = "geu", [TCG_COND_LEU] = "leu", [TCG_COND_GTU] = "gtu", + [TCG_COND_TSTEQ] = "tsteq", + [TCG_COND_TSTNE] = "tstne", }; assert((unsigned)c < ARRAY_SIZE(cond));