From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926713; cv=none; d=zohomail.com; s=zohoarc; b=luD0RR1Jda3kQQocL7uEbXdyfP0y6fRgLnnLoihwS+b7LkFMB+713I3Kq7yiRyvleELg3Dtt/Xhw9r9/h01lNGSnj6fAs2JySWDMKrHSaTOTeh5jo78msc4L+JMXthlZ5+/5fmsouwUGQ4NM00Yirp5pA4PN+JJC8RQVxNPqWn4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926713; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Xe6YKO+UBE6YLyYsW2AZ/tSAY+8N62/s82QricPcuNc=; b=an4UQRxJuKRXcnTCdc1db2PeO2BE+yeinEnLQSTLtPl0bL4bv9rluSC3EW9wVaNBYWS3BEDlEnFPB+uG1mS8bpLNF9+G3KhZT57WbTJirQOwCxRa3PVZMMJb1OnBU+Dr9oOU0jfKTIfkZ5wxrV6lxVurC5KaxWFZHHM4IAOuS5U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926713885253.3404786288787; Wed, 10 Jan 2024 14:45:13 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IF1NAYLCxPrmliUSTAMHtenYTsFl3jAjQdyboTTBD7FebGoowI3yPJew2vrKuYGxKF5VEINqg== 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926715175100004 Add the enumerators, adjust the helpers to match, and dump. Not supported anywhere else just yet. Reviewed-by: Philippe Mathieu-Daud=C3=A9 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 =3D=3D 0 */`` + | ``TCG_COND_TSTNE /* t1 & t2 !=3D 0 */`` =20 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 =3D 0 | 0 | 0 | 0, TCG_COND_ALWAYS =3D 0 | 0 | 0 | 1, + + /* equality */ TCG_COND_EQ =3D 8 | 0 | 0 | 0, TCG_COND_NE =3D 8 | 0 | 0 | 1, + + /* "test" i.e. and then compare vs 0 */ + TCG_COND_TSTEQ =3D 8 | 4 | 0 | 0, + TCG_COND_TSTNE =3D 8 | 4 | 0 | 1, + /* signed */ TCG_COND_LT =3D 0 | 0 | 2 | 0, TCG_COND_GE =3D 0 | 0 | 2 | 1, - TCG_COND_LE =3D 8 | 0 | 2 | 0, - TCG_COND_GT =3D 8 | 0 | 2 | 1, + TCG_COND_GT =3D 0 | 4 | 2 | 0, + TCG_COND_LE =3D 0 | 4 | 2 | 1, + /* unsigned */ - TCG_COND_LTU =3D 0 | 4 | 0 | 0, - TCG_COND_GEU =3D 0 | 4 | 0 | 1, - TCG_COND_LEU =3D 8 | 4 | 0 | 0, - TCG_COND_GTU =3D 8 | 4 | 0 | 1, + TCG_COND_LTU =3D 8 | 0 | 2 | 0, + TCG_COND_GEU =3D 8 | 0 | 2 | 1, + TCG_COND_GTU =3D 8 | 4 | 2 | 0, + TCG_COND_LEU =3D 8 | 4 | 2 | 1, } TCGCond; =20 /* 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)); } =20 -/* 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)) =3D=3D 2; } =20 /* Must a comparison be considered unsigned? */ static inline bool is_unsigned_cond(TCGCond c) { - return (c & 4) !=3D 0; + return (c & (8 | 2)) =3D=3D (8 | 2); +} + +/* Must a comparison be considered a test? */ +static inline bool is_tst_cond(TCGCond c) +{ + return (c | 1) =3D=3D 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; } =20 /* @@ -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[] =3D [TCG_COND_LTU] =3D "ltu", [TCG_COND_GEU] =3D "geu", [TCG_COND_LEU] =3D "leu", - [TCG_COND_GTU] =3D "gtu" + [TCG_COND_GTU] =3D "gtu", + [TCG_COND_TSTEQ] =3D "tsteq", + [TCG_COND_TSTNE] =3D "tstne", }; =20 static const char * const ldst_name[(MO_BSWAP | MO_SSIZE) + 1] =3D --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926851; cv=none; d=zohomail.com; s=zohoarc; b=FybOA+WXQJxiYQ0PG3eBGRQPb7gilL8sEaWNMnPYXYSxg1Vb5l688dkLpkmbcAtDDYhQTN1//5RCIwVURciyxp9hHQMujG+Xd70g7YK9bhGRNWNOFai1tZae0kqPGzPBqtMfUB04J7hN3hThgcrJnNA9PDVSS5LbW03dVZlqXuo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926851; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XHALRgn6+R7mnoPisAPyxnrzriWZt0G/V66nE0399oE=; b=Ln3eCDh76G3HT78/IhVZjnnHVw5rp2yXl8ztZ17TEl/4yQsoUvqwRUfP2HzfGzy0i7NrJMVnWIN8KEeGfsTdkEmJUIuzfMxOg6Ym12BAc7EA53TA6pPRiHK4eHOmeevilUylQBVCwPJbcpINejMMCqWlyUJ4y1ioJSji5QbVnso= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926851461335.67087765752854; Wed, 10 Jan 2024 14:47:31 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IGqwBR2ufQFZs0dLeb4G5GUCLJoGZMrhIxw/nOkCCTai9IV39Ju7YAZit1+nPAHh1P1MvZUqA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926853378100018 Content-Type: text/plain; charset="utf-8" Define as 0 for all tcg backends. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 =20 +#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; =20 #define TCG_TARGET_HAS_qemu_ldst_i128 0 =20 +#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 =3D=3D 64 && (cpuinfo & CPUINFO_ATOMIC_VMOVDQA)) =20 +#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 { =20 #define TCG_TARGET_HAS_qemu_ldst_i128 (cpuinfo & CPUINFO_LSX) =20 +#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; =20 #define TCG_TARGET_HAS_qemu_ldst_i128 0 =20 +#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 =3D=3D 64 && have_isa_2_07) =20 +#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; =20 #define TCG_TARGET_HAS_qemu_ldst_i128 0 =20 +#define TCG_TARGET_HAS_tst 0 + #define TCG_TARGET_DEFAULT_MO (0) =20 #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]; =20 #define TCG_TARGET_HAS_qemu_ldst_i128 1 =20 +#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; =20 #define TCG_TARGET_HAS_qemu_ldst_i128 0 =20 +#define TCG_TARGET_HAS_tst 0 + #define TCG_AREG0 TCG_REG_I0 =20 #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 @@ =20 #define TCG_TARGET_HAS_qemu_ldst_i128 0 =20 +#define TCG_TARGET_HAS_tst 0 + /* Number of registers available. */ #define TCG_TARGET_NB_REGS 16 =20 --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926737; cv=none; d=zohomail.com; s=zohoarc; b=jVms8EswvPbtrysPIw6reiltoDvrz2Luv4wAZntBcgE/ye7O0KLI1NOxr0P9/uZZBsw+c37vLhf7QeYLalw2QEaCrCYPNK94Y2oqyVjwPwX2ejBb4P3UMv6YFWjdg9llPlrGdx/DSQwKImcOze25dnnTHjUo7MKPE4HwjDHAat4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926737; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XRwgTLH7x4qjGJwvWHPC6iD3rpKsmYUOnQgcGsFZM2o=; b=jMz5L9EsptfQukBI3+MCgnab5dr2n3TxjNM347qgwYt/HXsDrh0U2tTXZ74hUSjcTkslJKqv+fUpuWdXVWCgC3OwOsZaJmG3ODYnfQ+bjxcbvEuqiz+H91ltc4OYdXUuSVI+fXHb5CjKp/+Omq9+5b+96eES8bMOb0D0qAoOZqo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926737082444.60494245128154; Wed, 10 Jan 2024 14:45:37 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IF78akp1YBq1mO/ArcSP7+VRZUtFrVQ+wlzum9zcHHva4z+nhK7yOVXHN0/+AAwhrkJvi2Z7Q== 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926738940100001 Reviewed-by: Philippe Mathieu-Daud=C3=A9 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; } =20 +static inline bool ts_is_const_val(TCGTemp *ts, uint64_t val) +{ + TempOptInfo *ti =3D ts_info(ts); + return ti->is_const && ti->val =3D=3D val; +} + static inline bool arg_is_const(TCGArg arg) { return ts_is_const(arg_temp(arg)); } =20 +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 !=3D ts; @@ -689,7 +700,7 @@ static int do_constant_folding_cond(TCGType type, TCGAr= g 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 =3D=3D 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 =3D=3D 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, ui= nt64_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 =3D=3D 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 =3D=3D 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, ui= nt64_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 =3D=3D 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, u= int64_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 =3D=3D 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 =3D=3D= 0 && - arg_is_const(op->args[3]) && arg_info(op->args[3])->val =3D=3D= 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) } =20 /* Inserting a value into zero at offset 0. */ - if (arg_is_const(op->args[1]) - && arg_info(op->args[1])->val =3D=3D 0 - && op->args[3] =3D=3D 0) { + if (arg_is_const_val(op->args[1], 0) && op->args[3] =3D=3D 0) { uint64_t mask =3D MAKE_64BIT_MASK(0, op->args[4]); =20 op->opc =3D and_opc; @@ -1461,8 +1470,7 @@ static bool fold_deposit(OptContext *ctx, TCGOp *op) } =20 /* Inserting zero into a value. */ - if (arg_is_const(op->args[2]) - && arg_info(op->args[2])->val =3D=3D 0) { + if (arg_is_const_val(op->args[2], 0)) { uint64_t mask =3D deposit64(-1, op->args[3], op->args[4], 0); =20 op->opc =3D 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 =3D=3D= 0 && - arg_is_const(op->args[4]) && arg_info(op->args[4])->val =3D=3D= 0) { + if (arg_is_const_val(op->args[3], 0) && + arg_is_const_val(op->args[4], 0)) { goto do_setcond_high; } break; --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926732; cv=none; d=zohomail.com; s=zohoarc; b=aLYdMikiADkLm0m7idJoo+kf/L8yQP32n4gOybIGsTHnazPRE/fo/FActdY+dxXm6l/eKyv/pKHKS2UuBoR3uXdRoV0jMD+RP/bPx8PdbUHnQYhhGQCtKrMcVPcZWy8hkXD6uljGLsBZCC7/9qbv9aSGoue7dXl5pGqPeaw6xNo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926732; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=rCOb1ACImxEyjzPr7SpomivAS+ARwGZqu81A17yuvPw=; b=HAPJpDwlMkDd9TpiHFmWRB29EM+Ymx9qHD+Hhqq8p703RMkePwz5KERVuH+PBX/pqCEpUcuVlrg/dDxRNIgwOJnsBOBHPIxKQ4ubsT3mzTkXuq+JriRQwpIkE6KHKaNRh23xor1IfJxHPJWlkVpgiZ7hPkJD/6eCBtrCOFIeFuY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926731890129.28443741827243; Wed, 10 Jan 2024 14:45:31 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IEk7fq1MVhUig0WRcqhlci/Egljzz1a0tZWIqxK+LxTfRbzVb6P0+7cM0qnT1hfonGnBJPncA== 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926733223100002 Handle modifications to the arguments and condition in a single place. Reviewed-by: Philippe Mathieu-Daud=C3=A9 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; } =20 +static int do_constant_folding_cond1(OptContext *ctx, TCGArg dest, + TCGArg *p1, TCGArg *p2, TCGArg *pcond) +{ + TCGCond cond; + bool swap; + int r; + + swap =3D swap_commutative(dest, p1, p2); + cond =3D *pcond; + if (swap) { + *pcond =3D cond =3D tcg_swap_cond(cond); + } + + r =3D 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 =3D 0; i < nb_args; i++) { @@ -1193,14 +1210,8 @@ static bool fold_andc(OptContext *ctx, TCGOp *op) =20 static bool fold_brcond(OptContext *ctx, TCGOp *op) { - TCGCond cond =3D op->args[2]; - int i; - - if (swap_commutative(NO_DEST, &op->args[0], &op->args[1])) { - op->args[2] =3D cond =3D tcg_swap_cond(cond); - } - - i =3D do_constant_folding_cond(ctx->type, op->args[0], op->args[1], co= nd); + int i =3D do_constant_folding_cond1(ctx, NO_DEST, &op->args[0], + &op->args[1], &op->args[2]); if (i =3D=3D 0) { tcg_op_remove(ctx->tcg, op); return true; @@ -1695,21 +1706,18 @@ static bool fold_mov(OptContext *ctx, TCGOp *op) =20 static bool fold_movcond(OptContext *ctx, TCGOp *op) { - TCGCond cond =3D op->args[5]; int i; =20 - if (swap_commutative(NO_DEST, &op->args[1], &op->args[2])) { - op->args[5] =3D cond =3D 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] =3D cond =3D tcg_invert_cond(cond); + op->args[5] =3D tcg_invert_cond(op->args[5]); } =20 - i =3D do_constant_folding_cond(ctx->type, op->args[1], op->args[2], co= nd); + i =3D do_constant_folding_cond1(ctx, NO_DEST, &op->args[1], + &op->args[2], &op->args[5]); if (i >=3D 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 =3D arg_info(op->args[3])->val; uint64_t fv =3D arg_info(op->args[4])->val; TCGOpcode opc, negopc =3D 0; + TCGCond cond =3D op->args[5]; =20 switch (ctx->type) { case TCG_TYPE_I32: @@ -1950,14 +1959,8 @@ static bool fold_remainder(OptContext *ctx, TCGOp *o= p) =20 static bool fold_setcond(OptContext *ctx, TCGOp *op) { - TCGCond cond =3D op->args[3]; - int i; - - if (swap_commutative(op->args[0], &op->args[1], &op->args[2])) { - op->args[3] =3D cond =3D tcg_swap_cond(cond); - } - - i =3D do_constant_folding_cond(ctx->type, op->args[1], op->args[2], co= nd); + int i =3D do_constant_folding_cond1(ctx, op->args[0], &op->args[1], + &op->args[2], &op->args[3]); if (i >=3D 0) { return tcg_opt_gen_movi(ctx, op, op->args[0], i); } @@ -1969,14 +1972,8 @@ static bool fold_setcond(OptContext *ctx, TCGOp *op) =20 static bool fold_negsetcond(OptContext *ctx, TCGOp *op) { - TCGCond cond =3D op->args[3]; - int i; - - if (swap_commutative(op->args[0], &op->args[1], &op->args[2])) { - op->args[3] =3D cond =3D tcg_swap_cond(cond); - } - - i =3D do_constant_folding_cond(ctx->type, op->args[1], op->args[2], co= nd); + int i =3D do_constant_folding_cond1(ctx, op->args[0], &op->args[1], + &op->args[2], &op->args[3]); if (i >=3D 0) { return tcg_opt_gen_movi(ctx, op, op->args[0], -i); } --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926799; cv=none; d=zohomail.com; s=zohoarc; b=PcQPpDuSbzoGBMnWiylTjZLl95K/36VddXMTZxoTSVLJutyqqLhtbUTYnsiIYP7/iJFQGEOGZNEXEHcIlzNNVF++F3hgRwHMCyctH+Gv8ICrGxsaTHW+t/zuxsNx40Aeq1R+HC8lGmPxO2rYl0N3i1e5kkRQkvzxresL5vjBbws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926799; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VRgNiPJydpvDmMhlC8JjCGm8KjRyw9Ww/5hSgKncWeA=; b=FwpFXbLpBiDFFAORzZeCfoN0ICR9Hi4TV2FyVFOfLXIIyNZFYBEDSYvPBtoPbuOUbjvcrv6MBbHVaBGuNyCwcWcYezc0AJxxgeUGW3DVkUGYiJRxs9pXnuHUmgFxu0IH9ORh7FnBfYlRqVmE1zz07sCZs6iS4iQwJVVbctp7WYA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170492679902834.82072223540604; Wed, 10 Jan 2024 14:46:39 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IEKVe5t7LdUA50/Q3Z8q5b39g736y2vs5XArUJydfwgIDYXBM1y6Kn6em3c5uWN7opwF/nz7A== 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926801239100003 Mirror the new do_constant_folding_cond1 by doing all argument and condition adjustment within one helper. Reviewed-by: Philippe Mathieu-Daud=C3=A9 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, TCGA= rg x, return -1; } =20 -/* - * 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 =3D p1[0], ah =3D p1[1]; - TCGArg bl =3D p2[0], bh =3D p2[1]; - - if (arg_is_const(bl) && arg_is_const(bh)) { - tcg_target_ulong blv =3D arg_info(bl)->val; - tcg_target_ulong bhv =3D arg_info(bh)->val; - uint64_t b =3D deposit64(blv, 32, 32, bhv); - - if (arg_is_const(al) && arg_is_const(ah)) { - tcg_target_ulong alv =3D arg_info(al)->val; - tcg_target_ulong ahv =3D arg_info(ah)->val; - uint64_t a =3D deposit64(alv, 32, 32, ahv); - return do_constant_folding_cond_64(a, b, c); - } - if (b =3D=3D 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; } =20 +/* + * 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; } =20 +static int do_constant_folding_cond2(OptContext *ctx, TCGArg *args) +{ + TCGArg al, ah, bl, bh; + TCGCond c; + bool swap; + + swap =3D swap_commutative2(args, args + 2); + c =3D args[4]; + if (swap) { + args[4] =3D c =3D tcg_swap_cond(c); + } + + al =3D args[0]; + ah =3D args[1]; + bl =3D args[2]; + bh =3D args[3]; + + if (arg_is_const(bl) && arg_is_const(bh)) { + tcg_target_ulong blv =3D arg_info(bl)->val; + tcg_target_ulong bhv =3D arg_info(bh)->val; + uint64_t b =3D deposit64(blv, 32, 32, bhv); + + if (arg_is_const(al) && arg_is_const(ah)) { + tcg_target_ulong alv =3D arg_info(al)->val; + tcg_target_ulong ahv =3D arg_info(ah)->val; + uint64_t a =3D deposit64(alv, 32, 32, ahv); + return do_constant_folding_cond_64(a, b, c); + } + if (b =3D=3D 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 =3D 0; i < nb_args; i++) { @@ -1225,15 +1237,13 @@ static bool fold_brcond(OptContext *ctx, TCGOp *op) =20 static bool fold_brcond2(OptContext *ctx, TCGOp *op) { - TCGCond cond =3D op->args[4]; - TCGArg label =3D op->args[5]; + TCGCond cond; + TCGArg label; int i, inv =3D 0; =20 - if (swap_commutative2(&op->args[0], &op->args[2])) { - op->args[4] =3D cond =3D tcg_swap_cond(cond); - } - - i =3D do_constant_folding_cond2(&op->args[0], &op->args[2], cond); + i =3D do_constant_folding_cond2(ctx, &op->args[0]); + cond =3D op->args[4]; + label =3D op->args[5]; if (i >=3D 0) { goto do_brcond_const; } @@ -1986,14 +1996,11 @@ static bool fold_negsetcond(OptContext *ctx, TCGOp = *op) =20 static bool fold_setcond2(OptContext *ctx, TCGOp *op) { - TCGCond cond =3D op->args[5]; + TCGCond cond; int i, inv =3D 0; =20 - if (swap_commutative2(&op->args[1], &op->args[3])) { - op->args[5] =3D cond =3D tcg_swap_cond(cond); - } - - i =3D do_constant_folding_cond2(&op->args[1], &op->args[3], cond); + i =3D do_constant_folding_cond2(ctx, &op->args[1]); + cond =3D op->args[5]; if (i >=3D 0) { goto do_setcond_const; } --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926780; cv=none; d=zohomail.com; s=zohoarc; b=MdFZqfbo+WbonsaJofUiZLCE5SGIboE9j1TyWsrYwyQAaZJEgx8ByVWR0CBQBPq+YXrqGRoar+eCukgMvufc8gZHtGZ/WyQ6vgMBaTrVFrXTBMtu87ob30AGuzvRBfY+ZNv3LWyFYQNjFRXUi1L6QCaV20ZDN4z46LQY6cNoO3w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926780; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4WPFWKge9Cibe1+P1uYI+mpRsrAd20eTdoBjuJnsUMU=; b=NV29ImUhCW8+qJCFTAgKmjtkTA+99t23hM2jrqX94DNPcfjGDJqFrdWRRCYHKO/UXP24kP12W/iBCoGMpTerMKW3AanMI9NP4dQW0vR9k8zNlB72cOKGO3R/yi9dLS8VRFOmzFoyQvvth6GL2wZvjxGNMmF6bh5v4vaBfNnpILM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926780894186.15196378670942; Wed, 10 Jan 2024 14:46:20 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IFEXXc9FPOw/i4DdLRSFfj45YIIwXvllfe7yDGf2oB57ZxU5gK12aqp/jDGBLDrLNFgImn24w== 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926783110100006 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=C3=A9 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, ui= nt32_t y, TCGCond c) return x <=3D y; case TCG_COND_GTU: return x > y; - default: - g_assert_not_reached(); + case TCG_COND_TSTEQ: + return (x & y) =3D=3D 0; + case TCG_COND_TSTNE: + return (x & y) !=3D 0; + case TCG_COND_ALWAYS: + case TCG_COND_NEVER: + break; } + g_assert_not_reached(); } =20 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, u= int64_t y, TCGCond c) return x <=3D y; case TCG_COND_GTU: return x > y; - default: - g_assert_not_reached(); + case TCG_COND_TSTEQ: + return (x & y) =3D=3D 0; + case TCG_COND_TSTNE: + return (x & y) !=3D 0; + case TCG_COND_ALWAYS: + case TCG_COND_NEVER: + break; } + g_assert_not_reached(); } =20 -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(); } =20 /* @@ -703,8 +720,10 @@ static int do_constant_folding_cond(TCGType type, TCGA= rg 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, } =20 r =3D do_constant_folding_cond(ctx->type, *p1, *p2, cond); - return r; + if (r >=3D 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 =3D arg_new_constant(ctx, 0); + *pcond =3D tcg_tst_eqne_cond(cond); + return -1; + } + + /* TSTNE x,sign -> LT x,0 */ + if (arg_is_const_val(*p2, (ctx->type =3D=3D TCG_TYPE_I32 + ? INT32_MIN : INT64_MIN))) { + *p2 =3D arg_new_constant(ctx, 0); + *pcond =3D tcg_tst_ltge_cond(cond); + } + return -1; } =20 static int do_constant_folding_cond2(OptContext *ctx, TCGArg *args) @@ -785,6 +827,7 @@ static int do_constant_folding_cond2(OptContext *ctx, T= CGArg *args) TCGArg al, ah, bl, bh; TCGCond c; bool swap; + int r; =20 swap =3D swap_commutative2(args, args + 2); c =3D args[4]; @@ -806,21 +849,54 @@ static int do_constant_folding_cond2(OptContext *ctx,= TCGArg *args) tcg_target_ulong alv =3D arg_info(al)->val; tcg_target_ulong ahv =3D arg_info(ah)->val; uint64_t a =3D deposit64(alv, 32, 32, ahv); - return do_constant_folding_cond_64(a, b, c); + + r =3D do_constant_folding_cond_64(a, b, c); + if (r >=3D 0) { + return r; + } } + if (b =3D=3D 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 =3D=3D -1 && is_tst_cond(c)) { + args[3] =3D args[2] =3D arg_new_constant(ctx, 0); + args[4] =3D tcg_tst_eqne_cond(c); + return -1; + } + + /* TSTNE x,sign -> LT x,0 */ + if (b =3D=3D INT64_MIN && is_tst_cond(c)) { + /* bl must be 0, so copy that to bh */ + args[3] =3D bl; + args[4] =3D 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 =3D do_constant_folding_cond_eq(c); + if (r >=3D 0) { + return r; + } + + /* TSTNE x,x -> NE x,0 */ + if (is_tst_cond(c)) { + args[3] =3D args[2] =3D arg_new_constant(ctx, 0); + args[4] =3D 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 =3D INDEX_op_brcond_i32; - op->args[1] =3D op->args[2]; - op->args[2] =3D cond; - op->args[3] =3D 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; =20 default: break; =20 + do_brcond_low: + op->opc =3D INDEX_op_brcond_i32; + op->args[1] =3D op->args[2]; + op->args[2] =3D cond; + op->args[3] =3D label; + return fold_brcond(ctx, op); + do_brcond_high: op->opc =3D INDEX_op_brcond_i32; op->args[0] =3D op->args[1]; op->args[1] =3D op->args[3]; op->args[2] =3D cond; op->args[3] =3D label; - break; + return fold_brcond(ctx, op); =20 do_brcond_const: if (i =3D=3D 0) { @@ -1967,6 +2056,99 @@ static bool fold_remainder(OptContext *ctx, TCGOp *o= p) return false; } =20 +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 =3D 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 =3D op->args[2]; + val =3D arg_info(src2)->val; + if (!is_power_of_2(val)) { + return; + } + sh =3D ctz64(val); + + switch (ctx->type) { + case TCG_TYPE_I32: + and_opc =3D INDEX_op_and_i32; + sub_opc =3D INDEX_op_sub_i32; + xor_opc =3D INDEX_op_xor_i32; + shr_opc =3D INDEX_op_shr_i32; + neg_opc =3D INDEX_op_neg_i32; + if (TCG_TARGET_extract_i32_valid(sh, 1)) { + uext_opc =3D TCG_TARGET_HAS_extract_i32 ? INDEX_op_extract_i32= : 0; + sext_opc =3D TCG_TARGET_HAS_sextract_i32 ? INDEX_op_sextract_i= 32 : 0; + } + break; + case TCG_TYPE_I64: + and_opc =3D INDEX_op_and_i64; + sub_opc =3D INDEX_op_sub_i64; + xor_opc =3D INDEX_op_xor_i64; + shr_opc =3D INDEX_op_shr_i64; + neg_opc =3D INDEX_op_neg_i64; + if (TCG_TARGET_extract_i64_valid(sh, 1)) { + uext_opc =3D TCG_TARGET_HAS_extract_i64 ? INDEX_op_extract_i64= : 0; + sext_opc =3D TCG_TARGET_HAS_sextract_i64 ? INDEX_op_sextract_i= 64 : 0; + } + break; + default: + g_assert_not_reached(); + } + + ret =3D op->args[0]; + src1 =3D op->args[1]; + inv =3D cond =3D=3D TCG_COND_TSTEQ; + + if (sh && sext_opc && neg && !inv) { + op->opc =3D sext_opc; + op->args[1] =3D src1; + op->args[2] =3D sh; + op->args[3] =3D 1; + return; + } else if (sh && uext_opc) { + op->opc =3D uext_opc; + op->args[1] =3D src1; + op->args[2] =3D sh; + op->args[3] =3D 1; + } else { + if (sh) { + op2 =3D tcg_op_insert_before(ctx->tcg, op, shr_opc, 3); + op2->args[0] =3D ret; + op2->args[1] =3D src1; + op2->args[2] =3D arg_new_constant(ctx, sh); + src1 =3D ret; + } + op->opc =3D and_opc; + op->args[1] =3D src1; + op->args[2] =3D arg_new_constant(ctx, 1); + } + + if (neg && inv) { + op2 =3D tcg_op_insert_after(ctx->tcg, op, sub_opc, 3); + op2->args[0] =3D ret; + op2->args[1] =3D ret; + op2->args[2] =3D arg_new_constant(ctx, 1); + } else if (inv) { + op2 =3D tcg_op_insert_after(ctx->tcg, op, xor_opc, 3); + op2->args[0] =3D ret; + op2->args[1] =3D ret; + op2->args[2] =3D arg_new_constant(ctx, 1); + } else if (neg) { + op2 =3D tcg_op_insert_after(ctx->tcg, op, neg_opc, 2); + op2->args[0] =3D ret; + op2->args[1] =3D ret; + } +} + static bool fold_setcond(OptContext *ctx, TCGOp *op) { int i =3D 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 >=3D 0) { return tcg_opt_gen_movi(ctx, op, op->args[0], i); } + fold_setcond_tst_pow2(ctx, op, false); =20 ctx->z_mask =3D 1; ctx->s_mask =3D smask_from_zmask(1); @@ -1987,13 +2170,13 @@ static bool fold_negsetcond(OptContext *ctx, TCGOp = *op) if (i >=3D 0) { return tcg_opt_gen_movi(ctx, op, op->args[0], -i); } + fold_setcond_tst_pow2(ctx, op, true); =20 /* Value is {0,-1} so all bits are repetitions of the sign. */ ctx->s_mask =3D -1; return false; } =20 - static bool fold_setcond2(OptContext *ctx, TCGOp *op) { TCGCond cond; @@ -2041,22 +2224,35 @@ static bool fold_setcond2(OptContext *ctx, TCGOp *o= p) case 0: goto do_setcond_const; case 1: - op->args[2] =3D op->args[3]; - op->args[3] =3D cond; - op->opc =3D 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; =20 default: break; =20 + do_setcond_low: + op->args[2] =3D op->args[3]; + op->args[3] =3D cond; + op->opc =3D INDEX_op_setcond_i32; + return fold_setcond(ctx, op); + do_setcond_high: op->args[1] =3D op->args[2]; op->args[2] =3D op->args[4]; op->args[3] =3D cond; op->opc =3D INDEX_op_setcond_i32; - break; + return fold_setcond(ctx, op); } =20 ctx->z_mask =3D 1; --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926933733703.5371158790749; Wed, 10 Jan 2024 14:48:53 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IHdKv3jBs+ypfoFgSjfogUm9LKhVW+JE9Dq65WGNk8GxePySztDJmRzQONs+bztmo/ZbU7ryw== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1704926935737100001 Content-Type: text/plain; charset="utf-8" After having performed other simplifications, lower any remaining test comparisons with AND. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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) =20 bool tcg_target_has_memory_bswap(MemOp memop); =20 +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); } =20 +static TCGArg arg_new_temp(OptContext *ctx) +{ + TCGTemp *ts =3D 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 =3D 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 de= st, 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 =3D arg_new_constant(ctx, 0); *pcond =3D 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 =3D (ctx->type =3D=3D TCG_TYPE_I32 + ? INDEX_op_and_i32 : INDEX_op_and_i64); + TCGOp *op2 =3D tcg_op_insert_before(ctx->tcg, op, and_opc, 3); + TCGArg tmp =3D arg_new_temp(ctx); + + op2->args[0] =3D tmp; + op2->args[1] =3D *p1; + op2->args[2] =3D *p2; + + *p1 =3D tmp; + *p2 =3D arg_new_constant(ctx, 0); + *pcond =3D tcg_tst_eqne_cond(cond); } return -1; } =20 -static int do_constant_folding_cond2(OptContext *ctx, TCGArg *args) +static int do_constant_folding_cond2(OptContext *ctx, TCGOp *op, TCGArg *a= rgs) { 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 =3D tcg_op_insert_before(ctx->tcg, op, INDEX_op_and_i32= , 3); + TCGOp *op2 =3D tcg_op_insert_before(ctx->tcg, op, INDEX_op_and_i32= , 3); + TCGArg t1 =3D arg_new_temp(ctx); + TCGArg t2 =3D arg_new_temp(ctx); + + op1->args[0] =3D t1; + op1->args[1] =3D al; + op1->args[2] =3D bl; + op2->args[0] =3D t2; + op2->args[1] =3D ah; + op2->args[2] =3D bh; + + args[0] =3D t1; + args[1] =3D t2; + args[3] =3D args[2] =3D arg_new_constant(ctx, 0); + args[4] =3D tcg_tst_eqne_cond(c); + } return -1; } =20 @@ -1298,7 +1342,7 @@ static bool fold_andc(OptContext *ctx, TCGOp *op) =20 static bool fold_brcond(OptContext *ctx, TCGOp *op) { - int i =3D do_constant_folding_cond1(ctx, NO_DEST, &op->args[0], + int i =3D do_constant_folding_cond1(ctx, op, NO_DEST, &op->args[0], &op->args[1], &op->args[2]); if (i =3D=3D 0) { tcg_op_remove(ctx->tcg, op); @@ -1317,7 +1361,7 @@ static bool fold_brcond2(OptContext *ctx, TCGOp *op) TCGArg label; int i, inv =3D 0; =20 - i =3D do_constant_folding_cond2(ctx, &op->args[0]); + i =3D do_constant_folding_cond2(ctx, op, &op->args[0]); cond =3D op->args[4]; label =3D op->args[5]; if (i >=3D 0) { @@ -1815,7 +1859,7 @@ static bool fold_movcond(OptContext *ctx, TCGOp *op) op->args[5] =3D tcg_invert_cond(op->args[5]); } =20 - i =3D do_constant_folding_cond1(ctx, NO_DEST, &op->args[1], + i =3D do_constant_folding_cond1(ctx, op, NO_DEST, &op->args[1], &op->args[2], &op->args[5]); if (i >=3D 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, TC= GOp *op, bool neg) =20 static bool fold_setcond(OptContext *ctx, TCGOp *op) { - int i =3D do_constant_folding_cond1(ctx, op->args[0], &op->args[1], + int i =3D do_constant_folding_cond1(ctx, op, op->args[0], &op->args[1], &op->args[2], &op->args[3]); if (i >=3D 0) { return tcg_opt_gen_movi(ctx, op, op->args[0], i); @@ -2165,7 +2209,7 @@ static bool fold_setcond(OptContext *ctx, TCGOp *op) =20 static bool fold_negsetcond(OptContext *ctx, TCGOp *op) { - int i =3D do_constant_folding_cond1(ctx, op->args[0], &op->args[1], + int i =3D do_constant_folding_cond1(ctx, op, op->args[0], &op->args[1], &op->args[2], &op->args[3]); if (i >=3D 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 =3D 0; =20 - i =3D do_constant_folding_cond2(ctx, &op->args[1]); + i =3D do_constant_folding_cond2(ctx, op, &op->args[1]); cond =3D op->args[5]; if (i >=3D 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); } =20 -static TCGTemp *tcg_temp_new_internal(TCGType type, TCGTempKind kind) +TCGTemp *tcg_temp_new_internal(TCGType type, TCGTempKind kind) { TCGContext *s =3D tcg_ctx; TCGTemp *ts; --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926926; cv=none; d=zohomail.com; s=zohoarc; b=alYS7qlnQK+qpyFijd22VsGGnAXopMd3hOmYvc4/hyNAcEDfjljz8USFNzv3GAPV+TFGIbmggCnzNSq1bIu24h00CgJ3IkyvvSeLXr2PE89wETOJHVfV2tpDa5bvOfVK0g2pOPaYxdGvXq6B4n5h1ViB8caGpz4prUtDHz8sHuE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926926; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UglnfSI98W1O26WExoHEv4U96HoZn03cAysbwbueFqA=; b=oCEXUK3uNxQdFRJOlEPCLBD9LIDcamOTjvfob8/2xhqHE6FTam/jHxvKfocswIr1bwW3lEhqKc3b9jz46hbJ/xAGaByhc5GZL2mgAgJaRhW+y0Op/KJB759QV0N0g10vuXPgUjHItG+PGZtd/BLia6Uui7/nkIeTSJzBzvdnMUI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926926273858.4687794838484; Wed, 10 Jan 2024 14:48:46 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IEMLGQF3NArf0UuRpkVsNCPecDhKLkSw2SS7v0uDIFDUsxoL8qP0sgLh/Z5xZRo5zIu0YRMkw== 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926927668100001 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=C3=A9 Message-Id: <20231108205247.83234-1-philmd@linaro.org> Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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, i= nt ra, int32_t disp) } =20 static DisasJumpType gen_bcond_internal(DisasContext *ctx, TCGCond cond, - TCGv cmp, int32_t disp) + TCGv cmp, uint64_t imm, int32_t di= sp) { uint64_t dest =3D ctx->base.pc_next + (disp << 2); TCGLabel *lab_true =3D gen_new_label(); =20 if (use_goto_tb(ctx, dest)) { - tcg_gen_brcondi_i64(cond, cmp, 0, lab_true); + tcg_gen_brcondi_i64(cond, cmp, imm, lab_true); =20 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, =20 return DISAS_NORETURN; } else { - TCGv_i64 z =3D load_zero(ctx); + TCGv_i64 i =3D tcg_constant_i64(imm); TCGv_i64 d =3D tcg_constant_i64(dest); TCGv_i64 p =3D tcg_constant_i64(ctx->base.pc_next); =20 - 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 =3D tcg_temp_new(); - DisasJumpType ret; - - tcg_gen_andi_i64(tmp, load_gpr(ctx, ra), 1); - ret =3D 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); } =20 /* Fold -0.0 for comparison with COND. */ @@ -533,7 +526,7 @@ static DisasJumpType gen_fbcond(DisasContext *ctx, TCGC= ond cond, int ra, DisasJumpType ret; =20 gen_fold_mzero(cond, cmp_tmp, load_fpr(ctx, ra)); - ret =3D gen_bcond_internal(ctx, cond, cmp_tmp, disp); + ret =3D gen_bcond_internal(ctx, cond, cmp_tmp, 0, disp); return ret; } =20 --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926754; cv=none; d=zohomail.com; s=zohoarc; b=JzlXkPn/oBFHdQU38Ce9eZKsc8yiH02ew1PP30iH3uVrxdUhITyDSTmuTAkSIchKSQdjeCG3AoT0jzZUIqwFpWbc8uvwZxxOYFcbBOMj75MQnhuHIZwS2Duw3Zr9okTiNGaupBXN2mr8w7C8x1m+x7PJ9j9k0yv5Pca17bNMbxk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926754; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iq7I5R53pVNdI93EJRMub3T9kBHS1RS5Ymgrbh0dENY=; b=Qfzj4fHpKzeqW118G0iNqY6VHDVUeoG/wVhBVWoJXrf5Ru/UyyqnFYdBRBomQJuV74q5hnBr97/GobU3fwG0UNI+iFczfuy3W14CtMZTOw3tFG17Ulk2JUATFsWfQvk3DUB073XVcBbQQbs9baOyM7yI9q9CHa3MC1/LkAVkWg0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926754179109.54806765167166; Wed, 10 Jan 2024 14:45:54 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IGhztKYVqkBD6b0OGFu6QWkGu1Ht4Wc/aQyMwFBGjS9+QwkQQDtbJpPuT0Gl6jdhPfxwW1/sg== 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926754985100001 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=C3=A9 Message-Id: <20231108205247.83234-2-philmd@linaro.org> Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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, } =20 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); } =20 /* Fold -0.0 for comparison with COND. */ @@ -2820,35 +2820,35 @@ static DisasJumpType translate_one(DisasContext *ct= x, uint32_t insn) break; case 0x38: /* BLBC */ - ret =3D gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 1); + ret =3D gen_bcond(ctx, TCG_COND_TSTEQ, ra, disp21); break; case 0x39: /* BEQ */ - ret =3D gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 0); + ret =3D gen_bcond(ctx, TCG_COND_EQ, ra, disp21); break; case 0x3A: /* BLT */ - ret =3D gen_bcond(ctx, TCG_COND_LT, ra, disp21, 0); + ret =3D gen_bcond(ctx, TCG_COND_LT, ra, disp21); break; case 0x3B: /* BLE */ - ret =3D gen_bcond(ctx, TCG_COND_LE, ra, disp21, 0); + ret =3D gen_bcond(ctx, TCG_COND_LE, ra, disp21); break; case 0x3C: /* BLBS */ - ret =3D gen_bcond(ctx, TCG_COND_NE, ra, disp21, 1); + ret =3D gen_bcond(ctx, TCG_COND_TSTNE, ra, disp21); break; case 0x3D: /* BNE */ - ret =3D gen_bcond(ctx, TCG_COND_NE, ra, disp21, 0); + ret =3D gen_bcond(ctx, TCG_COND_NE, ra, disp21); break; case 0x3E: /* BGE */ - ret =3D gen_bcond(ctx, TCG_COND_GE, ra, disp21, 0); + ret =3D gen_bcond(ctx, TCG_COND_GE, ra, disp21); break; case 0x3F: /* BGT */ - ret =3D gen_bcond(ctx, TCG_COND_GT, ra, disp21, 0); + ret =3D gen_bcond(ctx, TCG_COND_GT, ra, disp21); break; invalid_opc: ret =3D gen_invalid(ctx); --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926766414407.9818818872466; Wed, 10 Jan 2024 14:46:06 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IFV9WQHgoNkQ1Xp5ZUPImEgO3ZA93PxxBoVNEqXdeW7hVyrqKdK8CXGHZj+p2XVX/OIK6M8tg== 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1704926766982100001 Reviewed-by: Philippe Mathieu-Daud=C3=A9 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 *ct= x, uint32_t insn) break; case 0x14: /* CMOVLBS */ - tmp =3D 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 =3D 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: --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926813; cv=none; d=zohomail.com; s=zohoarc; b=VUXwKzKu0pspZy9BvbBodpJqx9GaVnO+rwtQiHUtx4dmKqqRqqWJKp7XxB647TDc9wqsy63lTnwTUDdp26JeAKd/m/jj7YmhXgGjBEOOOAceNHhjXtWEXWxM5VDUDfmsmnnEIL89pP9FECYwG7Lg+CutnUfALtZgvAzdS7QnRM0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926813; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/Mi02s/8pPhslq92YCDg9owTXJVUIjB51aqomHFCjPA=; b=G3AEcGbDL/czayFw6tYm3P9sVdn2bzmduVYRyTAm4wbwACTcSVkwBkc5ZRBJkm2wZ4U+rE6LBfzJU/eY2LSisvY6EACI/O7SJbeu/7SH6N+zb4IwJoZ9VUWnW4Z13HqkliSgV/nKEBYclIlYsdooOZ4gEom/rwlkQGbbtKxwS0Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926813202512.6355729908433; Wed, 10 Jan 2024 14:46:53 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IGKypzb+F1Ao0IiRN76RS4P8UOOH42hixf+LFKc8wtWQ9lIowdjVCeZ6UdsHUgefUA9nldHtQ== 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926815191100003 Reviewed-by: Philippe Mathieu-Daud=C3=A9 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, TCG= Cond cond, int ra, =20 /* Fold -0.0 for comparison with COND. */ =20 -static void gen_fold_mzero(TCGCond cond, TCGv dest, TCGv src) +static TCGv_i64 gen_fold_mzero(TCGCond *pcond, uint64_t *pimm, TCGv_i64 sr= c) { - uint64_t mzero =3D 1ull << 63; + TCGv_i64 tmp; =20 - switch (cond) { + *pimm =3D 0; + switch (*pcond) { case TCG_COND_LE: case TCG_COND_GT: /* For <=3D or >, the -0.0 value directly compares the way we want= . */ - tcg_gen_mov_i64(dest, src); - break; + return src; =20 case TCG_COND_EQ: case TCG_COND_NE: - /* For =3D=3D or !=3D, we can simply mask off the sign bit and com= pare. */ - tcg_gen_andi_i64(dest, src, mzero - 1); - break; + /* For =3D=3D or !=3D, we can compare without the sign bit. */ + *pcond =3D *pcond =3D=3D TCG_COND_EQ ? TCG_COND_TSTEQ : TCG_COND_T= STNE; + *pimm =3D INT64_MAX; + return src; =20 case TCG_COND_GE: case TCG_COND_LT: /* For >=3D 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 =3D 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; =20 default: - abort(); + g_assert_not_reached(); } } =20 static DisasJumpType gen_fbcond(DisasContext *ctx, TCGCond cond, int ra, int32_t disp) { - TCGv cmp_tmp =3D tcg_temp_new(); - DisasJumpType ret; - - gen_fold_mzero(cond, cmp_tmp, load_fpr(ctx, ra)); - ret =3D gen_bcond_internal(ctx, cond, cmp_tmp, 0, disp); - return ret; + uint64_t imm; + TCGv_i64 tmp =3D gen_fold_mzero(&cond, &imm, load_fpr(ctx, ra)); + return gen_bcond_internal(ctx, cond, tmp, imm, disp); } =20 static void gen_fcmov(DisasContext *ctx, TCGCond cond, int ra, int rb, int= rc) { - TCGv_i64 va, vb, z; - - z =3D load_zero(ctx); - vb =3D load_fpr(ctx, rb); - va =3D 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 =3D 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)); } =20 #define QUAL_RM_N 0x080 /* Round mode nearest even */ --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926852956384.4063390533952; Wed, 10 Jan 2024 14:47:32 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IHB6gR9wBZgANJS2AkLuy0ivK0VotvH6u00D3nIt/KSIcMjpougzwBv2Eun1mTKWb2POyVzvA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1704926853403100020 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 =3D 0; =20 - c->v2 =3D tcg_constant_i32(0); /* TODO: Raise BSUN exception. */ fpsr =3D tcg_temp_new(); gen_load_fcr(s, fpsr, M68K_FPSR); + c->v1 =3D fpsr; + switch (cond) { case 0: /* False */ case 16: /* Signaling False */ - c->v1 =3D c->v2; c->tcond =3D TCG_COND_NEVER; break; case 1: /* EQual Z */ case 17: /* Signaling EQual Z */ - c->v1 =3D tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_Z); - c->tcond =3D TCG_COND_NE; + imm =3D FPSR_CC_Z; + c->tcond =3D TCG_COND_TSTNE; break; case 2: /* Ordered Greater Than !(A || Z || N) */ case 18: /* Greater Than !(A || Z || N) */ - c->v1 =3D tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, - FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N); - c->tcond =3D TCG_COND_EQ; + imm =3D FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N; + c->tcond =3D 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 =3D 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 =3D TCG_COND_NE; + imm =3D FPSR_CC_Z | FPSR_CC_N; + c->tcond =3D TCG_COND_TSTNE; break; case 4: /* Ordered Less Than !(!N || A || Z); */ case 20: /* Less Than !(!N || A || Z); */ c->v1 =3D 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 =3D TCG_COND_EQ; + imm =3D FPSR_CC_N | FPSR_CC_A | FPSR_CC_Z; + c->tcond =3D 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, DisasCont= ext *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 =3D TCG_COND_NE; + imm =3D FPSR_CC_Z | FPSR_CC_N; + c->tcond =3D TCG_COND_TSTNE; break; case 6: /* Ordered Greater or Less than !(A || Z) */ case 22: /* Greater or Less than !(A || Z) */ - c->v1 =3D tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A | FPSR_CC_Z); - c->tcond =3D TCG_COND_EQ; + imm =3D FPSR_CC_A | FPSR_CC_Z; + c->tcond =3D TCG_COND_TSTEQ; break; case 7: /* Ordered !A */ case 23: /* Greater, Less or Equal !A */ - c->v1 =3D tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A); - c->tcond =3D TCG_COND_EQ; + imm =3D FPSR_CC_A; + c->tcond =3D TCG_COND_TSTEQ; break; case 8: /* Unordered A */ case 24: /* Not Greater, Less or Equal A */ - c->v1 =3D tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A); - c->tcond =3D TCG_COND_NE; + imm =3D FPSR_CC_A; + c->tcond =3D TCG_COND_TSTNE; break; case 9: /* Unordered or Equal A || Z */ case 25: /* Not Greater or Less then A || Z */ - c->v1 =3D tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A | FPSR_CC_Z); - c->tcond =3D TCG_COND_NE; + imm =3D FPSR_CC_A | FPSR_CC_Z; + c->tcond =3D TCG_COND_TSTNE; break; case 10: /* Unordered or Greater Than A || !(N || Z)) */ case 26: /* Not Less or Equal A || !(N || Z)) */ c->v1 =3D 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 =3D TCG_COND_NE; + imm =3D FPSR_CC_A | FPSR_CC_N; + c->tcond =3D TCG_COND_TSTNE; break; case 11: /* Unordered or Greater or Equal A || Z || !N */ case 27: /* Not Less Than A || Z || !N */ c->v1 =3D 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 =3D TCG_COND_NE; + tcg_gen_xori_i32(c->v1, fpsr, FPSR_CC_N); + imm =3D FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N; + c->tcond =3D 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, DisasCont= ext *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 =3D TCG_COND_NE; + imm =3D FPSR_CC_A | FPSR_CC_N; + c->tcond =3D TCG_COND_TSTNE; break; case 13: /* Unordered or Less or Equal A || Z || N */ case 29: /* Not Greater Than A || Z || N */ - c->v1 =3D tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N); - c->tcond =3D TCG_COND_NE; + imm =3D FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N; + c->tcond =3D TCG_COND_TSTNE; break; case 14: /* Not Equal !Z */ case 30: /* Signaling Not Equal !Z */ - c->v1 =3D tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_Z); - c->tcond =3D TCG_COND_EQ; + imm =3D FPSR_CC_Z; + c->tcond =3D TCG_COND_TSTEQ; break; case 15: /* True */ case 31: /* Signaling True */ - c->v1 =3D c->v2; c->tcond =3D TCG_COND_ALWAYS; break; } + c->v2 =3D tcg_constant_i32(imm); } =20 static void gen_fjmpcc(DisasContext *s, int cond, TCGLabel *l1) --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926781; cv=none; d=zohomail.com; s=zohoarc; b=VASXfV9wB2JzSrsh/5kXdMt5wR+AlNbC0tBi9iNoKXXVG1PFaokFq7ERM31B9UI6U/X2X7CxzItwRLkteAG13jinPNo/C2Kfsth2IMW2Rdsl+FUbx0C7ckKinRISAgPLn6L+BrlIl+ON2AWsxGK8/ehLVZGy89pNh4y8CiAfIMM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926781; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wsZxMo/6G0y0rb+He/biAv9zUFttsowRzurXqIiQz9A=; b=abAYa2LaMwRqg8V0PTHqOtoty9uchWRggC8Mvtcd9LWHi8aKoEnuHeZUUQfDPkM5UrHLNEWj9endpGwF9SKPD6l0Z+NqJQJGXtxrPADvuWbL5tmpgHCjH+nbnqWOI7dW8+thOJPBHE6N0XdOEUIS+XclFlSfzyNCGtNjFDJfPBg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926780955124.5123579282847; Wed, 10 Jan 2024 14:46:20 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IFgmDx0rjLjdDJEA47a3KgqUj85sMkg6nUuP0fvuiPp34aIHKDnp5Lk5haX3gA2j0aGfGQKaA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926783061100005 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 src= 2) static void gen_op_mulscc(TCGv dst, TCGv src1, TCGv src2) { TCGv zero =3D tcg_constant_tl(0); + TCGv one =3D tcg_constant_tl(1); TCGv t_src1 =3D tcg_temp_new(); TCGv t_src2 =3D tcg_temp_new(); TCGv t0 =3D tcg_temp_new(); @@ -517,8 +518,7 @@ static void gen_op_mulscc(TCGv dst, TCGv src1, TCGv src= 2) * if (!(env->y & 1)) * src2 =3D 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); =20 /* * b2 =3D src1 & 1; --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926914; cv=none; d=zohomail.com; s=zohoarc; b=fG6en/uw08CGgXxjzIVl7WK0yIyC1llyuzzB3w1kSSxnOK+J9SfL49BpksFTk2fiUatd1tvSq2xr35sDZkBcBO4hb8dcMNaKagc/ffBUBZ+wkdpUEKXm6/nqTjsArXj4yRPtfyu8PxpRGFZQntg0RBh0s+JfyvlibcFUYBE4pzo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926914; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GS3d6Cpw6XkPNpi2NrfgOHaZo+XrWfNCNBnXScIVqj4=; b=iTcd8OdrB26HevDPiw5wtXAU+4qdZ85/UlgZQ1BEwuHzL1MNXimQYTCFqwR9lZYxEqKVF7XcZu4I2g6pQ60PeWdLE2G0E7WWQZQ7qKwaUnUMjJhcP8yQJgNSQl/VLe8s3ZiyEF77URMBCve6kWjpPiRwsZShvEN4mwbEAHngwqI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926914187851.3191126061608; Wed, 10 Jan 2024 14:48:34 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IFUPLhjOVNjtD+Jl2a+1SNTt63cDl0xmFHjrWu+S2KYxv6bhbYv/GkTgtd6QF0hdUVnCjEcDA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926915662100001 Content-Type: text/plain; charset="utf-8" These are all test-and-compare type instructions. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 =3D TCG_COND_EQ; + cond =3D TCG_COND_TSTEQ; break; case 4 | 2 | 1: - cond =3D TCG_COND_NE; + cond =3D 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 =3D TCG_COND_EQ; + cond =3D TCG_COND_TSTEQ; break; case 4 | 2 | 1: case 4 | 2: - cond =3D TCG_COND_NE; + cond =3D 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 =3D cc_dst; c->u.s64.b =3D tcg_constant_i64(0); break; + case CC_OP_LTGT_64: case CC_OP_LTUGTU_64: - c->u.s64.a =3D cc_src; - c->u.s64.b =3D cc_dst; - break; - case CC_OP_TM_32: case CC_OP_TM_64: case CC_OP_ICM: - c->u.s64.a =3D tcg_temp_new_i64(); - c->u.s64.b =3D tcg_constant_i64(0); - tcg_gen_and_i64(c->u.s64.a, cc_src, cc_dst); + c->u.s64.a =3D cc_src; + c->u.s64.b =3D cc_dst; break; =20 case CC_OP_ADDU: --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926845; cv=none; d=zohomail.com; s=zohoarc; b=cnAA+5V1367UBgyr4LzQ1TYxnS/je3O1gOUUobhximMEqYhHR0xY3y8tukUm+vbmLuHHP9siXzyOSx4hYEafo72BmK57BV6mgkQbuV6UQz8q/NL3zJdpNlfdGzT+8u2AW3IhR7BSBlN/9KKSpiSHtjzNnl32bdJf3rqEPSSc6qA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926845; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=W1dg8xzeToyJ1noTdWjMrmUW84nILSKxoDBHRkIKi/4=; b=L866dYZl0oNtkUw8F5FR0zN0bbCDHqeb7Dt+AtQiBbBetbLeIV8F2wYtEYK8NdI3X1qt9Qj4vBFH/qwJzefqxhRuf8VTOEOAJGmWJXF1NCAvbpeKA1zxID9bC+IgXks3wnHYRMD9Gl+x1hcvwDMewiRtocxh3SxfkKl01mweR7I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170492684565317.198242581674094; Wed, 10 Jan 2024 14:47:25 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IFYTwBsEGrih3iTjWB3lV2/oHOrwf/C6MgB8qHVMNZBCZvMYNNNh9kHGaG8lAhGyBGgxxRabA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926847332100001 Content-Type: text/plain; charset="utf-8" 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) <=3D 1 for cc in {1,2}. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 =3D false; c->u.s32.a =3D cc_op; - switch (mask) { - case 0x8 | 0x4 | 0x2: /* cc !=3D 3 */ - cond =3D TCG_COND_NE; + + /* Fold half of the cases using bit 3 to invert. */ + switch (mask & 8 ? mask ^ 0xf : mask) { + case 0x1: /* cc =3D=3D 3 */ + cond =3D TCG_COND_EQ; c->u.s32.b =3D tcg_constant_i32(3); break; - case 0x8 | 0x4 | 0x1: /* cc !=3D 2 */ - cond =3D TCG_COND_NE; - c->u.s32.b =3D tcg_constant_i32(2); - break; - case 0x8 | 0x2 | 0x1: /* cc !=3D 1 */ - cond =3D TCG_COND_NE; - c->u.s32.b =3D tcg_constant_i32(1); - break; - case 0x8 | 0x2: /* cc =3D=3D 0 || cc =3D=3D 2 =3D> (cc & 1) =3D=3D= 0 */ - cond =3D TCG_COND_EQ; - c->u.s32.a =3D tcg_temp_new_i32(); - c->u.s32.b =3D tcg_constant_i32(0); - tcg_gen_andi_i32(c->u.s32.a, cc_op, 1); - break; - case 0x8 | 0x4: /* cc < 2 */ - cond =3D TCG_COND_LTU; - c->u.s32.b =3D tcg_constant_i32(2); - break; - case 0x8: /* cc =3D=3D 0 */ - cond =3D TCG_COND_EQ; - c->u.s32.b =3D tcg_constant_i32(0); - break; - case 0x4 | 0x2 | 0x1: /* cc !=3D 0 */ - cond =3D TCG_COND_NE; - c->u.s32.b =3D tcg_constant_i32(0); - break; - case 0x4 | 0x1: /* cc =3D=3D 1 || cc =3D=3D 3 =3D> (cc & 1) !=3D 0= */ - cond =3D TCG_COND_NE; - c->u.s32.a =3D tcg_temp_new_i32(); - c->u.s32.b =3D tcg_constant_i32(0); - tcg_gen_andi_i32(c->u.s32.a, cc_op, 1); - break; - case 0x4: /* cc =3D=3D 1 */ - cond =3D TCG_COND_EQ; - c->u.s32.b =3D tcg_constant_i32(1); - break; - case 0x2 | 0x1: /* cc > 1 */ - cond =3D TCG_COND_GTU; - c->u.s32.b =3D tcg_constant_i32(1); - break; case 0x2: /* cc =3D=3D 2 */ cond =3D TCG_COND_EQ; c->u.s32.b =3D tcg_constant_i32(2); break; - case 0x1: /* cc =3D=3D 3 */ + case 0x4: /* cc =3D=3D 1 */ cond =3D TCG_COND_EQ; - c->u.s32.b =3D tcg_constant_i32(3); + c->u.s32.b =3D tcg_constant_i32(1); + break; + case 0x2 | 0x1: /* cc =3D=3D 2 || cc =3D=3D 3 =3D> cc > 1 */ + cond =3D TCG_COND_GTU; + c->u.s32.b =3D tcg_constant_i32(1); + break; + case 0x4 | 0x1: /* cc =3D=3D 1 || cc =3D=3D 3 =3D> (cc & 1) !=3D 0= */ + cond =3D TCG_COND_TSTNE; + c->u.s32.b =3D tcg_constant_i32(1); + break; + case 0x4 | 0x2: /* cc =3D=3D 1 || cc =3D=3D 2 =3D> (cc - 1) <=3D 1= */ + cond =3D TCG_COND_LEU; + c->u.s32.a =3D tcg_temp_new_i32(); + c->u.s32.b =3D tcg_constant_i32(1); + tcg_gen_addi_i32(c->u.s32.a, cc_op, -1); + break; + case 0x4 | 0x2 | 0x1: /* cc !=3D 0 */ + cond =3D TCG_COND_NE; + c->u.s32.b =3D tcg_constant_i32(0); break; default: - /* CC is masked by something else: (8 >> cc) & mask. */ - cond =3D TCG_COND_NE; - c->u.s32.a =3D tcg_temp_new_i32(); - c->u.s32.b =3D 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 =3D tcg_invert_cond(cond); } break; =20 --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926849; cv=none; d=zohomail.com; s=zohoarc; b=lCtJtruY/NOPkcgeL/R2xIuYtrym6lKu0ZnWbKOkym4WfZkHo9ZkCX9Lql7VcS64Z2jAxTwmFa+4ExjUz4ZWm+uWu7rpIg4pK4u5bi2MTCBw4UJhjFsaFQBMzb6zDn0iBD6R+08oNM+f+OviFWhe8t4E8fHPhkpAYFMSomJcCd4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926849; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Yt1amn66GV+70TUwg6QhzJ4YUnpX4UUEzHPNr30u2sg=; b=BsBwTfN/PTquLfyu/rCtxyPtCazrhHaO6GoRMQKll9CAMY+HLxKpp7N5ztxnXt4PEqEE9UvQhybwUY3YUDog5Q/ArpkSqhjFDC3ajU1R8MRlSFAysxAGWEqMgh24/jfWouFSTRExVhq4+ScN7M4fdk0Enr3WDCzl1r6ZeEztFvw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926849666940.4910190962219; Wed, 10 Jan 2024 14:47:29 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IGcOnVPuHupy2QbjUIjkNN0J26tp03wNPvRyYUilChN5bDxLraKKAE97bsj4KanX/qKx7p4aA== 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926851420100013 Fill the new argument from any condition within the opcode. Not yet used within any backend. Reviewed-by: Philippe Mathieu-Daud=C3=A9 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, TC= GArg 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 TCG= Op *op) TCGTemp *ts; TCGArg new_args[TCG_MAX_OP_ARGS]; int const_args[TCG_MAX_OP_ARGS]; + TCGCond op_cond; =20 nb_oargs =3D def->nb_oargs; nb_iargs =3D def->nb_iargs; @@ -4798,6 +4800,33 @@ static void tcg_reg_alloc_op(TCGContext *s, const TC= GOp *op) i_allocated_regs =3D s->reserved_regs; o_allocated_regs =3D s->reserved_regs; =20 + switch (op->opc) { + case INDEX_op_brcond_i32: + case INDEX_op_brcond_i64: + op_cond =3D 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 =3D op->args[3]; + break; + case INDEX_op_brcond2_i32: + op_cond =3D 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 =3D op->args[5]; + break; + default: + /* No condition within opcode. */ + op_cond =3D TCG_COND_ALWAYS; + break; + } + /* satisfy input constraints */ for (k =3D 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 TCG= Op *op) ts =3D arg_temp(arg); =20 if (ts->val_type =3D=3D 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] =3D 1; new_args[i] =3D 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) } } =20 -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 ty= pe, } =20 /* 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 v= al, int pos, int len) } =20 /* 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) } =20 /* 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) } =20 /* 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(TCGCallReturnKin= d kind, int slot) #define sextreg sextract64 =20 /* 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) } =20 /* 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, } =20 /* 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 t= ype, TCGArg val, } =20 /* 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; } --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926940; cv=none; d=zohomail.com; s=zohoarc; b=EacCrzMSmXbOPoDjwtFQwtvsDwMFuUxj6+KpniESKT2w9AbBzyGQoXcuv8dU3+laEm/OhSXFbB7dXieYG+i3htkhymFiaHBQQuZpEQSBc5XIc1E0oDaWcSFq9kBEPGOX+FBXjUwS9YCMRqtTj2Xzt8tf7p7fbxFJBdw6nSRa8pE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926940; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=07WcNRuELUJbpEJ/6K8AoY3Jv+ERO1K9CGzKIf1CLoc=; b=Ll5d8kgP5VwXnAvwiQciJFu1oOcu1ECu3bYx7U8hA5a40pLW9uTrKtVvmxI7Bp6Nip4S/0RyavQGmw0PM6JhkGjpW2TcjrDaZ/eBtGv/cFgttFu2x+VfwnLhUedYp5WChKovPRm4imEagU6k3JkjKUrYyVPNLy/jS2mdhCqxCZU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926940706283.97545623748056; Wed, 10 Jan 2024 14:49:00 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IG4C2zLaVmtwBq8A+zM0UPWT1K1tked8apU7WyYNtBq5HhmGDU4rW0/LpZaqkiPuPIPwXHICQ== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926941735100006 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 =20 -#define TCG_TARGET_HAS_tst 0 +#define TCG_TARGET_HAS_tst 1 =20 #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 ty= pe, #define TCG_CT_CONST_MONE 0x800 #define TCG_CT_CONST_ORRI 0x1000 #define TCG_CT_CONST_ANDI 0x2000 +#define TCG_CT_CONST_CMP 0x4000 =20 #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 =3D=3D TCG_TYPE_I32) { val =3D (int32_t)val; } + + if (ct & TCG_CT_CONST_CMP) { + if (is_tst_cond(cond)) { + ct |=3D TCG_CT_CONST_LIMM; + } else { + ct |=3D 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= [] =3D { [TCG_COND_GTU] =3D COND_HI, [TCG_COND_GEU] =3D COND_HS, [TCG_COND_LEU] =3D COND_LS, + /* bit test */ + [TCG_COND_TSTEQ] =3D COND_EQ, + [TCG_COND_TSTNE] =3D COND_NE, }; =20 typedef enum { @@ -1342,19 +1355,26 @@ static inline void tcg_out_dep(TCGContext *s, TCGTy= pe ext, TCGReg rd, tcg_out_bfm(s, ext, rd, rn, a, b); } =20 -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 >=3D 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 >=3D 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); + } } } =20 @@ -1402,7 +1422,7 @@ static void tcg_out_brcond(TCGContext *s, TCGType ext= , TCGCond c, TCGArg a, need_cmp =3D false; } else { need_cmp =3D true; - tcg_out_cmp(s, ext, a, b, b_const); + tcg_out_cmp(s, ext, c, a, b, b_const); } =20 if (!l->has_value) { @@ -1575,7 +1595,7 @@ static void tcg_out_cltz(TCGContext *s, TCGType ext, = TCGReg d, } else { AArch64Insn sel =3D I3506_CSEL; =20 - 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); =20 if (const_b) { @@ -1720,7 +1740,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext= *s, HostAddress *h, addr_adj, compare_mask); =20 /* 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); =20 /* If not equal, we jump to the slow path. */ ldst->label_ptr[0] =3D s->code_ptr; @@ -2276,7 +2296,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, a2 =3D (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 =3D (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 =3D (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; =20 @@ -2896,11 +2916,13 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGO= pcode 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); =20 case INDEX_op_mul_i32: case INDEX_op_mul_i64: @@ -2950,11 +2972,11 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGO= pcode op) =20 case INDEX_op_brcond_i32: case INDEX_op_brcond_i64: - return C_O0_I2(r, rA); + return C_O0_I2(r, rC); =20 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); =20 case INDEX_op_qemu_ld_a32_i32: case INDEX_op_qemu_ld_a64_i32: --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926931; cv=none; d=zohomail.com; s=zohoarc; b=Y7uZJ0aVa8fGVXBy/Zo5m8grA9TjcDmR89vOGg9SwCX5NEmaYvquodEmlUTUhqs1NBelX+xJ/e3uwMxWD1V/9T4O3c2+2mRnX1krurcx6dNZkVjs2K4Bwd5efeSG+p3smv1LdylPjabkHJM8+XNLAhqoOIsy9FtYu+2+fGUy3tw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926931; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=h+gt0CjYg4HfuULsURoNWzr2njchZ3xEe5eZdBzd0U4=; b=QcOaGHPyzarZ4sIFYDjGjpOvoLHeeaN8uhYWUrArvnB2+sxMuunnPTL5+3cLvgoNrb0y5nWxvNftbregMt1Zi4BXmuoaS0SQ53ftQNEIdUOMls9RlRStP8TH99ZvmXTbqkyvuVxemcjN8A8CFj5tIoBAe8MUEqvAuPM5VxsRqtQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926931437575.9587847221226; Wed, 10 Jan 2024 14:48:51 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IEf5YSlTgRfaVYYubS225sE9f5PCRVQkXjNHRmmm6er68u4ThHJn1Bt4E16iouW72MEhGYtpw== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926931745100001 Content-Type: text/plain; charset="utf-8" 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 tc= g_insn_unit *target) return false; } =20 +static bool reloc_pc14(tcg_insn_unit *src_rw, const tcg_insn_unit *target) +{ + const tcg_insn_unit *src_rx =3D tcg_splitwx_to_rx(src_rw); + ptrdiff_t offset =3D target - src_rx; + + if (offset =3D=3D sextract64(offset, 0, 14)) { + *src_rw =3D 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 ty= pe, 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 =3D 0x54000000, =20 + /* Test and branch (immediate). */ + I3205_TBZ =3D 0x36000000, + I3205_TBNZ =3D 0x37000000, + /* Unconditional branch (immediate). */ I3206_B =3D 0x14000000, I3206_BL =3D 0x94000000, @@ -660,6 +678,14 @@ static void tcg_out_insn_3202(TCGContext *s, AArch64In= sn insn, tcg_out32(s, insn | tcg_cond_to_aarch64[c] | (imm19 & 0x7ffff) << 5); } =20 +static void tcg_out_insn_3205(TCGContext *s, AArch64Insn insn, + TCGReg rt, int imm6, int imm14) +{ + insn |=3D (imm6 & 0x20) << (31 - 5); + insn |=3D (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 =3D -1; + bool need_cmp =3D true; =20 - if (b_const && b =3D=3D 0 && (c =3D=3D TCG_COND_EQ || c =3D=3D TCG_CON= D_NE)) { - need_cmp =3D false; - } else { - need_cmp =3D 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 =3D tcg_in32(s) >> 5; - } else { - offset =3D tcg_pcrel_diff(s, l->u.value_ptr) >> 2; - tcg_debug_assert(offset =3D=3D sextract64(offset, 0, 19)); + switch (c) { + case TCG_COND_EQ: + case TCG_COND_NE: + if (b_const && b =3D=3D 0) { + need_cmp =3D false; + } + break; + case TCG_COND_LT: + case TCG_COND_GE: + if (b_const && b =3D=3D 0) { + c =3D (c =3D=3D TCG_COND_LT ? TCG_COND_TSTNE : TCG_COND_TSTEQ); + tbit =3D ext ? 63 : 31; + need_cmp =3D false; + } + break; + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + if (b_const && is_power_of_2(b)) { + tbit =3D ctz64(b); + need_cmp =3D false; + } + break; + default: + break; } =20 if (need_cmp) { - tcg_out_insn(s, 3202, B_C, c, offset); - } else if (c =3D=3D 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 >=3D 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(); + } } } =20 --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926869; cv=none; d=zohomail.com; s=zohoarc; b=Yn3RtqIIK8BBBEqJ9RjCI1iuzX2ELelnuAS0YX6Xp8n1TmRDkCq6IE/ZqUPtB+Tso3rJnORUH2ZvR6lt57ommP3SjsS7KNvTKVO5iPnC93LmLK693o6SK7OtUTbiw0EYXg0ZPkkCCOY7nHAY9fie0KAJittRb08jk1voH5jHBks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926869; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9zCJMFAqdf2iFGNb4zrA/FuyIMECuUh8qss+ekAKVh8=; b=M6rZNpu69Bxg/qLaIuWFvRGS9fdxsjIel/SeFi9gaozS0VEZAfsao6I7QS3u9klSn6B/sFOGXhg87kOlRqpemDQlt/4RhfsOd7pQe75HpD2mvbie3Zl5DeQGd5mMlU09ZbUohCWQe6ZjT5g9u6Rbcv8cVDAeF9V71Wb+sFPXDNs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926869441330.06058793922375; Wed, 10 Jan 2024 14:47:49 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IEawBiEdaZMeqifTfwxd9JRAqgEDGRhJ8DdtGW3ehTqW3C0gCdPEMvAkrVtU+axa4DRCcXq3A== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926871467100007 Content-Type: text/plain; charset="utf-8" ... and the inverse, CBZ for TSTEQ. Suggested-by: Paolo Bonzini Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 =3D=3D 0) { c =3D (c =3D=3D TCG_COND_LT ? TCG_COND_TSTNE : TCG_COND_TSTEQ); tbit =3D ext ? 63 : 31; @@ -1461,6 +1462,13 @@ static void tcg_out_brcond(TCGContext *s, TCGType ex= t, 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 =3D=3D UINT32_MAX) { + ext =3D TCG_TYPE_I32; + need_cmp =3D false; + break; + } + /* tst xN,1< tbnz xN,B,L */ if (b_const && is_power_of_2(b)) { tbit =3D ctz64(b); need_cmp =3D false; --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926938; cv=none; d=zohomail.com; s=zohoarc; b=dOr1d0VGl0Ds2xHP2X7OtHJVF02dh9ucG5fTR005QIcKxo+yvbYoAtxLiuhswZaZZ64fLGWi89tPcIYcv5udSef26U7ePkzoB4F04DQ0TcJtMOWF6aYlouFZUUUbcaUWNBMJ5f5jCrUGQaO2m1X05vEM3HkUScQQSLl6Kqtc3hA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926938; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=rBO9h8KMQ8hfOsqhiuTiqmSfaBXd3OkUHNoQ5JH+g9M=; b=kBxlxdOU6yuTmFyoMeqfLR8VWpOOFtt3fejIxtGzWkHKv4sxJHudfS+Dpp/bVRN8vB56esE6Axyzr9e2A4CYDxuw9x3lp30Doj1bXQNL/WTU1AsLNxaLgenBMp7zG+wx5h9u45eIy5HBFCnhspOj5q/+vAHHJL+jjb089/ykyIA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926938391483.33085514480774; Wed, 10 Jan 2024 14:48:58 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IH9BPPU92JRo6PqUm9PVtmswfRd1kFdSemyS59JeqQ3JObf4eQSECbWp6L+1F7jcXgKIblB1Q== 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926939775100001 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=C3=A9 Message-Id: <20231108145244.72421-1-philmd@linaro.org> Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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) } } =20 +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 =3D 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; =20 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 =3D 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 =3D 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 =3D 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; =20 --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926827; cv=none; d=zohomail.com; s=zohoarc; b=kRvgeWEW1kSXPUxxEo6+XnCK1iJ/CBvyXOcnwPrldAen4Eg2xcjzfkjxCUh55i9ny5Jr6z0UU1PCTRbbQU9U0t9zDBF0Vu8fsDxgFk02mIwglVuTQVa74VEyo5BorO4+LKkp5k1HckGbOlxwusvnxIc/dm3SKoU9qaUSOmTrLoo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926827; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PVv83mbHx+ti5Iw4ZVcFle0NjlrRtL0PCWiz47WVlUo=; b=mH1Kp19WEyL9JuDgOmKRWwvnBM88MAUj4DSMMmCbB+NoUEBvjxuK/FKxlL8TBRtImf4szUV9e8xnStCCmpXi2qqjWLt90NFMQnQQkpqx3zezdShpcKZ4vqohqpkNKh4EE4YvB3tUOSM3TjVxQNGUn9HBIin0wY7DX106cxMaaC8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926827800940.5317050913799; Wed, 10 Jan 2024 14:47:07 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IFUDgFzSjjiP4iCZPJVtRwhOIvPNZerJwuBqnRarXLOgBcPtnav3+2k8h8J4S03ucLEG64CBQ== 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926829222100001 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=C3=A9 Message-Id: <20231108145244.72421-2-philmd@linaro.org> Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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; =20 #define TCG_TARGET_HAS_qemu_ldst_i128 0 =20 -#define TCG_TARGET_HAS_tst 0 +#define TCG_TARGET_HAS_tst 1 =20 #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 =3D tcg_tst_eqne_cond(cond); + if (b_const) { + int imm12 =3D 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 >=3D 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 =3D TCG_REG_TMP; + } + tcg_out_dat_reg(s, COND_AL, ARITH_TST, 0, a, b, SHIFT_IMM_LSL(0)); return cond; } =20 @@ -1225,6 +1245,13 @@ static TCGCond tcg_out_cmp2(TCGContext *s, const TCG= Arg *args, tcg_out_dat_rI(s, COND_EQ, ARITH_CMP, 0, al, bl, const_bl); return cond; =20 + 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. --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926847; cv=none; d=zohomail.com; s=zohoarc; b=E5BCuqajV5oqVMBD6K1jsg55PauC5emqF8/94fdCFIpDj2NwBV4HM0G2Bold+H9/cF9vcgfINX00XsVH6b+TJ4Lwlvsytogbx+oe7DwqHA3oX+NJ6WuF+kWn26V/BSUAnfFk/876okiwjN0PGWnEsbDLAEmB8WtNQ2v2JII6qcM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926847; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hIn73/7L0/UvLzTpfBg1BsspTF3e93L6IUnQvuIa2EY=; b=PkIlGxMaLRoBHd2+q8UpSELytFVcU8GjqNKIEJzUeRwcioYDPRtClCWNU9GosdpgxfzJvvcMM+6oVPSJuQrQ31U9HJdYsjjRoRP+cMQa5inNXqVnmzFu0QlGvmIHkXoI7hNaYwB60EQlV/KwVo+xJnGEGzJkrUfyrUa/6l+MgjU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170492684795098.32554274663778; Wed, 10 Jan 2024 14:47:27 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IHHmeRFlmwYeKkEBykUNVSUDiRQ3CtjOcaZcqtGgr/IrQnBM+VLLX7aqWNmMIhHsv781bjbYg== 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926849540100008 Hoist the tcg_cond_to_jcc index outside the function. Reviewed-by: Philippe Mathieu-Daud=C3=A9 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 T= CGArg *args, } #endif =20 -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 =3D 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); } =20 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, TC= GReg dest, TCGReg arg1, tcg_debug_assert(arg2 =3D=3D (rexw ? 64 : 32)); } else { tcg_debug_assert(dest !=3D 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 !=3D 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); } } =20 @@ -1747,7 +1747,7 @@ static void tcg_out_clz(TCGContext *s, int rexw, TCGR= eg dest, TCGReg arg1, tcg_debug_assert(arg2 =3D=3D (rexw ? 64 : 32)); } else { tcg_debug_assert(dest !=3D 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, TCGR= eg dest, TCGReg arg1, =20 /* 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); } } =20 --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704927113; cv=none; d=zohomail.com; s=zohoarc; b=OjJaUEYz9C5DofkV9PbioZgIzBGZJRW7TYcHO6w5vHOFCpK4i1DuM+8ZxS19nxlUOf+l3MMGME8beiANQlyngDc9EJrCBT4JxLiLn14iMOx1iLWqBUo5MkO+b5FngIubtL0JXzdw/dmipjV8Q6fFGfIUBMEnf5Z+cVvFPN246xU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704927113; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SYMLLwA9gva4L4uzAlLYH7HUcuo07hrL8DJH/YZuBt8=; b=iNSwNAGfxUe2HDWpl7UoDvY5/0zSt/97zVfeY+OdKo6RCSFVtdeVGe7kcvoKMZ8t1SuTuAnBIjFD4tx9213Px+y3n2maNQAmNULsvLplyHgR7/Ehc0qv9aSj4dELzA7FUhMgAQlZM2adpj5Sa/TcLVs3ACJbKfkPosyoIQsUtI0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704927113745937.4478321735161; Wed, 10 Jan 2024 14:51:53 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IGXGXSdy7Yazwarzw4VXB1nvRak09TCqmOHHzh/rX43IGRN4vC0+yzAKWHVPw2I2lZXYjWX7Q== 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704927114232100003 Return the x86 condition codes to use after the compare. Reviewed-by: Philippe Mathieu-Daud=C3=A9 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, TCGLa= bel *l, bool small) } } =20 -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 =3D=3D 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]; } =20 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 =3D tcg_out_cmp(s, cond, arg1, arg2, const_arg2, rexw); + tcg_out_jxx(s, jcc, label, small); } =20 #if TCG_TARGET_REG_BITS =3D=3D 32 @@ -1561,6 +1562,7 @@ static void tcg_out_setcond(TCGContext *s, int rexw, = TCGCond cond, { bool inv =3D false; bool cleared; + int jcc; =20 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); =20 /* X - X - C =3D -C =3D (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 =3D true; } =20 - tcg_out_cmp(s, arg1, arg2, const_arg2, rexw); - tcg_out_modrm(s, OPC_SETCC | tcg_cond_to_jcc[cond], 0, dest); + jcc =3D tcg_out_cmp(s, cond, arg1, arg2, const_arg2, rexw); + tcg_out_modrm(s, OPC_SETCC | jcc, 0, dest); =20 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_c= 2, 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 =3D tcg_out_cmp(s, cond, c1, c2, const_c2, rexw); + tcg_out_cmov(s, jcc, rexw, dest, v1); } =20 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, TCGR= eg dest, TCGReg arg1, tgen_arithi(s, ARITH_XOR + rexw, dest, rexw ? 63 : 31, 0); =20 /* 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 =3D tcg_out_cmp(s, TCG_COND_EQ, arg1, 0, 1, rexw); + tcg_out_cmov(s, jcc, rexw, dest, arg2); } } =20 --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926945; cv=none; d=zohomail.com; s=zohoarc; b=B0/5OT1SN/kJ9RYGoM98kvqzhITMk9NbRuINgmSdeAKM0QpxIZOVdJP9njG04+8r1HjG1RlnLmGaD0zJ9QOASYHV/ro0OLkesP4SfoQlxHJ5ZOzQ2K0lkePFfJ0ZwPsmt7z5YJXfHVJ8oe6bGTGduHLFyOovQU94CC0iJeYax/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926945; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Od/xSXS8NstAz+sWZVmhj5MEuIknHRPAQGdZXQ5yceo=; b=n3MMX0o0yOZ0Z7KT6lN7r8lXIPLbiAaV516ifz0u7YaascBfNdcUiRxEk48QuKn8BfyWqhrqOLraqIToSsKqR1WEJMPLGsb28NaCJsjZmWQRmiWyO7ErhERzlRwkm+bLPOx5Phlo5v0nnDDSoQQfdIWy6PGKf3MGo2Q8Wu1IZsg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926945728113.44455220891598; Wed, 10 Jan 2024 14:49:05 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IEL4Lgwo/6EAQ8rWefp3ZCbaYjGri4CdDJo5Ghw7dToxVwodOVEVGm6DsAavAwencItxJutWw== 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926948108100001 Merge tcg_out_testi into tcg_out_cmp and adjust the two uses. Reviewed-by: Philippe Mathieu-Daud=C3=A9 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 =3D=3D 64 && (cpuinfo & CPUINFO_ATOMIC_VMOVDQA)) =20 -#define TCG_TARGET_HAS_tst 0 +#define TCG_TARGET_HAS_tst 1 =20 /* 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[] =3D { [TCG_COND_GEU] =3D JCC_JAE, [TCG_COND_LEU] =3D JCC_JBE, [TCG_COND_GTU] =3D JCC_JA, + [TCG_COND_TSTEQ] =3D JCC_JE, + [TCG_COND_TSTNE] =3D JCC_JNE, }; =20 #if TCG_TARGET_REG_BITS =3D=3D 64 @@ -1452,17 +1454,49 @@ static void tcg_out_jxx(TCGContext *s, int opc, TCG= Label *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 =3D=3D 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 =3D=3D 0) { tcg_out_modrm(s, OPC_TESTL + rexw, arg1, arg1); } else { + tcg_debug_assert(!rexw || arg2 =3D=3D (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 =3D tcg_cond_to_jcc[cond]; + + if (!const_arg2) { + tcg_out_modrm(s, OPC_TESTL + rexw, arg1, arg2); + return jz; + } + + if (arg2 <=3D 0xff && (TCG_TARGET_REG_BITS =3D=3D 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) =3D=3D 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 =3D=3D (uint32_t)arg2) { + rexw =3D 0; + } else { + tcg_debug_assert(arg2 =3D=3D (int32_t)arg2); + } + } + tcg_out_modrm(s, OPC_GRP3_Ev + rexw, EXT3_TESTi, arg1); + tcg_out32(s, arg2); + return jz; } =20 static void tcg_out_brcond(TCGContext *s, int rexw, TCGCond cond, @@ -1479,18 +1513,21 @@ static void tcg_out_brcond2(TCGContext *s, const TC= GArg *args, { TCGLabel *label_next =3D gen_new_label(); TCGLabel *label_this =3D arg_label(args[5]); + TCGCond cond =3D args[4]; =20 - 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); } =20 -/* 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 <=3D 0xff && (TCG_TARGET_REG_BITS =3D=3D 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(TCGConte= xt *s, HostAddress *h, tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_L0, TCG_REG_L0, offsetof(CPUTLBEntry, addend)); } else if (a_mask) { - ldst =3D new_ldst_label(s); + int jcc; =20 + ldst =3D new_ldst_label(s); ldst->is_ld =3D is_ld; ldst->oi =3D oi; ldst->addrlo_reg =3D addrlo; ldst->addrhi_reg =3D addrhi; =20 - tcg_out_testi(s, addrlo, a_mask); /* jne slow_path */ - tcg_out_opc(s, OPC_JCC_long + JCC_JNE, 0, 0, 0); + jcc =3D 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] =3D s->code_ptr; s->code_ptr +=3D 4; } @@ -2259,9 +2280,10 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TC= GReg datalo, TCGReg datahi, } else { TCGLabel *l1 =3D gen_new_label(); TCGLabel *l2 =3D gen_new_label(); + int jcc; =20 - tcg_out_testi(s, h.base, 15); - tcg_out_jxx(s, JCC_JNE, l1, true); + jcc =3D tcg_out_cmp(s, TCG_COND_TSTNE, h.base, 15, true, false= ); + tcg_out_jxx(s, jcc, l1, true); =20 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, TC= GReg datalo, TCGReg datahi, } else { TCGLabel *l1 =3D gen_new_label(); TCGLabel *l2 =3D gen_new_label(); + int jcc; =20 - tcg_out_testi(s, h.base, 15); - tcg_out_jxx(s, JCC_JNE, l1, true); + jcc =3D tcg_out_cmp(s, TCG_COND_TSTNE, h.base, 15, true, false= ); + tcg_out_jxx(s, jcc, l1, true); =20 tcg_out_vex_modrm_sib_offset(s, OPC_MOVDQA_WxVx + h.seg, TCG_TMP_VEC, 0, --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926870; cv=none; d=zohomail.com; s=zohoarc; b=lI5FDO9+UsYSAV5z21wij7D4NGaNgQSE7jYecHsj6Zax2/ukgz7AIhiMuEtV59qUeGAzrFgXyqKAPdkx5DHwpwdroYIQ0DRNiwywpUYI3BeYFY3/TTieHXNFLoxE0jvkTn17te0cfn8DGFhFBDiXEi8tMleLuWIlGnRkH1c161g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926870; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1PZbgXf7h9mbijZSSPVJBmVbPzLYGP5B2/srtOcMXg4=; b=USfn3ajstA3WvWs2BcH5n/mu+LmP72cBvpQfNX2AkOHqBK4S2pzsM+SVWjxf0uqIxPwQ90y591DtY4waAW8/lIXpbbck2f0O3VmsTNfKAfRq/Pa0X7tW70c5I/eOWzDv5EER0oFCpVX5aqWR7lwkL98OHmDofmhRxPi/Ykf/aBw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926870741306.62572931918965; Wed, 10 Jan 2024 14:47:50 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IGUAR2TtOUl5Ni8shVTh5sVLaTOOGoYSiuSVk2D7PamUwH4bDTH6+L3QQ++6oIAAtZq3HqgXg== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926871443100005 Content-Type: text/plain; charset="utf-8" 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) /* q= emu_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(TCGCallReturnKin= d 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 =20 /* 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 =3D=3D 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 =3D=3D (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 =3D=3D (uint32_t)val || is_power_of_2(val))) { + return 1; + } } if ((ct & TCG_CT_CONST_WSZ) && val =3D=3D (type =3D=3D 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 =20 /* 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, TCGLa= bel *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; =20 if (!is_tst_cond(cond)) { if (!const_arg2) { @@ -1469,6 +1489,7 @@ static int tcg_out_cmp(TCGContext *s, TCGCond cond, T= CGArg arg1, } =20 jz =3D tcg_cond_to_jcc[cond]; + js =3D (cond =3D=3D TCG_COND_TSTNE ? JCC_JS : JCC_JNS); =20 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, } =20 if (arg2 <=3D 0xff && (TCG_TARGET_REG_BITS =3D=3D 64 || arg1 < 4)) { + if (arg2 =3D=3D 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; } =20 if ((arg2 & ~0xff00) =3D=3D 0 && arg1 < 4) { + if (arg2 =3D=3D 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; } =20 + if (is_power_of_2(rexw ? arg2 : (uint32_t)arg2)) { + int jc =3D (cond =3D=3D TCG_COND_TSTNE ? JCC_JB : JCC_JAE); + int sh =3D ctz64(arg2); + + rexw =3D (sh & 32 ? P_REXW : 0); + if ((sh & 31) =3D=3D 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 =3D=3D (uint32_t)arg2) { rexw =3D 0; @@ -3399,7 +3443,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode op) =20 case INDEX_op_brcond_i32: case INDEX_op_brcond_i64: - return C_O0_I2(r, re); + return C_O0_I2(r, reT); =20 case INDEX_op_bswap16_i32: case INDEX_op_bswap16_i64: @@ -3447,11 +3491,11 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGO= pcode 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); =20 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); =20 case INDEX_op_div2_i32: case INDEX_op_div2_i64: --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926851; cv=none; d=zohomail.com; s=zohoarc; b=OMxYXekhYxdYbRV6d4ukgJanB1SiRNPTPwk7AVWZxqnrbd1TOSBQMDUIC6+/GmcNgEUDHm8IInAwQlzlrl43Vrma08O7GR8Zs9iuKYpSy6hO5IhBFYHXrFrTrFYna2oLIsY5g3HECyHkG39IGUVX67TuuRNpX3ElCXJAtoSSMX0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926851; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=m/PSbURQMO52LKiUV65FsmYmXzuvt6ozdqSCCbVOxK8=; b=DoihVPMkizrDCX4wMihfzTPz5HB7SfPe3Mbcj5bC509TDJghkR0z86FLWhT0Z7cw7vMcJ4k+hAMs+ytsrjtBzkpu/7UPoBoSS8S3ZdQwlEhg9O/N0m9GzIE8jtSP/6zyAlpoqZa3ldeRv4azXihBbOcRNFa6BT8gifJxL2Srb9A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926851889341.56637540461986; Wed, 10 Jan 2024 14:47:31 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IHretxsBkephltom39482kwwl4p8XHZsm9+T/lF3wVAmeq+wFvFTYJaawrWzut0zomBpzE2sw== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926853365100017 Content-Type: text/plain; charset="utf-8" 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=C3=A9 --- 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 =3D=3D 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 =3D=3D 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; } =20 + if (arg2 =3D=3D 0xffff) { + tcg_out_modrm(s, OPC_TESTL | P_DATA16, arg1, arg1); + return jz; + } + if (arg2 =3D=3D 0xffffffffu) { + tcg_out_modrm(s, OPC_TESTL, arg1, arg1); + return jz; + } + if (is_power_of_2(rexw ? arg2 : (uint32_t)arg2)) { int jc =3D (cond =3D=3D TCG_COND_TSTNE ? JCC_JB : JCC_JAE); int sh =3D ctz64(arg2); --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926940; cv=none; d=zohomail.com; s=zohoarc; b=PH0CBdy0HGvZ+ArTby4Xk5c6AddFOiDc++VMVoG5ikfFccWSH8kh5R7qu5IqAGU5T28xfYsklLaCURBzhjTDPVR5PdEghTz8kpCncnnASLADPRh2ZZ9G33b9bxqomznbVWIqYo6zMHjPaABCFJSAk7UF9bsfnmUXXpN/M56W8kU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926940; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=w7DMJgHEIfczGa+x10sgEDsRXfwUGwOd6p01k71b3vA=; b=b6pxgDiViPNBvQU88aC5L39IPOYUk1kMIf/zc5oATglZtZUMUvRohYk5xhvLkMWeikNN8yTXkDCwlL1N/5QqhwtWPP/ywns3YZEEGzMkxdc6kZrS23GFj9Y/yckx7TLUKI+xxYxPRU4TQ1NMRdNLdu7REi5hWXwh+uGkW01RpRo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926940629677.3012919295288; Wed, 10 Jan 2024 14:49:00 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IG8nrB7sWxXdwbhaqaqF89295Gn0ije6S2SzkSSHjq9oY4EW0tx74g/FrAFRctCAXZYUUH3nQ== 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926941728100005 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=C3=A9 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[] =3D { [TCG_COND_GTU] =3D COND_GU, }; =20 -static const uint8_t tcg_cond_to_rcond[] =3D { +static const uint8_t tcg_cond_to_rcond[16] =3D { [TCG_COND_EQ] =3D RCOND_Z, [TCG_COND_NE] =3D RCOND_NZ, [TCG_COND_LT] =3D RCOND_LZ, @@ -679,7 +679,8 @@ static void tcg_out_brcond_i64(TCGContext *s, TCGCond c= ond, TCGReg arg1, int32_t arg2, int const_arg2, TCGLabel *l) { /* For 64-bit signed comparisons vs zero, we can avoid the compare. */ - if (arg2 =3D=3D 0 && !is_unsigned_cond(cond)) { + int rcond =3D tcg_cond_to_rcond[cond]; + if (arg2 =3D=3D 0 && rcond) { int off16 =3D 0; =20 if (l->has_value) { @@ -688,7 +689,7 @@ static void tcg_out_brcond_i64(TCGContext *s, TCGCond c= ond, 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); } =20 -static void tcg_out_movr(TCGContext *s, TCGCond cond, TCGReg ret, TCGReg c= 1, +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))); } =20 @@ -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 =3D=3D 0 && !is_unsigned_cond(cond) - && (!v1const || check_fit_i32(v1, 10))) { - tcg_out_movr(s, cond, ret, c1, v1, v1const); + int rcond =3D tcg_cond_to_rcond[cond]; + if (c2 =3D=3D 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 n= eg) { + 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, =20 /* For 64-bit signed comparisons vs zero, we can avoid the compare if the input does not overlap the output. */ - if (c2 =3D=3D 0 && !is_unsigned_cond(cond) && c1 !=3D ret) { + rcond =3D tcg_cond_to_rcond[cond]; + if (c2 =3D=3D 0 && rcond && c1 !=3D 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); --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704927108; cv=none; d=zohomail.com; s=zohoarc; b=NKNskbtw17Riu/HcwY7lUBBDezBXAbj2xGSqBtcVuH89XJOmYesPX3AmPSVYGeeUePgny3rYhc7rsm/qILC9JkWQpTX1xOMLcmDqOZbnl53cgaeiCA3X6PjiObFP5Ju8Y9UttrCwOsTkv2QK6n02a8GoPDrD9XbhNIlqQnQwbSk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704927108; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XTZQ8U70bvvwDjHMDYUT6Xyjxfqygw11gwaeaagFYFE=; b=f8ebrdFQdPr4TpQM+fkGnFR0H718uQQt7aNSnDD+1wjSbb5dVbIdlzZnMJqVWZS04SZ/G8Ihduh5C8N+7oiJniqp7Thps7skgofufRP3GKHPK3WRi44pMMoRGCtWiMdgm7/rh4qZbNj7kFq4/aTXtaOWUpQ2Ipa2eb2uto7rXFk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704927108893479.805312692705; Wed, 10 Jan 2024 14:51:48 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IGmQ+P5X49j1+y1jv3dIdPLLfQytAZdRXvVrNl1in52vYYuGZ1s1atVrCpk3n7fxrbO4BfKHg== 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704927110251100003 Reviewed-by: Philippe Mathieu-Daud=C3=A9 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); } =20 -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); } =20 @@ -691,7 +692,7 @@ static void tcg_out_brcond_i64(TCGContext *s, TCGCond c= ond, 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 =3D=3D 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, TCGCon= d cond, TCGReg ret, /* FALLTHRU */ =20 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; } =20 - tcg_out_cmp(s, c1, c2, c2const); + tcg_out_cmp(s, cond, c1, c2, c2const); if (cond =3D=3D TCG_COND_LTU) { if (neg) { /* 0 - 0 - C =3D -C =3D (C ? -1 : 0) */ @@ -799,7 +800,7 @@ static void tcg_out_setcond_i64(TCGContext *s, TCGCond = cond, TCGReg ret, c2 =3D c1, c2const =3D 0, c1 =3D 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); =20 ldst =3D new_ldst_label(s); ldst->is_ld =3D is_ld; --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926956; cv=none; d=zohomail.com; s=zohoarc; b=GkWS4rgRoo9MqMEgzfy0+IO7wYe+TDtccxW7XYeajBcyMDOmItQdA104vW0xCLhLb/IL8anUT6D2CLf0EoO3TxTBoO5LWVyfdsc9WlYqgttrdYX+zw8+Q4vy/0cb+vdh3w5H6oJ8G1hb4kOJ0rwWUZFd6b7+ZabZcCS+HAmvwjo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926956; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=J7nkcnvR7yCW819cN0Z1TIqZ24aA0LLfk5m6dHETDfI=; b=aybrSZ/vzYj3QzyjHusfJX63WCKLtogpZBLsa9ggPQOaR5yxyHBrMr0/HpumrQXwjQelr4cHFg93gu7ngbZZ3tvbDIFm+HzhVO9DgG/i/F069wNDM+p4ws9LpwaebJwZKCkUQXgOWpwKTfVPmAD9fhtZpjRMOlm+o8pBxng+36U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926956855686.3953987621476; Wed, 10 Jan 2024 14:49:16 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IHLIvpZpl4haxvEpMA6/Gh0QVJq1bG5KwVrjiH3pdO4/ZC2E2htljRXo3fhoNuW7zVw3Bp59Q== 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926957808100001 Reviewed-by: Philippe Mathieu-Daud=C3=A9 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; =20 #define TCG_TARGET_HAS_qemu_ldst_i128 0 =20 -#define TCG_TARGET_HAS_tst 0 +#define TCG_TARGET_HAS_tst 1 =20 #define TCG_AREG0 TCG_REG_I0 =20 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, TC= GReg rs1, uns ? ARITH_UDIV : ARITH_SDIV); } =20 -static const uint8_t tcg_cond_to_bcond[] =3D { +static const uint8_t tcg_cond_to_bcond[16] =3D { [TCG_COND_EQ] =3D COND_E, [TCG_COND_NE] =3D COND_NE, + [TCG_COND_TSTEQ] =3D COND_E, + [TCG_COND_TSTNE] =3D COND_NE, [TCG_COND_LT] =3D COND_L, [TCG_COND_GE] =3D COND_GE, [TCG_COND_LE] =3D 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); } =20 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 =3D (cond =3D=3D TCG_COND_EQ ? TCG_COND_GEU : TCG_COND_LTU); break; =20 + 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 =3D TCG_REG_G0; + c2 =3D TCG_REG_T1, c2const =3D 0; + cond =3D (cond =3D=3D 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 --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926870; cv=none; d=zohomail.com; s=zohoarc; b=R5eEe8ZCv9jLi9F806/UIlKXEBkh7GPOH77XHSpIJe5Ql5xqPW6d5AzKHvTbudiYv6F7gfm6S/AlVwQ4CotBIm0WfX/d9YNdVTaqu5Y70x5IEOgysirqRe6062/eC1PK1RIGVw/5JX1xe6lx2Q65yBcLlVYLM0mGPCVOB0MSuqQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926870; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Njou8078FZIGaih/KmoVshAEm+KpvJ/TDJRnizv9npg=; b=nDG2a+Q75dEXeO7oWtuFNoeoT2ZiF7nX9rl4X11RN9+5Jadah0wwRzip2NUUi6yRkvDXLhkwF5LGMOZqmp5SxZzo0pEFeXK8xS0K84264mTyH813taXPkum+iPZXcoQXUJwMlZy4897MSo/1pTq1FpYGYVFWdIRJQ90xmIVxH9c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170492687024191.08956462196181; Wed, 10 Jan 2024 14:47:50 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IH/vbNkhNkcXSVbcdqyJCV86Lhy2wF083Drgw9gWIkWGLtnJKUQwcoBbMQyXQPWX0Xl1o0rWA== 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926871473100008 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=C3=A9 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, } } =20 -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 =3D 0; if (l->has_value) { - bc |=3D reloc_pc14_val(tcg_splitwx_to_rx(s->code_ptr), l->u.value_= ptr); + bd =3D reloc_pc14_val(tcg_splitwx_to_rx(s->code_ptr), l->u.value_p= tr); } else { tcg_out_reloc(s, s->code_ptr, R_PPC_REL14, l, 0); } - tcg_out32(s, bc); + tcg_out_bc(s, cond, bd); } =20 static void tcg_out_brcond(TCGContext *s, TCGCond cond, @@ -1961,7 +1967,7 @@ static void tcg_out_brcond(TCGContext *s, TCGCond con= d, 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); } =20 static void tcg_out_movcond(TCGContext *s, TCGType type, TCGCond cond, @@ -2003,7 +2009,7 @@ static void tcg_out_movcond(TCGContext *s, TCGType ty= pe, TCGCond cond, } } /* Branch forward over one insn */ - tcg_out32(s, tcg_to_bc[cond] | 8); + tcg_out_bc(s, cond, 8); if (v2 =3D=3D 0) { tcg_out_movi(s, type, dest, 0); } else { @@ -2024,11 +2030,11 @@ static void tcg_out_cntxz(TCGContext *s, TCGType ty= pe, 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 =3D=3D 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 T= CGArg *args, tcg_out_rlw(s, RLWINM, args[0], TCG_REG_R0, 31, 31, 31); } =20 -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])); } =20 static void tcg_out_mb(TCGContext *s, TCGArg a0) @@ -2446,7 +2452,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext= *s, HostAddress *h, =20 /* Load a pointer into the current opcode w/conditional branch-lin= k. */ ldst->label_ptr[0] =3D s->code_ptr; - tcg_out32(s, BC | BI(7, CR_EQ) | BO_COND_FALSE | LK); + tcg_out_bc(s, TCG_COND_NE, LK); =20 h->base =3D TCG_REG_TMP1; } else { --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926868; cv=none; d=zohomail.com; s=zohoarc; b=kRDxqCnS4+OuMznSSXe1XXJx1TauHoHLhx+AaabDDYIw8XaTWw0qU6czdB6Ot+j5XwxQJAWPBK1CJvUUPQ9NShT/yFD5T7fA1CVh21T4ZoB+J+/bqmnEaeVjOMYiamBdiuRPTJinj/KT1rBCFEJD6hGz+EeOe1nscirUOaOGGcE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926868; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3V+CWkXdNqNJeKthv/lyY08kBwUymIwSbvahoKExcsA=; b=E8vBI6HLZSTwybP4q127FcHRHAmihcYm+KVhHhvcXAp6D8TPAAGy2S6eLtH7EQkIITxjYifg9hyrbrTKpkEegG/0dRB6ZkDdRvTNf3K+apnHa9cHq7xQT76Jc+znxalQcGI2Bf3JKu51qI67UxUgfpaiIyhpqJIR3Zo/fruEE/Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926868105951.4066628471045; Wed, 10 Jan 2024 14:47:48 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IG0fIUOVCiiihf4C5V64lNv4+G3gjUkv4eCGiuPu1fr942xbmfATaMIOulXSGuI9X9NL0P/vA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926869452100001 Content-Type: text/plain; charset="utf-8" Using cr0 means we could choose to use rc=3D1 to compute the condition. Adjust the tables and tcg_out_cmp that feeds them. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 { }; =20 static const uint32_t tcg_to_bc[] =3D { - [TCG_COND_EQ] =3D BC | BI(7, CR_EQ) | BO_COND_TRUE, - [TCG_COND_NE] =3D BC | BI(7, CR_EQ) | BO_COND_FALSE, - [TCG_COND_LT] =3D BC | BI(7, CR_LT) | BO_COND_TRUE, - [TCG_COND_GE] =3D BC | BI(7, CR_LT) | BO_COND_FALSE, - [TCG_COND_LE] =3D BC | BI(7, CR_GT) | BO_COND_FALSE, - [TCG_COND_GT] =3D BC | BI(7, CR_GT) | BO_COND_TRUE, - [TCG_COND_LTU] =3D BC | BI(7, CR_LT) | BO_COND_TRUE, - [TCG_COND_GEU] =3D BC | BI(7, CR_LT) | BO_COND_FALSE, - [TCG_COND_LEU] =3D BC | BI(7, CR_GT) | BO_COND_FALSE, - [TCG_COND_GTU] =3D BC | BI(7, CR_GT) | BO_COND_TRUE, + [TCG_COND_EQ] =3D BC | BI(0, CR_EQ) | BO_COND_TRUE, + [TCG_COND_NE] =3D BC | BI(0, CR_EQ) | BO_COND_FALSE, + [TCG_COND_LT] =3D BC | BI(0, CR_LT) | BO_COND_TRUE, + [TCG_COND_GE] =3D BC | BI(0, CR_LT) | BO_COND_FALSE, + [TCG_COND_LE] =3D BC | BI(0, CR_GT) | BO_COND_FALSE, + [TCG_COND_GT] =3D BC | BI(0, CR_GT) | BO_COND_TRUE, + [TCG_COND_LTU] =3D BC | BI(0, CR_LT) | BO_COND_TRUE, + [TCG_COND_GEU] =3D BC | BI(0, CR_LT) | BO_COND_FALSE, + [TCG_COND_LEU] =3D BC | BI(0, CR_GT) | BO_COND_FALSE, + [TCG_COND_GTU] =3D BC | BI(0, CR_GT) | BO_COND_TRUE, }; =20 /* The low bit here is set if the RA and RB fields must be inverted. */ static const uint32_t tcg_to_isel[] =3D { - [TCG_COND_EQ] =3D ISEL | BC_(7, CR_EQ), - [TCG_COND_NE] =3D ISEL | BC_(7, CR_EQ) | 1, - [TCG_COND_LT] =3D ISEL | BC_(7, CR_LT), - [TCG_COND_GE] =3D ISEL | BC_(7, CR_LT) | 1, - [TCG_COND_LE] =3D ISEL | BC_(7, CR_GT) | 1, - [TCG_COND_GT] =3D ISEL | BC_(7, CR_GT), - [TCG_COND_LTU] =3D ISEL | BC_(7, CR_LT), - [TCG_COND_GEU] =3D ISEL | BC_(7, CR_LT) | 1, - [TCG_COND_LEU] =3D ISEL | BC_(7, CR_GT) | 1, - [TCG_COND_GTU] =3D ISEL | BC_(7, CR_GT), + [TCG_COND_EQ] =3D ISEL | BC_(0, CR_EQ), + [TCG_COND_NE] =3D ISEL | BC_(0, CR_EQ) | 1, + [TCG_COND_LT] =3D ISEL | BC_(0, CR_LT), + [TCG_COND_GE] =3D ISEL | BC_(0, CR_LT) | 1, + [TCG_COND_LE] =3D ISEL | BC_(0, CR_GT) | 1, + [TCG_COND_GT] =3D ISEL | BC_(0, CR_GT), + [TCG_COND_LTU] =3D ISEL | BC_(0, CR_LT), + [TCG_COND_GEU] =3D ISEL | BC_(0, CR_LT) | 1, + [TCG_COND_LEU] =3D ISEL | BC_(0, CR_GT) | 1, + [TCG_COND_GTU] =3D ISEL | BC_(0, CR_GT), }; =20 static bool patch_reloc(tcg_insn_unit *code_ptr, int type, @@ -1827,7 +1827,7 @@ static void tcg_out_setcond(TCGContext *s, TCGType ty= pe, TCGCond cond, if (have_isa_3_10) { tcg_insn_unit bi, opc; =20 - tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 7, type); + tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 0, type); =20 /* Re-use tcg_to_bc for BI and BO_COND_{TRUE,FALSE}. */ bi =3D tcg_to_bc[cond] & (0x1f << 16); @@ -1880,7 +1880,7 @@ static void tcg_out_setcond(TCGContext *s, TCGType ty= pe, TCGCond cond, if (have_isel) { int isel, tab; =20 - tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 7, type); + tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 0, type); =20 isel =3D tcg_to_isel[cond]; =20 @@ -1966,7 +1966,7 @@ static void tcg_out_brcond(TCGContext *s, TCGCond con= d, 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); } =20 @@ -1980,7 +1980,7 @@ static void tcg_out_movcond(TCGContext *s, TCGType ty= pe, TCGCond cond, return; } =20 - tcg_out_cmp(s, cond, c1, c2, const_c2, 7, type); + tcg_out_cmp(s, cond, c1, c2, const_c2, 0, type); =20 if (have_isel) { int isel =3D tcg_to_isel[cond]; @@ -2024,7 +2024,7 @@ static void tcg_out_cntxz(TCGContext *s, TCGType type= , uint32_t opc, if (const_a2 && a2 =3D=3D (type =3D=3D 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; =20 case TCG_COND_LT: @@ -2097,8 +2097,8 @@ static void tcg_out_cmp2(TCGContext *s, const TCGArg = *args, =20 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; =20 default: @@ -2110,8 +2110,8 @@ static void tcg_out_setcond2(TCGContext *s, const TCG= Arg *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); } =20 static void tcg_out_brcond2(TCGContext *s, const TCGArg *args, @@ -2442,12 +2442,12 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGConte= xt *s, HostAddress *h, tcg_out_cmp(s, TCG_COND_EQ, addrhi, TCG_REG_TMP2, 0, 6, TCG_TYPE_I32); =20 - /* 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); } =20 /* Load a pointer into the current opcode w/conditional branch-lin= k. */ --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926885; cv=none; d=zohomail.com; s=zohoarc; b=UfSvCQoBVWWGzPUE4U9rJXWodxmEYPjurAznkctEeRFUUSrBpxhSNQ26uqmclLTcrXiR4M4E8cBqsw8FrpNegeUxHkG5SEUH7OkMqR4hqE2NnDuwTQtpJbLozKmIuIFAgM9nMGZn4vephx6D6D2yU5n5vBW4QxDknRCm1Fa/AXI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926885; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=l6wrsnSxRLOGGrrUU+5wUcOLIX0LsFSMqYGfjSPgVvg=; b=fviKQBiRCljjxYOEiH8qHlnD222gY6sdERtW5X+7t8vGDbe2Re4HhBd6X4taDY95RQl6o8GDEZxpRFk8pB4vqk+8ojtN1/bxOOVuWwAQYaR+mGW4yN2QUM5tcTrfaQSXQMLajuDBIbSgFW7OZRby5HD1/s3o8L4io1+4axZ2WI0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926885492409.6907617838598; Wed, 10 Jan 2024 14:48:05 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IFARdK+VrmfEJTba1kHd/29lJ/JnfFaa7oDFALtZ+dqC4oJajBJ4TrIoNmYWvOJ/OC7Tpb8hQ== 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926887482100001 Reviewed-by: Philippe Mathieu-Daud=C3=A9 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 t= cg_insn_unit *target) } =20 /* 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 =3D sval; + if (ct & TCG_CT_CONST) { return 1; } =20 - /* The only 32-bit constraint we use aside from - TCG_CT_CONST is TCG_CT_CONST_S16. */ if (type =3D=3D TCG_TYPE_I32) { - val =3D (int32_t)val; + uval =3D (uint32_t)sval; + sval =3D (int32_t)sval; } =20 - if ((ct & TCG_CT_CONST_S16) && val =3D=3D (int16_t)val) { + if ((ct & TCG_CT_CONST_S16) && sval =3D=3D (int16_t)sval) { return 1; - } else if ((ct & TCG_CT_CONST_S32) && val =3D=3D (int32_t)val) { + } + if ((ct & TCG_CT_CONST_S32) && sval =3D=3D (int32_t)sval) { return 1; - } else if ((ct & TCG_CT_CONST_U32) && val =3D=3D (uint32_t)val) { + } + if ((ct & TCG_CT_CONST_U32) && uval =3D=3D (uint32_t)uval) { return 1; - } else if ((ct & TCG_CT_CONST_ZERO) && val =3D=3D 0) { + } + if ((ct & TCG_CT_CONST_ZERO) && sval =3D=3D 0) { return 1; - } else if ((ct & TCG_CT_CONST_MONE) && val =3D=3D -1) { + } + if ((ct & TCG_CT_CONST_MONE) && sval =3D=3D -1) { return 1; - } else if ((ct & TCG_CT_CONST_WSZ) - && val =3D=3D (type =3D=3D TCG_TYPE_I32 ? 32 : 64)) { + } + if ((ct & TCG_CT_CONST_WSZ) && sval =3D=3D (type =3D=3D TCG_TYPE_I32 ?= 32 : 64)) { return 1; } return 0; --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926862; cv=none; d=zohomail.com; s=zohoarc; b=epycPEwUUePj5QbHtu3EpSDG8aCVBDi83ca7Ny2dTpGion8sqpazbbINIEt5f3z2zX8Pxp50y0WiXss3PlT8d6WtK8Xs6nCC+C9PmZoaDTX9bSJ2f4sKQytVf1SShzQAi33nUkqXKI3QmMKDrti9PDi8RsZ112Kxb0BtqLouYCk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926862; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zjHxyGR5DOw/0X5t4FNhTcg/ySO1/KXOrl0SiEd+H80=; b=YERS1qKr7VyTtykhPoTK6rfMS0ScW6VBPIVaZep/SUvvGhIbNPLGSWBr/fexbGKzPLql0CR2gyyr/1bYbu5DZTd5maEuvjEr9VinobNZZhNXyU1bCTk1byrBFYqUlLusogKB/FtFca+XVdvtYZV0QLnWmO8z7vK+BXW49w0yTy8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926862415382.3535784982606; Wed, 10 Jan 2024 14:47:42 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IEmnXJnQF0SrqK3pdkCt1V1JUh2FdmwBD6ZNIlARSIwPsNx5fjB1TBPTI+VAElsii0jfEkwjg== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926863407100001 Content-Type: text/plain; charset="utf-8" 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=C3=A9 --- 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) =20 #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 =20 #define ALL_GENERAL_REGS 0xffffffffu #define ALL_VECTOR_REGS 0xffffffff00000000ull @@ -296,9 +298,35 @@ static bool tcg_target_const_match(int64_t sval, int c= t, sval =3D (int32_t)sval; } =20 + if (ct & TCG_CT_CONST_CMP) { + switch (cond) { + case TCG_COND_EQ: + case TCG_COND_NE: + ct |=3D 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 |=3D TCG_CT_CONST_S16; + break; + case TCG_COND_LTU: + case TCG_COND_GEU: + case TCG_COND_LEU: + case TCG_COND_GTU: + ct |=3D TCG_CT_CONST_U16; + break; + default: + g_assert_not_reached(); + } + } + if ((ct & TCG_CT_CONST_S16) && sval =3D=3D (int16_t)sval) { return 1; } + if ((ct & TCG_CT_CONST_U16) && uval =3D=3D (uint16_t)uval) { + return 1; + } if ((ct & TCG_CT_CONST_S32) && sval =3D=3D (int32_t)sval) { return 1; } @@ -1682,7 +1710,10 @@ static void tcg_out_cmp(TCGContext *s, int cond, TCG= Arg arg1, TCGArg arg2, =20 tcg_debug_assert(TCG_TARGET_REG_BITS =3D=3D 64 || type =3D=3D TCG_TYPE= _I32); =20 - /* 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 =3D=3D TCG_TYPE_I32) { arg2 =3D (int32_t)arg2; } @@ -3991,8 +4022,6 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode 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(TCGOpc= ode 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); =20 case INDEX_op_mul_i32: @@ -4045,11 +4072,16 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGO= pcode op) =20 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); --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926908; cv=none; d=zohomail.com; s=zohoarc; b=Gx3Lm1BvGmnVeBpJ6qkdKq8RGtGYVLNkxdDk0PihAaI2CIyXwwBdQ3iaIGW0gxT4XyNY6c8j9tmmrT8TextODNmciuxZCZRdPf23I7dmAZXl/z4cqvjAZ1dGzaFAsQiHtSuUgCJi6jDH0tlixS8O/Ri5BQXh5ED4g4vFn/eBZeA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926908; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+m2bQ+EJZL+KCOl+ulw6p2ASMsIl7BSAfdsffaeaSYk=; b=kDSsaZ+dZqLHOV6zjkMH2GX0Av9c4Q4tIV8RAOUOb/lQk7AIrarqTGujSsH9n4rmLRTEqO+6a42rVGqKm7aOr56ZA1hUq9vz4uFro4oJC5LzXIYKZoOAA+AX3Atv+3wqDHxxxUH9aj316VctMDKKYb2xrV2/AblitRKZJ/k5G8k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17049269082749.863216874740147; Wed, 10 Jan 2024 14:48:28 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IF544GMuMIDXjBzC9wvGcf23N7VO7wGKASKUlhduPNlb5Uq24dPqlqlkmN+McbcSuT3fOfW4w== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926909663100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 =3D=3D 64 && have_isa_2_07) =20 -#define TCG_TARGET_HAS_tst 0 +#define TCG_TARGET_HAS_tst 1 =20 /* * 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 t= cg_insn_unit *target) return false; } =20 +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 =3D sval; + int mb, me; =20 if (ct & TCG_CT_CONST) { return 1; @@ -316,6 +320,17 @@ static bool tcg_target_const_match(int64_t sval, int c= t, case TCG_COND_GTU: ct |=3D TCG_CT_CONST_U16; break; + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + if ((uval & ~0xffff) =3D=3D 0 || (uval & ~0xffff0000ull) =3D= =3D 0) { + return 1; + } + if (TCG_TARGET_REG_BITS =3D=3D 32 || type =3D=3D 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 }; =20 -static const uint32_t tcg_to_bc[] =3D { +static const uint32_t tcg_to_bc[16] =3D { [TCG_COND_EQ] =3D BC | BI(0, CR_EQ) | BO_COND_TRUE, [TCG_COND_NE] =3D BC | BI(0, CR_EQ) | BO_COND_FALSE, + [TCG_COND_TSTEQ] =3D BC | BI(0, CR_EQ) | BO_COND_TRUE, + [TCG_COND_TSTNE] =3D BC | BI(0, CR_EQ) | BO_COND_FALSE, [TCG_COND_LT] =3D BC | BI(0, CR_LT) | BO_COND_TRUE, [TCG_COND_GE] =3D BC | BI(0, CR_LT) | BO_COND_FALSE, [TCG_COND_LE] =3D BC | BI(0, CR_GT) | BO_COND_FALSE, @@ -717,9 +734,11 @@ static const uint32_t tcg_to_bc[] =3D { }; =20 /* The low bit here is set if the RA and RB fields must be inverted. */ -static const uint32_t tcg_to_isel[] =3D { +static const uint32_t tcg_to_isel[16] =3D { [TCG_COND_EQ] =3D ISEL | BC_(0, CR_EQ), [TCG_COND_NE] =3D ISEL | BC_(0, CR_EQ) | 1, + [TCG_COND_TSTEQ] =3D ISEL | BC_(0, CR_EQ), + [TCG_COND_TSTNE] =3D ISEL | BC_(0, CR_EQ) | 1, [TCG_COND_LT] =3D ISEL | BC_(0, CR_LT), [TCG_COND_GE] =3D ISEL | BC_(0, CR_LT) | 1, [TCG_COND_LE] =3D 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; } =20 -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 =3D=3D 64); sh =3D SH(sh & 0x1f) | (((sh >> 5) & 1) << 1); mb =3D 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); } =20 -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); } =20 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, TCGTyp= e type, TCGArg val, return false; } =20 +/* + * 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 a= rg2, + 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 =3D=3D TCG_TYPE_I32) { + arg2 =3D (uint32_t)arg2; + } else if (arg2 =3D=3D (uint32_t)arg2) { + type =3D TCG_TYPE_I32; + } + + if ((arg2 & ~0xffff) =3D=3D 0) { + tcg_out32(s, ANDI | SAI(arg1, dest, arg2)); + return; + } + if ((arg2 & ~0xffff0000ull) =3D=3D 0) { + tcg_out32(s, ANDIS | SAI(arg1, dest, arg2 >> 16)); + return; + } + if (TCG_TARGET_REG_BITS =3D=3D 32 || type =3D=3D 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 =3D 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, TCG= Arg arg1, TCGArg arg2, imm =3D 0; break; =20 + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + tcg_debug_assert(cr =3D=3D 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 t= ype, TCGCond cond, tcg_out_setcond_ne0(s, type, arg0, arg1, neg); break; =20 + 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 =3D 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; =20 + 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: --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926848; cv=none; d=zohomail.com; s=zohoarc; b=kF1w6IsvH+rqQya945509D/X/ctHbf9kf0lblj12RsUR3C86KzzgFrlXtY6EOXnvyM3I7PDY2rtcNy3aX7OU3Zg6XdiXh3xqMdqb3xZ5S/qgOwmncrsiGgjEBLcz8LlRUe4QhMqpafEwU7vvN1OwiSU26wSUeTNSc5nFOF6V9mM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926848; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SG+rKuUVbaUxXp+EMRwo0KDiuCri6E6fV9fOpbonh9A=; b=fLijAn5X1waqYzz5IkRYPvsXo65L/K0ZWbTbDM7usup9ELfPofbUh7o94E29yMiqKpqJLXPOWYzm3ugiLpvIjp2MZcTZRA3vilND6RMAFpStuxz9eSsniJ3VE5kvuVSF9qsb/OIfX0Tn7uzyfyF28Wqfd5uHwUBtGPWiu2mu7jY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170492684865315.225640200301427; Wed, 10 Jan 2024 14:47:28 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IFulm/FA8wzkTiqpomjM7QkrneslTHkC+qvHOTefsVwJSohfczVhvUsR73JxGorGUexEtx+yQ== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926849504100005 Content-Type: text/plain; charset="utf-8" Signed 33-bit =3D=3D signed 32-bit + unsigned 32-bit. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 @@ =20 #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 c= t, TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { - return 1; + return true; } - if (type =3D=3D TCG_TYPE_I32) { val =3D (int32_t)val; } =20 - /* The following are mutually exclusive. */ - if (ct & TCG_CT_CONST_S16) { - return val =3D=3D (int16_t)val; - } else if (ct & TCG_CT_CONST_S32) { - return val =3D=3D (int32_t)val; - } else if (ct & TCG_CT_CONST_S33) { - return val >=3D -0xffffffffll && val <=3D 0xffffffffll; - } else if (ct & TCG_CT_CONST_ZERO) { - return val =3D=3D 0; + if ((ct & TCG_CT_CONST_S32) && val =3D=3D (int32_t)val) { + return true; + } + if ((ct & TCG_CT_CONST_U32) && val =3D=3D (uint32_t)val) { + return true; + } + if ((ct & TCG_CT_CONST_S16) && val =3D=3D (int16_t)val) { + return true; + } + if ((ct & TCG_CT_CONST_ZERO) && val =3D=3D 0) { + return true; } =20 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; } =20 /* Emit instructions according to the given instruction format. */ @@ -3137,7 +3137,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode 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); =20 case INDEX_op_clz_i64: return C_O1_I2(r, r, rI); @@ -3187,7 +3187,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode 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); =20 case INDEX_op_bswap16_i32: case INDEX_op_bswap16_i64: @@ -3240,7 +3240,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode 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); =20 case INDEX_op_div2_i32: case INDEX_op_div2_i64: @@ -3259,7 +3259,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode op) =20 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); =20 case INDEX_op_st_vec: return C_O0_I2(v, r); --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926948; cv=none; d=zohomail.com; s=zohoarc; b=nOhIJIb/MfRQvA5atd+eoaeApdF0XW0Am65WIa56F6/g+26cmF+mPjct31zumsWWkHwI1LMAEzMgaKbMsqf98ammeWP8Jp+i76ci8kMnmm4X7GJZT+v/duY7ZZQFS0OKLbFmqth67rhpnb03RRvUSG5tMWMc7JlwJLUoeub8iO0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926948; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aJQydxS3NvJxT4eWGTovhRM0Zt2nynj/3g50i7a6gMo=; b=n6ikumDednmr89PvjO5sJ98SR2hx0D4wH8J4jIVdhXJYPtkjbSuCgyTpzGBJKN0NWX4ees1N90eGbymu7aXb79sxWruDSK94diehDqVzysOzGyND7BVahUZhLQQEuoKDQXphu1C5n7gxigy/3srf6lkOEDmFWpe+ejWwKu5p4+w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170492694823397.46090892906886; Wed, 10 Jan 2024 14:49:08 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IF0Nc0vsb33jP23lHlYC5vvnOQT0Z23G98J2+cTZJWjWeUmn4QvwWgfyG2C36GPm4qQkGQFVw== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926949800100003 Content-Type: text/plain; charset="utf-8" Better constraint for tcg_out_cmp, based on the comparison. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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) =20 #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 =3D (int32_t)val; } =20 + if (ct & TCG_CT_CONST_CMP) { + switch (cond) { + case TCG_COND_EQ: + case TCG_COND_NE: + ct |=3D 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 |=3D TCG_CT_CONST_S32; /* CGFI */ + break; + case TCG_COND_LTU: + case TCG_COND_GEU: + case TCG_COND_LEU: + case TCG_COND_GTU: + ct |=3D TCG_CT_CONST_U32; /* CLGFI */ + break; + default: + g_assert_not_reached(); + } + } + if ((ct & TCG_CT_CONST_S32) && val =3D=3D (int32_t)val) { return true; } @@ -1229,22 +1253,34 @@ static int tgen_cmp2(TCGContext *s, TCGType type, T= CGCond c, TCGReg r1, goto exit; } =20 - /* - * Constraints are for a signed 33-bit operand, which is a - * convenient superset of this signed/unsigned test. - */ - if (c2 =3D=3D (is_unsigned ? (TCGArg)(uint32_t)c2 : (TCGArg)(int32= _t)c2)) { - op =3D (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 =3D=3D (int32_t)c2); + op =3D RIL_CGFI; + break; + case TCG_COND_EQ: + case TCG_COND_NE: + if (c2 =3D=3D (int32_t)c2) { + op =3D 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 =3D=3D (uint32_t)c2); + op =3D 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 =3D TCG_TMP0; - } - - if (type =3D=3D TCG_TYPE_I32) { + tcg_out_insn_RIL(s, op, r1, c2); + } else if (type =3D=3D TCG_TYPE_I32) { op =3D (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(TCGOpc= ode 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); =20 case INDEX_op_clz_i64: return C_O1_I2(r, r, rI); @@ -3187,7 +3223,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode 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); =20 case INDEX_op_bswap16_i32: case INDEX_op_bswap16_i64: @@ -3240,7 +3276,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode 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); =20 case INDEX_op_div2_i32: case INDEX_op_div2_i64: --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926952; cv=none; d=zohomail.com; s=zohoarc; b=SDm7usiCuDnqEKIgrTv2m3+/zGa+eY5/6g22mXJMLKfrWez3Kq2jjFFlL+mVI7iAG5b6uNQjJMUwQIQP/NCnZ6JMK3wQlU4mrDMzVNi2w/wnwrwaJvHE6MaZNp6T4gHGVhjzcrdpdoFYBVb8Hs+wMlRlqB0SlHU/Qd5fpxwa7OU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926952; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wZ0H1HwSFXvLC8Z3KY83cUGJjMMhIte+R5upodq3iGE=; b=M+HugSsIDUuWcOdp62W9yq3X9AUWfp0Ggec3o6VMQYABgR/Nudi0IyglRVHTkCE7WCrb0AQlEFQ5+QTE0HX6YV9Q7s7igx6kr/xusPY2va+u+aAgDvojTwDQRkG5dmicrPWZYfTL1nqg8nnl3GdGvt7o39h7QTlSVj8ZFmy0irk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926952559812.5812868113092; Wed, 10 Jan 2024 14:49:12 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IHdcfldtjs/fIlLdmLch9n36xR65z1iI1MQi3apOSX3EgP3PxcMpfzxCWgwDzV9OAJNqnxscA== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926953811100001 Content-Type: text/plain; charset="utf-8" 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]; =20 #define TCG_TARGET_HAS_qemu_ldst_i128 1 =20 -#define TCG_TARGET_HAS_tst 0 +#define TCG_TARGET_HAS_tst 1 =20 #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 =3D 0xa50a, RI_OILL =3D 0xa50b, RI_TMLL =3D 0xa701, + RI_TMLH =3D 0xa700, + RI_TMHL =3D 0xa703, + RI_TMHH =3D 0xa702, =20 RIEb_CGRJ =3D 0xec64, RIEb_CLGRJ =3D 0xec65, @@ -404,10 +407,15 @@ static TCGReg tcg_target_call_oarg_reg(TCGCallReturnK= ind kind, int slot) #define S390_CC_NEVER 0 #define S390_CC_ALWAYS 15 =20 +#define S390_TM_EQ 8 /* CC =3D=3D 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[] =3D { +static const uint8_t tcg_cond_to_s390_cond[16] =3D { [TCG_COND_EQ] =3D S390_CC_EQ, [TCG_COND_NE] =3D S390_CC_NE, + [TCG_COND_TSTEQ] =3D S390_CC_EQ, + [TCG_COND_TSTNE] =3D S390_CC_NE, [TCG_COND_LT] =3D S390_CC_LT, [TCG_COND_LE] =3D S390_CC_LE, [TCG_COND_GT] =3D S390_CC_GT, @@ -421,9 +429,11 @@ static const uint8_t tcg_cond_to_s390_cond[] =3D { /* 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[] =3D { +static const uint8_t tcg_cond_to_ltr_cond[16] =3D { [TCG_COND_EQ] =3D S390_CC_EQ, [TCG_COND_NE] =3D S390_CC_NE, + [TCG_COND_TSTEQ] =3D S390_CC_ALWAYS, + [TCG_COND_TSTNE] =3D S390_CC_NEVER, [TCG_COND_LT] =3D S390_CC_LT, [TCG_COND_LE] =3D S390_CC_LE, [TCG_COND_GT] =3D 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 =3D val; + if (ct & TCG_CT_CONST) { return true; } if (type =3D=3D TCG_TYPE_I32) { + uval =3D (uint32_t)val; val =3D (int32_t)val; } =20 @@ -567,6 +580,15 @@ static bool tcg_target_const_match(int64_t val, int ct, case TCG_COND_GTU: ct |=3D TCG_CT_CONST_U32; /* CLGFI */ break; + case TCG_COND_TSTNE: + case TCG_COND_TSTEQ: + if (is_const_p16(uval) >=3D 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 =3D ~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) >=3D 0) { return true; } @@ -868,6 +886,9 @@ static const S390Opcode oi_insns[4] =3D { static const S390Opcode lif_insns[2] =3D { RIL_LLILF, RIL_LLIHF, }; +static const S390Opcode tm_insns[4] =3D { + RI_TMLL, RI_TMLH, RI_TMHL, RI_TMHH +}; =20 /* 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, TC= GCond c, TCGReg r1, TCGCond inv_c =3D tcg_invert_cond(c); S390Opcode op; =20 + if (is_tst_cond(c)) { + tcg_debug_assert(!need_carry); + + if (!c2const) { + if (type =3D=3D 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 =3D=3D TCG_TYPE_I32) { + c2 =3D (uint32_t)c2; + } + + int i =3D is_const_p16(c2); + if (i >=3D 0) { + tcg_out_insn_RI(s, tm_insns[i], r1, c2 >> (i * 16)); + *inv_cc =3D 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 =3D=3D 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 =3D is_unsigned_cond(c); - bool in_range; - S390Opcode opc; =20 - cc =3D tcg_cond_to_s390_cond[c]; + if (!is_tst_cond(c)) { + bool is_unsigned =3D is_unsigned_cond(c); + bool in_range; + S390Opcode opc; =20 - if (!c2const) { - opc =3D (type =3D=3D 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 =3D tcg_cond_to_s390_cond[c]; =20 - /* - * 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 =3D=3D TCG_TYPE_I32) { - if (is_unsigned) { - opc =3D RIEc_CLIJ; - in_range =3D (uint32_t)c2 =3D=3D (uint8_t)c2; - } else { - opc =3D RIEc_CIJ; - in_range =3D (int32_t)c2 =3D=3D (int8_t)c2; + if (!c2const) { + opc =3D (type =3D=3D 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 =3D RIEc_CLGIJ; - in_range =3D (uint64_t)c2 =3D=3D (uint8_t)c2; + + /* + * COMPARE IMMEDIATE AND BRANCH RELATIVE has an 8-bit immediate fi= eld. + * 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 =3D=3D TCG_TYPE_I32) { + if (is_unsigned) { + opc =3D RIEc_CLIJ; + in_range =3D (uint32_t)c2 =3D=3D (uint8_t)c2; + } else { + opc =3D RIEc_CIJ; + in_range =3D (int32_t)c2 =3D=3D (int8_t)c2; + } } else { - opc =3D RIEc_CGIJ; - in_range =3D (int64_t)c2 =3D=3D (int8_t)c2; + if (is_unsigned) { + opc =3D RIEc_CLGIJ; + in_range =3D (uint64_t)c2 =3D=3D (uint8_t)c2; + } else { + opc =3D RIEc_CGIJ; + in_range =3D (int64_t)c2 =3D=3D (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; } =20 cc =3D tgen_cmp(s, type, c, r1, c2, c2const, false); @@ -1871,11 +1925,10 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGConte= xt *s, HostAddress *h, ldst->oi =3D oi; ldst->addrlo_reg =3D addr_reg; =20 - /* We are expecting a_bits to max out at 7, much lower than TM= LL. */ tcg_debug_assert(a_mask <=3D 0xffff); tcg_out_insn(s, RI, TMLL, addr_reg, a_mask); =20 - 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] =3D s->code_ptr++; } =20 @@ -1956,7 +2009,7 @@ static void tcg_out_qemu_ldst_i128(TCGContext *s, TCG= Reg datalo, TCGReg datahi, l2 =3D gen_new_label(); =20 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); } =20 tcg_debug_assert(!need_bswap); --=20 2.34.1 From nobody Thu Nov 14 07:15:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1704926952; cv=none; d=zohomail.com; s=zohoarc; b=IdHrmPqgXW0tEE49jklaOqQQYQ5qNsbWvUrfDuXRihTuplnZcQ2QfW8qkQPH7dRr+LadgUqvkckTPnM9D1tB7a7HgRiS6HBoVE1ThNU3/wWWyO8JNs8Z3rMcEYjTS193RU/AIFsblZTpJjrnDcrXRoPCFOqv9DaHpo2BTh5rl2c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704926952; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qTBa5jnTmGPw5Fiyw2n1vRD4BYHoTuI+qXkHnySYH1Q=; b=c5S7VvH/75g+5t15BmXgjUHa1eie+c2xxD7VBmroJusvQJut7UppQmxBh5/yZM//Jz0mvI1w0oMFy999sxHELCYEM4X4XmNsggN7k3UJ5EnA7jASHYvrdkUVG6dm3rvkWY4XNiD94veiBKE5CEq5AcGjCd18sE7d/bhz9ql8kRk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704926952665740.5079620135549; Wed, 10 Jan 2024 14:49:12 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IH2uWFGXiOxQWKTmtm4URgOb86k8ExMZnh6mLUs2Y8uAYiXUqeKSKfa52TpOBnzXTute/EUMg== 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) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704926953920100003 Reviewed-by: Philippe Mathieu-Daud=C3=A9 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 @@ =20 #define TCG_TARGET_HAS_qemu_ldst_i128 0 =20 -#define TCG_TARGET_HAS_tst 0 +#define TCG_TARGET_HAS_tst 1 =20 /* 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, TC= GCond condition) case TCG_COND_GTU: result =3D (u0 > u1); break; + case TCG_COND_TSTEQ: + result =3D (u0 & u1) =3D=3D 0; + break; + case TCG_COND_TSTNE: + result =3D (u0 & u1) !=3D 0; + break; default: g_assert_not_reached(); } @@ -270,6 +276,12 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TC= GCond condition) case TCG_COND_GTU: result =3D (u0 > u1); break; + case TCG_COND_TSTEQ: + result =3D (u0 & u1) =3D=3D 0; + break; + case TCG_COND_TSTNE: + result =3D (u0 & u1) !=3D 0; + break; default: g_assert_not_reached(); } @@ -1041,6 +1053,8 @@ static const char *str_c(TCGCond c) [TCG_COND_GEU] =3D "geu", [TCG_COND_LEU] =3D "leu", [TCG_COND_GTU] =3D "gtu", + [TCG_COND_TSTEQ] =3D "tsteq", + [TCG_COND_TSTNE] =3D "tstne", }; =20 assert((unsigned)c < ARRAY_SIZE(cond)); --=20 2.34.1