From patchwork Sun Feb 4 21:40:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769851 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842051wrc; Sun, 4 Feb 2024 13:41:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IHL/eV42QMnj7lP8TdDoVDMyf5FoUgSLF/8MBSwz+J6XAQmq+WzfLM7mF9ng+R31rizwslk X-Received: by 2002:a05:620a:563a:b0:785:44ea:97b0 with SMTP id vv26-20020a05620a563a00b0078544ea97b0mr9220023qkn.72.1707082918894; Sun, 04 Feb 2024 13:41:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707082918; cv=none; d=google.com; s=arc-20160816; b=Ot/0VgSjjmV5FikM/ceUHa8pxlD+E1LhjhZKsd4mmbq7l3jVEoytsVW8cEprdwUQd8 OjZ9nU5zerkcG0GyUP4ZIan7/hlkVIzp3ka5mHD3J6xNf+PyylbxdWBBaG81kZxFtlHl Dej0LhKEoUrQ/vemQsUg3sIaSxKBcRh6BS+MhbczDR6bXJIBegsrj2rNLn3vYOiKg78v nuBrVoIDkjZnm8Je9fRSPS4aKMvtaSVWJEq03hf44OocIqKIHWCm6Titxt+hpqbvBcem ow3C/X6McKz5LwOZZgTd+A87ns9GQtekl9IdXzfaEv0H38UVew/u0bentkYILTLmM9Qv l6yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+2xt3v9hngTFbwI41n9Aj+nylg/m+N+vO+1fc4NZ/KE=; fh=QqjgsFQEy8JDhs79bgQfB/Mx1q9f1lkKaEQFrxVH47k=; b=iTEc3A1zLss1cfbJP35hFo8H0W4Ut40754MQXx5xTla/26D6XmUZDOz6PtlK5X3dl8 LstfF4Bl+lhyNQWbzFUZUVYT2fBtMM6tJ04ZBXK/svsUDY6RcNVy8CEQ9AonFi4qaV+7 DAb1FtXTlujx2eKtWaAf3gR1KkN+/VJ/RYVKKxOOpRlHRAiU+R7yQNiYDe8piZG4Eo4K w4art98RIZFZnTSPQFRZ3t2xYfQyyjuH8iBDKoMoMP6zVs4geJoZyTwcHmXbYBWzR/Mh n/uxt4baRquP4m+R788qix6Hj3WoDpBqZ+VsLbJPAB0zwkIJsMbvDeHKK108vwsUWXps vzuA==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L1CJLyLO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCWLI4R8ltxYEdm+bypuJt43Jn51Go62jyXs91msGHId8uFW4vtgfD/k2UiSozSAB2imRVzDRYjZd4EF8v8B563j Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j6-20020a37ef06000000b00784023a4545si6963694qkk.680.2024.02.04.13.41.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:41:58 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L1CJLyLO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkEY-00020I-Ii; Sun, 04 Feb 2024 16:41:02 -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 1rWkEX-000203-Tz for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:01 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkEW-0003US-8f for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:01 -0500 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1d74045c463so29331815ad.3 for ; Sun, 04 Feb 2024 13:40:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082859; x=1707687659; 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=+2xt3v9hngTFbwI41n9Aj+nylg/m+N+vO+1fc4NZ/KE=; b=L1CJLyLOL8xuN5b59GI+Nscww4WKGYBIbCIiJBJfvu+1hLJO2LiSIPNZhZFZ9hv3XH yClFCRFo0ZhE0DQ8q0GxA65rfyInEn9tWFVN1lnXQmAzRs1DzdaKG3y8K8yYuNmrsG+M +YVbNvJBc5sAZmxDKelbY68aFF5UQzpDUYNehMQCr8Zawfs7tSjhKawLxffbDJePda4V rYl/kzE7nnLLnUc0RwsY3wBMjpEBVniu7BqegR1BjXc9mcPpwhmG9v5oabQ4oiF6KleM FkR2SZgZBCyZJNYcA+ynEWgjM0RxwSnNbmwU4FRH/Ni1ll9GQKj1Z1K6ic7GF16dhcCs 7+bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082859; x=1707687659; 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=+2xt3v9hngTFbwI41n9Aj+nylg/m+N+vO+1fc4NZ/KE=; b=Pp8gLHwyZlGy+51AISnXejRUSkrPwClud8vd4VRm0JndD2OFiYi2cvFThnR+EAL1Zl LKY8QMEI66lJ08R0XZpXMksCl/eI6ROTlfivxCCAKxBX50QZK8C/2QhIPna0hLn3UT9e TUp/9sn4cf4QUpO2lU2l9SR2vbstPpe0VYM3MkKCpgT0FH/VQKfCvO+u9/7jUAUpAved 8JQqb4ZorC+k/yJoEs7RYCb+KFyenv1dJBjwrKYk6G/9SRjdZVJuDOw/QWis2j2tXU7G Jp8sxKUO13seJGALzacWNUmls2agbcnp0MCrlu1STm5GQafyLyXJRtxFZDBaFTJJVTQM 3G/g== X-Gm-Message-State: AOJu0YzIOa+k27tHjIYTj4B2cQmOMXpoyMw1ZMSZlf7+NEyFTLd3SeV2 FZKwwrXobv9AcQt6F0eQn4COLKD1JDQW2txQM4LvpyJ/+ftTwsNzeExMcjAVhJmoT/2p+1p1rwI CaVM= X-Received: by 2002:a17:902:f551:b0:1d9:95c5:296e with SMTP id h17-20020a170902f55100b001d995c5296emr3751432plf.53.1707082858825; Sun, 04 Feb 2024 13:40:58 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.40.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:40:58 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 01/39] tcg: Introduce TCG_COND_TST{EQ,NE} Date: Mon, 5 Feb 2024 07:40:14 +1000 Message-Id: <20240204214052.5639-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Add the enumerators, adjust the helpers to match, and dump. Not supported anywhere else just yet. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- include/tcg/tcg-cond.h | 74 ++++++++++++++++++++++++++++++------------ tcg/tcg.c | 4 ++- docs/devel/tcg-ops.rst | 2 ++ 3 files changed, 58 insertions(+), 22 deletions(-) diff --git a/include/tcg/tcg-cond.h b/include/tcg/tcg-cond.h index 2a38a386d4..5cadbd6ff2 100644 --- a/include/tcg/tcg-cond.h +++ b/include/tcg/tcg-cond.h @@ -29,26 +29,34 @@ * Conditions. Note that these are laid out for easy manipulation by * the functions below: * bit 0 is used for inverting; - * bit 1 is signed, - * bit 2 is unsigned, - * bit 3 is used with bit 0 for swapping signed/unsigned. + * bit 1 is used for conditions that need swapping (signed/unsigned). + * bit 2 is used with bit 1 for swapping. + * bit 3 is used for unsigned conditions. */ typedef enum { /* non-signed */ TCG_COND_NEVER = 0 | 0 | 0 | 0, TCG_COND_ALWAYS = 0 | 0 | 0 | 1, + + /* equality */ TCG_COND_EQ = 8 | 0 | 0 | 0, TCG_COND_NE = 8 | 0 | 0 | 1, + + /* "test" i.e. and then compare vs 0 */ + TCG_COND_TSTEQ = 8 | 4 | 0 | 0, + TCG_COND_TSTNE = 8 | 4 | 0 | 1, + /* signed */ TCG_COND_LT = 0 | 0 | 2 | 0, TCG_COND_GE = 0 | 0 | 2 | 1, - TCG_COND_LE = 8 | 0 | 2 | 0, - TCG_COND_GT = 8 | 0 | 2 | 1, + TCG_COND_GT = 0 | 4 | 2 | 0, + TCG_COND_LE = 0 | 4 | 2 | 1, + /* unsigned */ - TCG_COND_LTU = 0 | 4 | 0 | 0, - TCG_COND_GEU = 0 | 4 | 0 | 1, - TCG_COND_LEU = 8 | 4 | 0 | 0, - TCG_COND_GTU = 8 | 4 | 0 | 1, + TCG_COND_LTU = 8 | 0 | 2 | 0, + TCG_COND_GEU = 8 | 0 | 2 | 1, + TCG_COND_GTU = 8 | 4 | 2 | 0, + TCG_COND_LEU = 8 | 4 | 2 | 1, } TCGCond; /* Invert the sense of the comparison. */ @@ -60,25 +68,49 @@ static inline TCGCond tcg_invert_cond(TCGCond c) /* Swap the operands in a comparison. */ static inline TCGCond tcg_swap_cond(TCGCond c) { - return c & 6 ? (TCGCond)(c ^ 9) : c; + return (TCGCond)(c ^ ((c & 2) << 1)); } -/* Create an "unsigned" version of a "signed" comparison. */ -static inline TCGCond tcg_unsigned_cond(TCGCond c) +/* Must a comparison be considered signed? */ +static inline bool is_signed_cond(TCGCond c) { - return c & 2 ? (TCGCond)(c ^ 6) : c; -} - -/* Create a "signed" version of an "unsigned" comparison. */ -static inline TCGCond tcg_signed_cond(TCGCond c) -{ - return c & 4 ? (TCGCond)(c ^ 6) : c; + return (c & (8 | 2)) == 2; } /* Must a comparison be considered unsigned? */ static inline bool is_unsigned_cond(TCGCond c) { - return (c & 4) != 0; + return (c & (8 | 2)) == (8 | 2); +} + +/* Must a comparison be considered a test? */ +static inline bool is_tst_cond(TCGCond c) +{ + return (c | 1) == TCG_COND_TSTNE; +} + +/* Create an "unsigned" version of a "signed" comparison. */ +static inline TCGCond tcg_unsigned_cond(TCGCond c) +{ + return is_signed_cond(c) ? (TCGCond)(c + 8) : c; +} + +/* Create a "signed" version of an "unsigned" comparison. */ +static inline TCGCond tcg_signed_cond(TCGCond c) +{ + return is_unsigned_cond(c) ? (TCGCond)(c - 8) : c; +} + +/* Create the eq/ne version of a tsteq/tstne comparison. */ +static inline TCGCond tcg_tst_eqne_cond(TCGCond c) +{ + return is_tst_cond(c) ? (TCGCond)(c - 4) : c; +} + +/* Create the lt/ge version of a tstne/tsteq comparison of the sign. */ +static inline TCGCond tcg_tst_ltge_cond(TCGCond c) +{ + return is_tst_cond(c) ? (TCGCond)(c ^ 0xf) : c; } /* @@ -92,7 +124,7 @@ static inline TCGCond tcg_high_cond(TCGCond c) case TCG_COND_LE: case TCG_COND_GEU: case TCG_COND_LEU: - return (TCGCond)(c ^ 8); + return (TCGCond)(c ^ (4 | 1)); default: return c; } diff --git a/tcg/tcg.c b/tcg/tcg.c index eeff4c1d51..eeeb9b0c70 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2482,7 +2482,9 @@ static const char * const cond_name[] = [TCG_COND_LTU] = "ltu", [TCG_COND_GEU] = "geu", [TCG_COND_LEU] = "leu", - [TCG_COND_GTU] = "gtu" + [TCG_COND_GTU] = "gtu", + [TCG_COND_TSTEQ] = "tsteq", + [TCG_COND_TSTNE] = "tstne", }; static const char * const ldst_name[(MO_BSWAP | MO_SSIZE) + 1] = diff --git a/docs/devel/tcg-ops.rst b/docs/devel/tcg-ops.rst index 8ae59ea02b..d46b625e0e 100644 --- a/docs/devel/tcg-ops.rst +++ b/docs/devel/tcg-ops.rst @@ -253,6 +253,8 @@ Jumps/Labels | ``TCG_COND_GEU /* unsigned */`` | ``TCG_COND_LEU /* unsigned */`` | ``TCG_COND_GTU /* unsigned */`` + | ``TCG_COND_TSTEQ /* t1 & t2 == 0 */`` + | ``TCG_COND_TSTNE /* t1 & t2 != 0 */`` Arithmetic ---------- From patchwork Sun Feb 4 21:40:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769854 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842139wrc; Sun, 4 Feb 2024 13:42:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IE/zHV3bQ+4TdxNjFLjscu59ztrVMI9WYvyNhKddDHFlOPIzl4NXgjgS56c1xNCnuAFyZWK X-Received: by 2002:ac8:44cd:0:b0:42c:1170:1cf0 with SMTP id b13-20020ac844cd000000b0042c11701cf0mr4866487qto.2.1707082951951; Sun, 04 Feb 2024 13:42:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707082951; cv=none; d=google.com; s=arc-20160816; b=y0TTFoqCGZTrA4PvrIRM0cogD3Ek/8vEdDMcmhfwkPNTx7U3W2vdVe5r9fQ41oU28l L+zbHWM6vpsQ136c1IyK28dSrRjUT2YUXTcfeZcS7Bd4RpgtbPnlj+JQJ+QLvJi7q80n LnqMolECnJIsRhmOaXEhJ4DUwNkd4yJMY87Y19Izf/w5Vq+ysrG3aPSDgzPQRtMuTKHz LvRmwKpzo/q/xjGhNPsUawTKNuAMLcEjCHcmXbHnh6b7j/JiAhqCPhys2UtfXaCsORe6 Km3LbFMoPFk3Fgo4XwbFa9WJN8dWsbC7T1pYPL1b1uWEYpytzydgrUAPGu9o/tKPLziu bfvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Vr5ZAc/RjPXfmKZRK62DlWwG7Va6xrXif7VnM9K+hHM=; fh=SdPhO4UFBpLn8slodPsbMX6Sh1TkdztIERsOYEe3aPo=; b=mG3LLa/jCvQ8E0U84eI39bYzPkdwFt21zQ1TCDVK30ECMgVUhNIcU/sKLTxSqU6hfJ Fhvtjnt7GX2T+kY6VZZPENCwXt4v9SR+cYrE/ClpDcWIzYDB1p7rpW199/GK8BbK1I7L VGdoeuhA3yZ3qtvy5mTk6EeAhuC446bgi3etOoULd+kIhV0EYWf6nzk1GZfiPIb2V5bl F/bp4hQBNhWUt452Mym2B36Xks+CGScOZmbc4lF5s/ux5w9xpUVYFCN0Qgdt5Vd9nsH7 IVsmPQ8XWYFqAiPNiInryahTcDw7JGFEoCtxx6RNFeqDOJ3RAoDySXC9VQZFDbwU27sZ 7Jrg==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Bsy/aPQE"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCWP9l5R1YIV4+tMyV3AHM1EVKq+2GM6bBshNoamnIIvNldYDNsiQl94COmcKripwZrt4OVYyQMWRRMX8KeOvTkw Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v4-20020a05622a014400b0042bee3b375esi7388089qtw.10.2024.02.04.13.42.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:42:31 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Bsy/aPQE"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkEc-000216-1i; Sun, 04 Feb 2024 16:41:06 -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 1rWkEa-00020p-8e for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:04 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkEY-0003Ug-K1 for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:04 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d9bd8fa49eso664925ad.1 for ; Sun, 04 Feb 2024 13:41:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082861; x=1707687661; 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=Vr5ZAc/RjPXfmKZRK62DlWwG7Va6xrXif7VnM9K+hHM=; b=Bsy/aPQEcr4pBLQG/x0WxXKTHkwRI1/q0jnghxEJnHDdlOYcsPJ6wHtYO/ZMRf0Jwl c8l14jz7bmKs/FoDn3Xj3ekBD6Uhl9z/Mnz6hreCiegKOXhojZkdnO6mA0G5eIuzu9GI +OIHhD80ikWXLk72Fq4Jq+b05+WqpgFLLo37daZFMlwxmebUpkTEvDW3n2dmYV4+F3S3 Udvd7k8H/lYyxanUx4fXGR3yBYLoZw+Dsckh6Psc1aWlTN/T/qCuN1ZuWqVqKc7BYQth pxELiIO+WaBlmTcHtHbmmL0OEz7A7zmk488A00Q/L8kv8MbtWH6CHi1BdWxOdLFttcAs aYyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082861; x=1707687661; 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=Vr5ZAc/RjPXfmKZRK62DlWwG7Va6xrXif7VnM9K+hHM=; b=DfHo3IRkcvWgFfoVjUsfMoPnb475c1LH4Ydr1+rmm7u/2WI+Z0d1i/hGWYzhMEjCXY su3cxaTO1UxID09e0HKuBgT/54+3FIYV3gG8vIkc7qCmGnJ1fO6FAQzn3NWX72qP2PgR jkoZskIEnzIquuQg0oAkCkxAXfQByaJrkZoO8df6reOHXw+h5XmNqibuw3I41DulxDuO aBk+J72nYBWLF/el7mw2p6TwiJ2zCDbkeWWyCcyuZFNvUllh7J3LV/XSq1gNlEjm5GBm E/gqTsGblIb6BJ1GG5pb1dkCVtqTiB8WyLU79QQVyQLoxTetvc6kY8WYTzzmx5xP0Dnf g0hw== X-Gm-Message-State: AOJu0YwYu532eeIFHsjMqPSMcbj9nAcJZ6H1REKcc6cp5RSFFPlSf3mA +Q5KGzYMfbskcVH548PwzuPTWGtydjDSV/716mp1x9kY6JzFCtoVJHaSW0Gb+aXaM9KWVXeH/0B ppfg= X-Received: by 2002:a17:903:120c:b0:1d7:35ba:6a39 with SMTP id l12-20020a170903120c00b001d735ba6a39mr7574018plh.69.1707082861092; Sun, 04 Feb 2024 13:41:01 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.40.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 02/39] tcg: Introduce TCG_TARGET_HAS_tst Date: Mon, 5 Feb 2024 07:40:15 +1000 Message-Id: <20240204214052.5639-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Define as 0 for all tcg backends. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.h | 2 ++ tcg/arm/tcg-target.h | 2 ++ tcg/i386/tcg-target.h | 2 ++ tcg/loongarch64/tcg-target.h | 2 ++ tcg/mips/tcg-target.h | 2 ++ tcg/ppc/tcg-target.h | 2 ++ tcg/riscv/tcg-target.h | 2 ++ tcg/s390x/tcg-target.h | 2 ++ tcg/sparc64/tcg-target.h | 2 ++ tcg/tci/tcg-target.h | 2 ++ 10 files changed, 20 insertions(+) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index 33f15a564a..b4ac13be7b 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -138,6 +138,8 @@ typedef enum { #define TCG_TARGET_HAS_qemu_ldst_i128 1 #endif +#define TCG_TARGET_HAS_tst 0 + #define TCG_TARGET_HAS_v64 1 #define TCG_TARGET_HAS_v128 1 #define TCG_TARGET_HAS_v256 0 diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index a712cc80ad..7bf42045a7 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -125,6 +125,8 @@ extern bool use_neon_instructions; #define TCG_TARGET_HAS_qemu_ldst_i128 0 +#define TCG_TARGET_HAS_tst 0 + #define TCG_TARGET_HAS_v64 use_neon_instructions #define TCG_TARGET_HAS_v128 use_neon_instructions #define TCG_TARGET_HAS_v256 0 diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index fa34deec47..1dd917a680 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -198,6 +198,8 @@ typedef enum { #define TCG_TARGET_HAS_qemu_ldst_i128 \ (TCG_TARGET_REG_BITS == 64 && (cpuinfo & CPUINFO_ATOMIC_VMOVDQA)) +#define TCG_TARGET_HAS_tst 0 + /* We do not support older SSE systems, only beginning with AVX1. */ #define TCG_TARGET_HAS_v64 have_avx1 #define TCG_TARGET_HAS_v128 have_avx1 diff --git a/tcg/loongarch64/tcg-target.h b/tcg/loongarch64/tcg-target.h index 9c70ebfefc..fede627bf7 100644 --- a/tcg/loongarch64/tcg-target.h +++ b/tcg/loongarch64/tcg-target.h @@ -169,6 +169,8 @@ typedef enum { #define TCG_TARGET_HAS_qemu_ldst_i128 (cpuinfo & CPUINFO_LSX) +#define TCG_TARGET_HAS_tst 0 + #define TCG_TARGET_HAS_v64 0 #define TCG_TARGET_HAS_v128 (cpuinfo & CPUINFO_LSX) #define TCG_TARGET_HAS_v256 0 diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index b98ffae1d0..a996aa171d 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -194,6 +194,8 @@ extern bool use_mips32r2_instructions; #define TCG_TARGET_HAS_qemu_ldst_i128 0 +#define TCG_TARGET_HAS_tst 0 + #define TCG_TARGET_DEFAULT_MO 0 #define TCG_TARGET_NEED_LDST_LABELS #define TCG_TARGET_NEED_POOL_LABELS diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index 5295e4f9ab..60ce49e672 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -143,6 +143,8 @@ typedef enum { #define TCG_TARGET_HAS_qemu_ldst_i128 \ (TCG_TARGET_REG_BITS == 64 && have_isa_2_07) +#define TCG_TARGET_HAS_tst 0 + /* * While technically Altivec could support V64, it has no 64-bit store * instruction and substituting two 32-bit stores makes the generated diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index a4edc3dc74..2c1b680b93 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -158,6 +158,8 @@ extern bool have_zbb; #define TCG_TARGET_HAS_qemu_ldst_i128 0 +#define TCG_TARGET_HAS_tst 0 + #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_NEED_LDST_LABELS diff --git a/tcg/s390x/tcg-target.h b/tcg/s390x/tcg-target.h index e69b0d2ddd..53bed8c8d2 100644 --- a/tcg/s390x/tcg-target.h +++ b/tcg/s390x/tcg-target.h @@ -138,6 +138,8 @@ extern uint64_t s390_facilities[3]; #define TCG_TARGET_HAS_qemu_ldst_i128 1 +#define TCG_TARGET_HAS_tst 0 + #define TCG_TARGET_HAS_v64 HAVE_FACILITY(VECTOR) #define TCG_TARGET_HAS_v128 HAVE_FACILITY(VECTOR) #define TCG_TARGET_HAS_v256 0 diff --git a/tcg/sparc64/tcg-target.h b/tcg/sparc64/tcg-target.h index f8cf145266..ae2910c4ee 100644 --- a/tcg/sparc64/tcg-target.h +++ b/tcg/sparc64/tcg-target.h @@ -149,6 +149,8 @@ extern bool use_vis3_instructions; #define TCG_TARGET_HAS_qemu_ldst_i128 0 +#define TCG_TARGET_HAS_tst 0 + #define TCG_AREG0 TCG_REG_I0 #define TCG_TARGET_DEFAULT_MO (0) diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index 2a13816c8e..609b2f4e4a 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -117,6 +117,8 @@ #define TCG_TARGET_HAS_qemu_ldst_i128 0 +#define TCG_TARGET_HAS_tst 0 + /* Number of registers available. */ #define TCG_TARGET_NB_REGS 16 From patchwork Sun Feb 4 21:40:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769845 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1841987wrc; Sun, 4 Feb 2024 13:41:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IHI5ilpBauo12VBhY+Bk8KTTUNhlW1eKh8WNRdi6iidEoPYt/XKgNstH5WFFElfgTkpdTPA X-Received: by 2002:a05:620a:34d:b0:783:3c61:27e4 with SMTP id t13-20020a05620a034d00b007833c6127e4mr8438510qkm.55.1707082904613; Sun, 04 Feb 2024 13:41:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707082904; cv=none; d=google.com; s=arc-20160816; b=OATzIZ3KklVaHcaBHkPlp/hf+WrMDbq+VTtiwPfSW2rIzUOyuv/ZvCVg1bKkfLwGLs l/eBZ/DUt4pJttYNIzp/A5vKrpLUMDBoQwi4RGqYp8bBdbjfDkKFGmcsR/7yZ09oTtop udKIuqKk5326W8t4uYS4oogGud9CEhWohnLy3HukRQUTFhs2oK6LnpktyXVf4Xi1OD6R x+OoCwP9ehIKUW8x7LCDcUsBIhxSREmpxzhADqSxhiDnxhDrnf74GEy77FQoEC4m5ILn q4mPJz/EPz9xtWfKKEMP+QrvBNG694B5ZliSPsWy/5FUPA6lWjvzOFXI6ZAeTZajlB2k RzAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XRwgTLH7x4qjGJwvWHPC6iD3rpKsmYUOnQgcGsFZM2o=; fh=zGi9v9UquKnvOdj6VKX/KayQNnQ5zfVaiRtWMyrtFYA=; b=A4b/tRlDXB6gQApImyJzg0Q3kLPDZFDiyqwZpRHNlA1iuF1ZdigNjwWTrcgDtKkKP+ +MYQcd1LNzhz7pd2EUmo4yUCrBRIEKQHXmQPlXIIQiJ77J2d8/A4xT3XXp8hoTNuRTQy 6H81RcRT5p1cqVioJMRZrhaS7EyJD6dmp8Drhx5jscl97qcmF2CE1/NWW4+16lngePVA 6Q9c/1HyZ6xBZwMuLOnqAdcn6iQgd89IfhgnaiE0oipZzOVpo8PPi3qdLdwK3VeF9plG gpyEc751jz8tjg1RER3LHq+UwP+uKnDgx3Liq1NnvlwqGP3y/NR0hs8xvEF0TK9quoTV 7/TA==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uBW8IHuq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCUBLZbKN0Z4qHUJsdKikvFSGaExCUEyAQK+GYuvmO6fOxEjQ88AHI9sxhfybms5HAuCeSvEc781m0TnrH+Bxnk3 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l25-20020a05620a211900b007855ec73a92si5097810qkl.635.2024.02.04.13.41.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:41:44 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uBW8IHuq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkEk-00022P-HB; Sun, 04 Feb 2024 16:41: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 1rWkEd-00021b-2a for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:07 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkEa-0003Us-JC for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:05 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1d746856d85so27597875ad.0 for ; Sun, 04 Feb 2024 13:41:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082863; x=1707687663; 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=uBW8IHuqRwly/Aj6D2IGvXNk2hLAALkGiWqjZzK4dWmH5ZtyiItzGW7hSLpgtdBxKm Jhzf1eorGyeH1c9gvSeroHi+UI+U5oLYtD/dRrYcYGuY1SozxLxQVTOFipWxpknWm7de eS3J35OrAwbYUqUqaB2K7LH668lsGWELf+6gf/duGHT/cvmQqZCrW0QQwDjj/Zf7C2n0 ZnM7kjGokUcKPuDWLVELyJErmFyaD+Ug6l1B5fl3K3/CjDfMo9TYMc4/TEvIXlfg1vUG 9gtkabZmaH8EWH/XrblhDi6FvD5do3f7U/7sH2RRBF5SUNJlflrQTv0TZ1Z8N5VQ8Iyu R4ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082863; x=1707687663; 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=GVOyDl4nLPURxcmrkwmFcaAuHTdVTkcb79mSQmxrSSd/JWMW3v2N+5i5poWbxq20Qt NHjGUBcnzN4gKoi3sG/eqxcdFZuHN+gef9jtDbSKM0HDQD48m9HVOQ1/BA0YM7WF3Kvo buf3CF39wJuvWWJA14t/BU5QzgN36z3PMUnnuKbQHhQ1ZSDuksDTG1KrDEZrqG9s4lZm +kF4cFkJNBteAttI0UNT5CmW0wlCGKeuFzPv05GtFCXlCjOC2h1NExVaqZGw3eOqS02b C75u9jTM82HPwJaO8rA0clQY8UZg5r8nIX/4WMAqo7IfuQefCWnTPFaoUSyHmqKlk4tO 4u7g== X-Gm-Message-State: AOJu0YxU2avhzrv1lofKBhUyaweGoLPiofdveGKXWjuTExhyS3z86MaV UnIODfuBB7JW/u8vTwyqbGz76QM1aOevDhmznmus/BE6KMwEXKnS9R520aOpqUZK0+gI6gaLmNd Yrhc= X-Received: by 2002:a17:902:d905:b0:1d4:e237:2c3f with SMTP id c5-20020a170902d90500b001d4e2372c3fmr6042973plz.28.1707082863123; Sun, 04 Feb 2024 13:41:03 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 03/39] tcg/optimize: Split out arg_is_const_val Date: Mon, 5 Feb 2024 07:40:16 +1000 Message-Id: <20240204214052.5639-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/optimize.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index f2d01654c5..73019b9996 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -124,11 +124,22 @@ static inline bool ts_is_const(TCGTemp *ts) return ts_info(ts)->is_const; } +static inline bool ts_is_const_val(TCGTemp *ts, uint64_t val) +{ + TempOptInfo *ti = ts_info(ts); + return ti->is_const && ti->val == val; +} + static inline bool arg_is_const(TCGArg arg) { return ts_is_const(arg_temp(arg)); } +static inline bool arg_is_const_val(TCGArg arg, uint64_t val) +{ + return ts_is_const_val(arg_temp(arg), val); +} + static inline bool ts_is_copy(TCGTemp *ts) { return ts_info(ts)->next_copy != ts; @@ -689,7 +700,7 @@ static int do_constant_folding_cond(TCGType type, TCGArg x, } } else if (args_are_copies(x, y)) { return do_constant_folding_cond_eq(c); - } else if (arg_is_const(y) && arg_info(y)->val == 0) { + } else if (arg_is_const_val(y, 0)) { switch (c) { case TCG_COND_LTU: return 0; @@ -954,7 +965,7 @@ static bool fold_to_not(OptContext *ctx, TCGOp *op, int idx) /* If the binary operation has first argument @i, fold to @i. */ static bool fold_ix_to_i(OptContext *ctx, TCGOp *op, uint64_t i) { - if (arg_is_const(op->args[1]) && arg_info(op->args[1])->val == i) { + if (arg_is_const_val(op->args[1], i)) { return tcg_opt_gen_movi(ctx, op, op->args[0], i); } return false; @@ -963,7 +974,7 @@ static bool fold_ix_to_i(OptContext *ctx, TCGOp *op, uint64_t i) /* If the binary operation has first argument @i, fold to NOT. */ static bool fold_ix_to_not(OptContext *ctx, TCGOp *op, uint64_t i) { - if (arg_is_const(op->args[1]) && arg_info(op->args[1])->val == i) { + if (arg_is_const_val(op->args[1], i)) { return fold_to_not(ctx, op, 2); } return false; @@ -972,7 +983,7 @@ static bool fold_ix_to_not(OptContext *ctx, TCGOp *op, uint64_t i) /* If the binary operation has second argument @i, fold to @i. */ static bool fold_xi_to_i(OptContext *ctx, TCGOp *op, uint64_t i) { - if (arg_is_const(op->args[2]) && arg_info(op->args[2])->val == i) { + if (arg_is_const_val(op->args[2], i)) { return tcg_opt_gen_movi(ctx, op, op->args[0], i); } return false; @@ -981,7 +992,7 @@ static bool fold_xi_to_i(OptContext *ctx, TCGOp *op, uint64_t i) /* If the binary operation has second argument @i, fold to identity. */ static bool fold_xi_to_x(OptContext *ctx, TCGOp *op, uint64_t i) { - if (arg_is_const(op->args[2]) && arg_info(op->args[2])->val == i) { + if (arg_is_const_val(op->args[2], i)) { return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[1]); } return false; @@ -990,7 +1001,7 @@ static bool fold_xi_to_x(OptContext *ctx, TCGOp *op, uint64_t i) /* If the binary operation has second argument @i, fold to NOT. */ static bool fold_xi_to_not(OptContext *ctx, TCGOp *op, uint64_t i) { - if (arg_is_const(op->args[2]) && arg_info(op->args[2])->val == i) { + if (arg_is_const_val(op->args[2], i)) { return fold_to_not(ctx, op, 1); } return false; @@ -1223,8 +1234,8 @@ static bool fold_brcond2(OptContext *ctx, TCGOp *op) * Simplify LT/GE comparisons vs zero to a single compare * vs the high word of the input. */ - if (arg_is_const(op->args[2]) && arg_info(op->args[2])->val == 0 && - arg_is_const(op->args[3]) && arg_info(op->args[3])->val == 0) { + if (arg_is_const_val(op->args[2], 0) && + arg_is_const_val(op->args[3], 0)) { goto do_brcond_high; } break; @@ -1448,9 +1459,7 @@ static bool fold_deposit(OptContext *ctx, TCGOp *op) } /* Inserting a value into zero at offset 0. */ - if (arg_is_const(op->args[1]) - && arg_info(op->args[1])->val == 0 - && op->args[3] == 0) { + if (arg_is_const_val(op->args[1], 0) && op->args[3] == 0) { uint64_t mask = MAKE_64BIT_MASK(0, op->args[4]); op->opc = and_opc; @@ -1461,8 +1470,7 @@ static bool fold_deposit(OptContext *ctx, TCGOp *op) } /* Inserting zero into a value. */ - if (arg_is_const(op->args[2]) - && arg_info(op->args[2])->val == 0) { + if (arg_is_const_val(op->args[2], 0)) { uint64_t mask = deposit64(-1, op->args[3], op->args[4], 0); op->opc = and_opc; @@ -2000,8 +2008,8 @@ static bool fold_setcond2(OptContext *ctx, TCGOp *op) * Simplify LT/GE comparisons vs zero to a single compare * vs the high word of the input. */ - if (arg_is_const(op->args[3]) && arg_info(op->args[3])->val == 0 && - arg_is_const(op->args[4]) && arg_info(op->args[4])->val == 0) { + if (arg_is_const_val(op->args[3], 0) && + arg_is_const_val(op->args[4], 0)) { goto do_setcond_high; } break; From patchwork Sun Feb 4 21:40:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769882 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842849wrc; Sun, 4 Feb 2024 13:46:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IEx8XGsyKUVtvXCozpPz+B5b78ogMeCtFk29TQver4/9LVUwF/2G6BvCUdh5zmJyn/N2ZVT X-Received: by 2002:a05:622a:a00b:b0:42c:1fa3:ffd3 with SMTP id jt11-20020a05622aa00b00b0042c1fa3ffd3mr1808937qtb.64.1707083177312; Sun, 04 Feb 2024 13:46:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083177; cv=none; d=google.com; s=arc-20160816; b=khnMjz9QdFzcvilT/Bh1t/FLjFFD9GG+oLjQaf1LRx37J2R47RgGiQ2VviE0QJepiI NQ0WM1STh21SaNx/AMnEVB++TZ1kjU/9sdS6GfMomP9ExMa3NAeBbnu3IgAF5YOaneTG CpODbn/9PV5Y/rueFhtbhv2624QGtiCtzS8RLuIOHTwQ+Tkza2LiG4x2ag56Rx5Xd/gu 3CRc/FVvSAPDTmBTfjpTbji0SdhN7TM02Mrsc0QBxzYm84kH2hmfBPAI9LG8D7IYgr3/ h8pvXZ5KWS5nUHetpizrlLQumf3RgB9J/rMTVPdY0k1/Ks/Rq2Zd9SrUY4RoMOOPD6B4 CeEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rCOb1ACImxEyjzPr7SpomivAS+ARwGZqu81A17yuvPw=; fh=l9zW/tl4YkwYRoLJKLzEui4+p8IlXsEcU3eDO3a4Res=; b=tRhXxjs6xRmeimY95MHTdZMnRaKAfSr+kVXLJxG2zKAq86/IP/Xff1sbMUTGAXCV0v 5PEwDeJ2We0IjJr71Uc6VLGboCgXC1F1lz5vX7PpSnFLZui4IV+0cK/soDMlqyfHG8HW ejyvczmqC8qbOamk5VPz8JSQg51CexG7dlKlIUaTgmJ+8N75v0VEQz2dJGbQBHTJCALr mUkvs2DWYxro3jtzV8BG1GYPrR9XcQ30ctkemQXysd+276KAWBhuPp/pFEocR735X8My 9h56/sFORsDm8hG4EJVwdgrbkMxEO9w4gxFwOGqwuD279VLdOBq4P98+I2vrLOSSAy0n oL2w==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zGWpGWIO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCVuNRttEOyDyKuWsMGFqsqTtLTdseH7VR9f0y+uswO+Xo0MKMQmHCcNK+Zsaw6N5P/vDMIW7GcidePsFtOCkIp5 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a13-20020a05622a064d00b0042a83f2cb61si7338818qtb.72.2024.02.04.13.46.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:46:17 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zGWpGWIO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkEo-000237-5s; Sun, 04 Feb 2024 16:41: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 1rWkEe-00021k-B5 for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:12 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkEc-0003V4-OK for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:08 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1d8aadc624dso28244155ad.0 for ; Sun, 04 Feb 2024 13:41:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082865; x=1707687665; 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=zGWpGWIOOa+A83MIp4yQ6zsLh4cl206ZIRXifP8eX6UVIRyKrpE8Vu0QsfNBwngWe8 WNIkVLoJdE27SZTKjqIZSTmlhwsa6gHjBFouxxribFTfIVoAwDkcAfc24LsIvUn1BNVJ dcHghuz8wRWORv+oT2sYWxUwPklwGZ65KcHlFf3bwjnkwNDXKyghlc6UZgyEQK2y1Vc3 Y1xvjh3VPdziLxjk1Qtp9pUXtD4Qc7QmUdSwN5bTd7tXoRsdBP3taDnKf0zC5AMc/I4o HlDu2cNtaQScF4sDT9YWzQNIQD723SsHo4xsDwb4k7lJAxVp5BKk+Be8X1yHuB8ZZKbe Q2pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082865; x=1707687665; 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=jC1etv/wI6lCOHE0No0bfsg+X2xCOruwVOox5WRZ7gvEVI/obXrOkGnnDq+lNBXzbC qjAagV1FAd80f3MfChUVUDHC/24Z7AQ2eIjfgsujiLPUK9u4GZxxcZKP47Lrol7ewvPp idFKZgcOmr4APVBz7lk7RjMEnKtpyHV79Dj3UNpxAr/PELftNsKXKlDVO3f5Zp6UgWJH 8nWALsMXZnzPh42iONRv03Ixv9WlW2L5GbLOmrZ6gk9aXO2kV6elwfVssVGr69qq3hC3 Is0iLTi7U/JIFBfEPYfc2l86/yi6cdV8BAX8dFDSbb2RFIJbAfJrDtanRxDKE3RuVhcu m8Lw== X-Gm-Message-State: AOJu0YznWbqsSSy7aJh5x5XFySzmwrACx4TmfRYLl0ZJ5PQ1J3Lz7vIo 750Ej5EmBNMYnb9L3XyyaBTHhVJife0AYE8SqZSvSKQSV6Gr0aXNjOFgi1ghcC8VdtA4WQ9X+QZ Kseg= X-Received: by 2002:a17:902:f681:b0:1d9:a50f:90eb with SMTP id l1-20020a170902f68100b001d9a50f90ebmr2284593plg.38.1707082865182; Sun, 04 Feb 2024 13:41:05 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 04/39] tcg/optimize: Split out do_constant_folding_cond1 Date: Mon, 5 Feb 2024 07:40:17 +1000 Message-Id: <20240204214052.5639-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Handle modifications to the arguments and condition in a single place. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/optimize.c | 57 ++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 73019b9996..9c04dba099 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -796,6 +796,23 @@ static bool swap_commutative2(TCGArg *p1, TCGArg *p2) return false; } +static int do_constant_folding_cond1(OptContext *ctx, TCGArg dest, + TCGArg *p1, TCGArg *p2, TCGArg *pcond) +{ + TCGCond cond; + bool swap; + int r; + + swap = swap_commutative(dest, p1, p2); + cond = *pcond; + if (swap) { + *pcond = cond = tcg_swap_cond(cond); + } + + r = do_constant_folding_cond(ctx->type, *p1, *p2, cond); + return r; +} + static void init_arguments(OptContext *ctx, TCGOp *op, int nb_args) { for (int i = 0; i < nb_args; i++) { @@ -1193,14 +1210,8 @@ static bool fold_andc(OptContext *ctx, TCGOp *op) static bool fold_brcond(OptContext *ctx, TCGOp *op) { - TCGCond cond = op->args[2]; - int i; - - if (swap_commutative(NO_DEST, &op->args[0], &op->args[1])) { - op->args[2] = cond = tcg_swap_cond(cond); - } - - i = do_constant_folding_cond(ctx->type, op->args[0], op->args[1], cond); + int i = do_constant_folding_cond1(ctx, NO_DEST, &op->args[0], + &op->args[1], &op->args[2]); if (i == 0) { tcg_op_remove(ctx->tcg, op); return true; @@ -1695,21 +1706,18 @@ static bool fold_mov(OptContext *ctx, TCGOp *op) static bool fold_movcond(OptContext *ctx, TCGOp *op) { - TCGCond cond = op->args[5]; int i; - if (swap_commutative(NO_DEST, &op->args[1], &op->args[2])) { - op->args[5] = cond = tcg_swap_cond(cond); - } /* * Canonicalize the "false" input reg to match the destination reg so * that the tcg backend can implement a "move if true" operation. */ if (swap_commutative(op->args[0], &op->args[4], &op->args[3])) { - op->args[5] = cond = tcg_invert_cond(cond); + op->args[5] = tcg_invert_cond(op->args[5]); } - i = do_constant_folding_cond(ctx->type, op->args[1], op->args[2], cond); + i = do_constant_folding_cond1(ctx, NO_DEST, &op->args[1], + &op->args[2], &op->args[5]); if (i >= 0) { return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[4 - i]); } @@ -1723,6 +1731,7 @@ static bool fold_movcond(OptContext *ctx, TCGOp *op) uint64_t tv = arg_info(op->args[3])->val; uint64_t fv = arg_info(op->args[4])->val; TCGOpcode opc, negopc = 0; + TCGCond cond = op->args[5]; switch (ctx->type) { case TCG_TYPE_I32: @@ -1950,14 +1959,8 @@ static bool fold_remainder(OptContext *ctx, TCGOp *op) static bool fold_setcond(OptContext *ctx, TCGOp *op) { - TCGCond cond = op->args[3]; - int i; - - if (swap_commutative(op->args[0], &op->args[1], &op->args[2])) { - op->args[3] = cond = tcg_swap_cond(cond); - } - - i = do_constant_folding_cond(ctx->type, op->args[1], op->args[2], cond); + int i = do_constant_folding_cond1(ctx, op->args[0], &op->args[1], + &op->args[2], &op->args[3]); if (i >= 0) { return tcg_opt_gen_movi(ctx, op, op->args[0], i); } @@ -1969,14 +1972,8 @@ static bool fold_setcond(OptContext *ctx, TCGOp *op) static bool fold_negsetcond(OptContext *ctx, TCGOp *op) { - TCGCond cond = op->args[3]; - int i; - - if (swap_commutative(op->args[0], &op->args[1], &op->args[2])) { - op->args[3] = cond = tcg_swap_cond(cond); - } - - i = do_constant_folding_cond(ctx->type, op->args[1], op->args[2], cond); + int i = do_constant_folding_cond1(ctx, op->args[0], &op->args[1], + &op->args[2], &op->args[3]); if (i >= 0) { return tcg_opt_gen_movi(ctx, op, op->args[0], -i); } From patchwork Sun Feb 4 21:40:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769878 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842738wrc; Sun, 4 Feb 2024 13:45:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IG48xVVv4w/5+tDcEMlOC3zMnfygvGSMdPOpm/4wz9tVwJBn+5Kqp+0c3/UyGSGXEaaaPmD X-Received: by 2002:ad4:4eae:0:b0:68c:6e89:dd33 with SMTP id ed14-20020ad44eae000000b0068c6e89dd33mr7813159qvb.1.1707083139473; Sun, 04 Feb 2024 13:45:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083139; cv=none; d=google.com; s=arc-20160816; b=vAJtaTbq9HRqIdHVf/TXKszfwViJDaq+XldCNmxgElB4SnNVYyDGpkU2Gtyl+Na+4E sibWzDCLcAoGU/6+e0vHE7IP9CDKEKHDI2tEkrho/iuUnwuT0l1kRO71kQQZMf5I+rme oGDH3lrakAPrxUiC286mfUvOkITCt+KLLIZDq6d2LrQgnl8iRfpcfPLKPdyfIx9WzNvA 2UWb/r1Ef8zrxh/e7wL7jfZVddqpWxRAAIBcUGNYZ0S3boDdVwwCo/pnTisWO+l4GAc9 0nv8YenbRsvpaZyPj0SFxttMSKA2QOIdojb52sLwSgkrx0r2SnflGlYAp5/RfDmjFoDy zOYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VRgNiPJydpvDmMhlC8JjCGm8KjRyw9Ww/5hSgKncWeA=; fh=tsvafTkOFmjzz4F+K2ZDJvdAkpbneWvlGUj8DQOnsik=; b=KU8LPVtzM9dPu04JeUUSKULCAbsUGOARxpluL5Bk+4+W9pjzZCmIRCSG2H3pibFb7O JVOCBf66IOEjNrKGKvN8CPN3E4A3BQm3EDtwVBjKMIfpErTK6aRZQmqVqSRmVYuJDh3f PcfYbB59eNHvgiejko5y7sZxyIu5OEKwPp/cJkm33B3x+u6B+uTdXv9nf7bNii2GLDMf IgHxEZqJXlhRIqiriOoOnCX3FTXcAi/7ox4DiBMkLJVTyMLV2RyuONCI4jCRbkJ7D1ZC yNral7CeQM3zHdr32G6cHjKphWtCX47qL6V07tnbX7k4ph1uVNBY7zri6mqIzDUUqI0K T3CQ==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="GWQSF/tH"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCWxmku2LMJpPy2vXc6OqpbPnKXUklh291l3UT0/q2zL4CANni8Tw1qhKFFt+VbkAkaY7b/XJComm7q7wklkCosJ Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v16-20020a0ced50000000b0068c7c3fb2a6si6973006qvq.203.2024.02.04.13.45.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:45:39 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="GWQSF/tH"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkEo-000236-5J; Sun, 04 Feb 2024 16:41: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 1rWkEg-00021n-I1 for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:12 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkEe-0003VJ-V0 for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:10 -0500 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1d944e8f367so29516885ad.0 for ; Sun, 04 Feb 2024 13:41:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082867; x=1707687667; 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=GWQSF/tHgGOKsfRTJYVx9Qp3o/J79d456+faWrmwtAGLeB84dJciMTfx43YELoYBXx MAPhOpzLH5SpTRrE1ZJCH/lrPM914iWotTiajqe2SrwkS/7FyAZbPac4b/DBwbUCqbvw 17bLgRlQjgVWkgoAIdaEQaLFsWNIauI/axjwurIKUaGi1/Tlehahu98iBH2lQbG+1TR2 iRobQdPuGaEV7LnFtPyHZY43qAMP1MypQEcL8Fv50YGZFvmy7E3Z+F9VKFUgeRfClahY oAonN9BR9DBZKPFpfbly8Xnjp3Fq6M5yI5rHEmZnY17Lw5KqOmm6o36HBKMIDyI07aEA 6VBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082867; x=1707687667; 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=S3wYQMnmcCioNCInEoExORHYnkpES0/UBVbC40gpIVusCjXEDh8sKUPEPxVXBF9kyk VyRVDNVYN9iwk6s0wQcjli+6gFNItyECcGkCT1EXQpnPEM34oU1ghYiefIfRSNM3Cqek Wy/ItV6AX8Uue30+8K0e0YPmhzBxRRalPLAjjJsO3LozTs0cemFHc+Fn/aCNXYhFElNl BAC2zRFVchStops8CjF91HYnMG4tHdXxmxrOZgou1f+2N5rNkCmMOKW9lKvTYGnDJpvX Wva+VJv9VJqsDRtrrKqIyOZEFbbZxGbDMtRJ9FSejDYwlBfDYMMY3OOlctk1ezTAbeq4 jOAQ== X-Gm-Message-State: AOJu0YxJLW3DXZHJdhSHrBBbxKc4ehv9vf3xItm7N8oA0XlOjJcDKh/N oArxni/2lz7LO7lHjFI56r1iQGVkK7bQuk5CjUZYZjrl4RlfCAYZJS5BOe4AnyWK/P+wmMTh5bG bxg8= X-Received: by 2002:a17:902:6803:b0:1d9:5b4d:6ffe with SMTP id h3-20020a170902680300b001d95b4d6ffemr8606983plk.52.1707082867330; Sun, 04 Feb 2024 13:41:07 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:06 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 05/39] tcg/optimize: Do swap_commutative2 in do_constant_folding_cond2 Date: Mon, 5 Feb 2024 07:40:18 +1000 Message-Id: <20240204214052.5639-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Mirror the new do_constant_folding_cond1 by doing all argument and condition adjustment within one helper. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/optimize.c | 107 ++++++++++++++++++++++++++----------------------- 1 file changed, 57 insertions(+), 50 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 9c04dba099..08a9280432 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -713,43 +713,6 @@ static int do_constant_folding_cond(TCGType type, TCGArg x, return -1; } -/* - * Return -1 if the condition can't be simplified, - * and the result of the condition (0 or 1) if it can. - */ -static int do_constant_folding_cond2(TCGArg *p1, TCGArg *p2, TCGCond c) -{ - TCGArg al = p1[0], ah = p1[1]; - TCGArg bl = p2[0], bh = p2[1]; - - if (arg_is_const(bl) && arg_is_const(bh)) { - tcg_target_ulong blv = arg_info(bl)->val; - tcg_target_ulong bhv = arg_info(bh)->val; - uint64_t b = deposit64(blv, 32, 32, bhv); - - if (arg_is_const(al) && arg_is_const(ah)) { - tcg_target_ulong alv = arg_info(al)->val; - tcg_target_ulong ahv = arg_info(ah)->val; - uint64_t a = deposit64(alv, 32, 32, ahv); - return do_constant_folding_cond_64(a, b, c); - } - if (b == 0) { - switch (c) { - case TCG_COND_LTU: - return 0; - case TCG_COND_GEU: - return 1; - default: - break; - } - } - } - if (args_are_copies(al, bl) && args_are_copies(ah, bh)) { - return do_constant_folding_cond_eq(c); - } - return -1; -} - /** * swap_commutative: * @dest: TCGArg of the destination argument, or NO_DEST. @@ -796,6 +759,10 @@ static bool swap_commutative2(TCGArg *p1, TCGArg *p2) return false; } +/* + * Return -1 if the condition can't be simplified, + * and the result of the condition (0 or 1) if it can. + */ static int do_constant_folding_cond1(OptContext *ctx, TCGArg dest, TCGArg *p1, TCGArg *p2, TCGArg *pcond) { @@ -813,6 +780,51 @@ static int do_constant_folding_cond1(OptContext *ctx, TCGArg dest, return r; } +static int do_constant_folding_cond2(OptContext *ctx, TCGArg *args) +{ + TCGArg al, ah, bl, bh; + TCGCond c; + bool swap; + + swap = swap_commutative2(args, args + 2); + c = args[4]; + if (swap) { + args[4] = c = tcg_swap_cond(c); + } + + al = args[0]; + ah = args[1]; + bl = args[2]; + bh = args[3]; + + if (arg_is_const(bl) && arg_is_const(bh)) { + tcg_target_ulong blv = arg_info(bl)->val; + tcg_target_ulong bhv = arg_info(bh)->val; + uint64_t b = deposit64(blv, 32, 32, bhv); + + if (arg_is_const(al) && arg_is_const(ah)) { + tcg_target_ulong alv = arg_info(al)->val; + tcg_target_ulong ahv = arg_info(ah)->val; + uint64_t a = deposit64(alv, 32, 32, ahv); + return do_constant_folding_cond_64(a, b, c); + } + if (b == 0) { + switch (c) { + case TCG_COND_LTU: + return 0; + case TCG_COND_GEU: + return 1; + default: + break; + } + } + } + if (args_are_copies(al, bl) && args_are_copies(ah, bh)) { + return do_constant_folding_cond_eq(c); + } + return -1; +} + static void init_arguments(OptContext *ctx, TCGOp *op, int nb_args) { for (int i = 0; i < nb_args; i++) { @@ -1225,15 +1237,13 @@ static bool fold_brcond(OptContext *ctx, TCGOp *op) static bool fold_brcond2(OptContext *ctx, TCGOp *op) { - TCGCond cond = op->args[4]; - TCGArg label = op->args[5]; + TCGCond cond; + TCGArg label; int i, inv = 0; - if (swap_commutative2(&op->args[0], &op->args[2])) { - op->args[4] = cond = tcg_swap_cond(cond); - } - - i = do_constant_folding_cond2(&op->args[0], &op->args[2], cond); + i = do_constant_folding_cond2(ctx, &op->args[0]); + cond = op->args[4]; + label = op->args[5]; if (i >= 0) { goto do_brcond_const; } @@ -1986,14 +1996,11 @@ static bool fold_negsetcond(OptContext *ctx, TCGOp *op) static bool fold_setcond2(OptContext *ctx, TCGOp *op) { - TCGCond cond = op->args[5]; + TCGCond cond; int i, inv = 0; - if (swap_commutative2(&op->args[1], &op->args[3])) { - op->args[5] = cond = tcg_swap_cond(cond); - } - - i = do_constant_folding_cond2(&op->args[1], &op->args[3], cond); + i = do_constant_folding_cond2(ctx, &op->args[1]); + cond = op->args[5]; if (i >= 0) { goto do_setcond_const; } From patchwork Sun Feb 4 21:40:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769847 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1841993wrc; Sun, 4 Feb 2024 13:41:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IEjLV+HiqRkDuHvnyOgQrrkdESp0tG4d2Z0SZt9kvub0dCZXpGPMJxX9SIVdJDhg3mQ2cex X-Received: by 2002:a05:6808:f88:b0:3bf:daf1:48bb with SMTP id o8-20020a0568080f8800b003bfdaf148bbmr2686409oiw.29.1707082904902; Sun, 04 Feb 2024 13:41:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707082904; cv=none; d=google.com; s=arc-20160816; b=eYAphXnDq3wcwqcUxvfo0ky5flUCYTcgIwA5NuImIHaJp8XpPzqClxE2SI2JJBeUHv OyJqeONZwKROZ2wVcpJ1VgplAm05GO5qZuojgQmLid7m0tEnX2ZhRx4H3qd06QODHcJb 1ExKhZo8pt+uxljWKEtRPwqAAiWLKTki/qKDwBxSAEuU8EfKfF+GMXyKGp+01fRPXSaM TcsWOttDSPUNQGEZUZMuQknVDWz/s1sKaYvSH355F7EfL5LRY7A//jRsO3rgDp/mTM6t s252ka33uD2hwnQr6cjaHI6auc5Ty8vJ1atn21WqwxcZWpaFxWKETBROaZshSwTnIOcf B4Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4WPFWKge9Cibe1+P1uYI+mpRsrAd20eTdoBjuJnsUMU=; fh=fgtVc/MiefWpnJSLTKsCpHST1UYpqaxbbP/pepe1VzE=; b=AM7XeQtCxyNSZDL31gWBZJveja4ZOwZQxW0HKbF2SWfu8CFEifWmav8fIOxhhLIt8y qFxopC3AYtr1BLEAr2EuuaKpviaAWnUbr+wfNTbC27AKPfjGF4LtOpUgqu9InkxvdqUn mzRfxOfGcWiZsEZqFoFLL11pjmaVfqBPV0NkwdI/EP0qRY0GrG9pLslLj0akgWEu5hGb sGSELa9J8fz2OeHsBHW9VEYOs4Km9m1HZuralWHwKw63Avkt/HVgR6jHv/X6BotlON+T yZ80J3UVpbQZzb0cj3dt5/gZfaeQtfu2Yib8Xt/J3pi1xBM+oYssV76TgJ+gIOXiDFiY XNOw==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ld3cDBD+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCU0BQFkOvZWHyWwy0u/rafnO+PaDQjxro1xoYwPBP8C3sVXkDbeE5HkDQFb4vRV8znGrPXvVNnrO7gNv2VE+PNG Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u5-20020a05622a010500b0042bf9317920si7018387qtw.775.2024.02.04.13.41.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:41:44 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ld3cDBD+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkEm-000234-Mr; Sun, 04 Feb 2024 16:41: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 1rWkEi-000227-Jc for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:12 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkEg-0003VR-JW for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:12 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1d9bd8fa49eso665545ad.1 for ; Sun, 04 Feb 2024 13:41:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082869; x=1707687669; 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=ld3cDBD+SiiC7SY5A0XbuTHhk+NDvAEe6U/+M/05h0NlJNEBmSHzfYPpmv6uVM2LK4 ENNyd3M/Jqg840B/ksiVTYBqgCsL4T1EqGeAiDtSv+CAj7O3tbFPke8LkT/PWU84uIGq p99mqrBMQfbHRsZDObi777lYXvVORZbiNNJGuul8ZltjdpNKKQN/M19P6bd26LZ9fSCq S/kqu8T03zFn1LsWDA4gVhUegOK25HYN7cdGY99BXHlf+w446+0cQep5lZULTodHrvCU PQ6V8mnP4p30H8tR19IHe5bqwZDkG4pXwdYaUYvAmSrP/0CiDvFhOb7evlfioesnZq9W 5dTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082869; x=1707687669; 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=af3gkRNags7+X0d3mAo6lbgub/MXHolTgKUCiHGLbFM41Bx6tDNqgw7KbTUuyFU1K6 7Sacu0qJoZnZ7dtQ09rfEakdN/02cK2Eom70emKmjZwugR9Yljvf+mWCNGa8lAqTI7d+ ZYLQtbQKLymH3m1oOBNGTN4Ru3iizDWqx8qpRoEl+Ovo68Xsk+z5F2FXAhtFQPLXvQwu jdcG1i9Wkcxv+VQnXpIPzeDLcSfsVHAxYCkI9BKukfLSJwGoiyJctA4yLZcBMIPeCFas UrAz6zpyAPRfWiukZMLglfRsYbUKfCzxpxSytvyyudeEg85b7jeRPljOiYL241pqIxhp jcgg== X-Gm-Message-State: AOJu0YzByKgWEaG39Omroz4uQlIqEzX84uXSaFtpHFbYHOefC3MpaCbO +lau7F4ffL40iP4QHpO2Zwu6HV1liYpRCFsQYXA8mNyI3GRJhFFaAPzO1jvExdR7J6ANolrAX/7 w0LQ= X-Received: by 2002:a17:903:11d2:b0:1d9:5763:d89b with SMTP id q18-20020a17090311d200b001d95763d89bmr8617156plh.47.1707082869369; Sun, 04 Feb 2024 13:41:09 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 06/39] tcg/optimize: Handle TCG_COND_TST{EQ,NE} Date: Mon, 5 Feb 2024 07:40:19 +1000 Message-Id: <20240204214052.5639-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Fold constant comparisons. Canonicalize "tst x,x" to equality vs zero. Canonicalize "tst x,sign" to sign test vs zero. Fold double-word comparisons with zero parts. Fold setcond of "tst x,pow2" to a bit extract. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/optimize.c | 240 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 218 insertions(+), 22 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 08a9280432..2ed6322f97 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -625,9 +625,15 @@ static bool do_constant_folding_cond_32(uint32_t x, uint32_t y, TCGCond c) return x <= y; case TCG_COND_GTU: return x > y; - default: - g_assert_not_reached(); + case TCG_COND_TSTEQ: + return (x & y) == 0; + case TCG_COND_TSTNE: + return (x & y) != 0; + case TCG_COND_ALWAYS: + case TCG_COND_NEVER: + break; } + g_assert_not_reached(); } static bool do_constant_folding_cond_64(uint64_t x, uint64_t y, TCGCond c) @@ -653,12 +659,18 @@ static bool do_constant_folding_cond_64(uint64_t x, uint64_t y, TCGCond c) return x <= y; case TCG_COND_GTU: return x > y; - default: - g_assert_not_reached(); + case TCG_COND_TSTEQ: + return (x & y) == 0; + case TCG_COND_TSTNE: + return (x & y) != 0; + case TCG_COND_ALWAYS: + case TCG_COND_NEVER: + break; } + g_assert_not_reached(); } -static bool do_constant_folding_cond_eq(TCGCond c) +static int do_constant_folding_cond_eq(TCGCond c) { switch (c) { case TCG_COND_GT: @@ -673,9 +685,14 @@ static bool do_constant_folding_cond_eq(TCGCond c) case TCG_COND_LEU: case TCG_COND_EQ: return 1; - default: - g_assert_not_reached(); + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + return -1; + case TCG_COND_ALWAYS: + case TCG_COND_NEVER: + break; } + g_assert_not_reached(); } /* @@ -703,8 +720,10 @@ static int do_constant_folding_cond(TCGType type, TCGArg x, } else if (arg_is_const_val(y, 0)) { switch (c) { case TCG_COND_LTU: + case TCG_COND_TSTNE: return 0; case TCG_COND_GEU: + case TCG_COND_TSTEQ: return 1; default: return -1; @@ -777,7 +796,30 @@ static int do_constant_folding_cond1(OptContext *ctx, TCGArg dest, } r = do_constant_folding_cond(ctx->type, *p1, *p2, cond); - return r; + if (r >= 0) { + return r; + } + if (!is_tst_cond(cond)) { + return -1; + } + + /* + * TSTNE x,x -> NE x,0 + * TSTNE x,-1 -> NE x,0 + */ + if (args_are_copies(*p1, *p2) || arg_is_const_val(*p2, -1)) { + *p2 = arg_new_constant(ctx, 0); + *pcond = tcg_tst_eqne_cond(cond); + return -1; + } + + /* TSTNE x,sign -> LT x,0 */ + if (arg_is_const_val(*p2, (ctx->type == TCG_TYPE_I32 + ? INT32_MIN : INT64_MIN))) { + *p2 = arg_new_constant(ctx, 0); + *pcond = tcg_tst_ltge_cond(cond); + } + return -1; } static int do_constant_folding_cond2(OptContext *ctx, TCGArg *args) @@ -785,6 +827,7 @@ static int do_constant_folding_cond2(OptContext *ctx, TCGArg *args) TCGArg al, ah, bl, bh; TCGCond c; bool swap; + int r; swap = swap_commutative2(args, args + 2); c = args[4]; @@ -806,21 +849,54 @@ static int do_constant_folding_cond2(OptContext *ctx, TCGArg *args) tcg_target_ulong alv = arg_info(al)->val; tcg_target_ulong ahv = arg_info(ah)->val; uint64_t a = deposit64(alv, 32, 32, ahv); - return do_constant_folding_cond_64(a, b, c); + + r = do_constant_folding_cond_64(a, b, c); + if (r >= 0) { + return r; + } } + if (b == 0) { switch (c) { case TCG_COND_LTU: + case TCG_COND_TSTNE: return 0; case TCG_COND_GEU: + case TCG_COND_TSTEQ: return 1; default: break; } } + + /* TSTNE x,-1 -> NE x,0 */ + if (b == -1 && is_tst_cond(c)) { + args[3] = args[2] = arg_new_constant(ctx, 0); + args[4] = tcg_tst_eqne_cond(c); + return -1; + } + + /* TSTNE x,sign -> LT x,0 */ + if (b == INT64_MIN && is_tst_cond(c)) { + /* bl must be 0, so copy that to bh */ + args[3] = bl; + args[4] = tcg_tst_ltge_cond(c); + return -1; + } } + if (args_are_copies(al, bl) && args_are_copies(ah, bh)) { - return do_constant_folding_cond_eq(c); + r = do_constant_folding_cond_eq(c); + if (r >= 0) { + return r; + } + + /* TSTNE x,x -> NE x,0 */ + if (is_tst_cond(c)) { + args[3] = args[2] = arg_new_constant(ctx, 0); + args[4] = tcg_tst_eqne_cond(c); + return -1; + } } return -1; } @@ -1284,24 +1360,37 @@ static bool fold_brcond2(OptContext *ctx, TCGOp *op) case 0: goto do_brcond_const; case 1: - op->opc = INDEX_op_brcond_i32; - op->args[1] = op->args[2]; - op->args[2] = cond; - op->args[3] = label; - break; + goto do_brcond_low; + } + break; + + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + if (arg_is_const_val(op->args[2], 0)) { + goto do_brcond_high; + } + if (arg_is_const_val(op->args[3], 0)) { + goto do_brcond_low; } break; default: break; + do_brcond_low: + op->opc = INDEX_op_brcond_i32; + op->args[1] = op->args[2]; + op->args[2] = cond; + op->args[3] = label; + return fold_brcond(ctx, op); + do_brcond_high: op->opc = INDEX_op_brcond_i32; op->args[0] = op->args[1]; op->args[1] = op->args[3]; op->args[2] = cond; op->args[3] = label; - break; + return fold_brcond(ctx, op); do_brcond_const: if (i == 0) { @@ -1967,6 +2056,99 @@ static bool fold_remainder(OptContext *ctx, TCGOp *op) return false; } +static void fold_setcond_tst_pow2(OptContext *ctx, TCGOp *op, bool neg) +{ + TCGOpcode and_opc, sub_opc, xor_opc, neg_opc, shr_opc, uext_opc, sext_opc; + TCGCond cond = op->args[3]; + TCGArg ret, src1, src2; + TCGOp *op2; + uint64_t val; + int sh; + bool inv; + + if (!is_tst_cond(cond) || !arg_is_const(op->args[2])) { + return; + } + + src2 = op->args[2]; + val = arg_info(src2)->val; + if (!is_power_of_2(val)) { + return; + } + sh = ctz64(val); + + switch (ctx->type) { + case TCG_TYPE_I32: + and_opc = INDEX_op_and_i32; + sub_opc = INDEX_op_sub_i32; + xor_opc = INDEX_op_xor_i32; + shr_opc = INDEX_op_shr_i32; + neg_opc = INDEX_op_neg_i32; + if (TCG_TARGET_extract_i32_valid(sh, 1)) { + uext_opc = TCG_TARGET_HAS_extract_i32 ? INDEX_op_extract_i32 : 0; + sext_opc = TCG_TARGET_HAS_sextract_i32 ? INDEX_op_sextract_i32 : 0; + } + break; + case TCG_TYPE_I64: + and_opc = INDEX_op_and_i64; + sub_opc = INDEX_op_sub_i64; + xor_opc = INDEX_op_xor_i64; + shr_opc = INDEX_op_shr_i64; + neg_opc = INDEX_op_neg_i64; + if (TCG_TARGET_extract_i64_valid(sh, 1)) { + uext_opc = TCG_TARGET_HAS_extract_i64 ? INDEX_op_extract_i64 : 0; + sext_opc = TCG_TARGET_HAS_sextract_i64 ? INDEX_op_sextract_i64 : 0; + } + break; + default: + g_assert_not_reached(); + } + + ret = op->args[0]; + src1 = op->args[1]; + inv = cond == TCG_COND_TSTEQ; + + if (sh && sext_opc && neg && !inv) { + op->opc = sext_opc; + op->args[1] = src1; + op->args[2] = sh; + op->args[3] = 1; + return; + } else if (sh && uext_opc) { + op->opc = uext_opc; + op->args[1] = src1; + op->args[2] = sh; + op->args[3] = 1; + } else { + if (sh) { + op2 = tcg_op_insert_before(ctx->tcg, op, shr_opc, 3); + op2->args[0] = ret; + op2->args[1] = src1; + op2->args[2] = arg_new_constant(ctx, sh); + src1 = ret; + } + op->opc = and_opc; + op->args[1] = src1; + op->args[2] = arg_new_constant(ctx, 1); + } + + if (neg && inv) { + op2 = tcg_op_insert_after(ctx->tcg, op, sub_opc, 3); + op2->args[0] = ret; + op2->args[1] = ret; + op2->args[2] = arg_new_constant(ctx, 1); + } else if (inv) { + op2 = tcg_op_insert_after(ctx->tcg, op, xor_opc, 3); + op2->args[0] = ret; + op2->args[1] = ret; + op2->args[2] = arg_new_constant(ctx, 1); + } else if (neg) { + op2 = tcg_op_insert_after(ctx->tcg, op, neg_opc, 2); + op2->args[0] = ret; + op2->args[1] = ret; + } +} + static bool fold_setcond(OptContext *ctx, TCGOp *op) { int i = do_constant_folding_cond1(ctx, op->args[0], &op->args[1], @@ -1974,6 +2156,7 @@ static bool fold_setcond(OptContext *ctx, TCGOp *op) if (i >= 0) { return tcg_opt_gen_movi(ctx, op, op->args[0], i); } + fold_setcond_tst_pow2(ctx, op, false); ctx->z_mask = 1; ctx->s_mask = smask_from_zmask(1); @@ -1987,13 +2170,13 @@ static bool fold_negsetcond(OptContext *ctx, TCGOp *op) if (i >= 0) { return tcg_opt_gen_movi(ctx, op, op->args[0], -i); } + fold_setcond_tst_pow2(ctx, op, true); /* Value is {0,-1} so all bits are repetitions of the sign. */ ctx->s_mask = -1; return false; } - static bool fold_setcond2(OptContext *ctx, TCGOp *op) { TCGCond cond; @@ -2041,22 +2224,35 @@ static bool fold_setcond2(OptContext *ctx, TCGOp *op) case 0: goto do_setcond_const; case 1: - op->args[2] = op->args[3]; - op->args[3] = cond; - op->opc = INDEX_op_setcond_i32; - break; + goto do_setcond_low; + } + break; + + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + if (arg_is_const_val(op->args[2], 0)) { + goto do_setcond_high; + } + if (arg_is_const_val(op->args[4], 0)) { + goto do_setcond_low; } break; default: break; + do_setcond_low: + op->args[2] = op->args[3]; + op->args[3] = cond; + op->opc = INDEX_op_setcond_i32; + return fold_setcond(ctx, op); + do_setcond_high: op->args[1] = op->args[2]; op->args[2] = op->args[4]; op->args[3] = cond; op->opc = INDEX_op_setcond_i32; - break; + return fold_setcond(ctx, op); } ctx->z_mask = 1; From patchwork Sun Feb 4 21:40:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769877 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842699wrc; Sun, 4 Feb 2024 13:45:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IF/JwtlBaE34zkOYs+OvXN5XmHBeTSd4Dvd5p0ASfGNKSYtZE026YFEow/u3uI4BJsPMg5x X-Received: by 2002:a0c:ca91:0:b0:68c:46b9:13d8 with SMTP id a17-20020a0cca91000000b0068c46b913d8mr4734515qvk.10.1707083125227; Sun, 04 Feb 2024 13:45:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083125; cv=none; d=google.com; s=arc-20160816; b=zcoL98nW33RSd59v0OFLgimYOGxkMfozhgINfPcX6kLYGS7HiWEYmoTKk0LrXI4avR g6Ucm/o2WJeXMikjeo8UjzC1EVWhz0DkCZWcz+hWIb86RApPddtZstOE1Io+LoHlXDki KyfWx3N0aOmE8kySOeoBK+JTFR8Ya6NIE0Q/GDbiiTfknUFAZAKcRXfLRXbA85fr1+4r FVMangGO5M7TenIKwH5fkt8GsPe0sde1P/HuE+KJ6AxkN8WnvIp3tYDNU/gZvEXAS1Ue ccAsreAFTQMx5rUeq6IbhUYqN/JrXXgA9jlHjcgzUhH+eHvalC3cb0wCwUmVjZWwJ4/7 DWsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zDxVow85zGZrsh8Lo3sBxluiD4KZqah1pBli11XwX78=; fh=8lGq7CTXiKo3TLRopiUeAntrAWfPXgzS9zkJxoZF/DQ=; b=QeFg1NzTfDyiejrhd3RsUJjVK2yeducO69VLx7rfLi2V5kEx7MtQBCgs4xeon8jHuP F4rxWlGMbIWzueFiNSAmBAhiSCWWoJSnOmvHDK3JOhFcDH1VvEeHWkf4mvKby3W274KH 1GegywKraweGof+dVuxI0dy0Engpbpw5DbVrLuQvH4Fjx93wXWPNfGe8ybEJ50iLH3It ptmxPWj6/CrYE31Cl1hBfRjXhcC7GvPNfuzDYx6ieYdbPCRdSxqP6hzzw2u2wsBf4LA9 bHRV65EzZzDzASx+zXt2X7XQjqoFv0vPQwJjMYCQ1qPcTlLZ0j4uetZ4COs/DGzVU1Bn xb+w==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LOL9fgJs; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCXymPtKNA+WHc4L1JeyRm+YT9aVfKRH9bbngGzTepHCF1kNi+fJQKkLS8hLY06AWL1d+JPwhL6N2dMASOWpnQFq Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c8-20020a056214224800b0068c91ba1cc2si4942219qvc.15.2024.02.04.13.45.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:45:25 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LOL9fgJs; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkEp-00023b-AZ; Sun, 04 Feb 2024 16:41:19 -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 1rWkEk-00022V-DG for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:14 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkEi-0003Va-NQ for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:14 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d98fc5ebceso2084275ad.1 for ; Sun, 04 Feb 2024 13:41:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082871; x=1707687671; 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=zDxVow85zGZrsh8Lo3sBxluiD4KZqah1pBli11XwX78=; b=LOL9fgJsJcLWfTyAn/JLs4PU3Zh/qU7VF3iGqSXN7r3R+FtLmzI8EjntQ3FYO2D6jv 2H0HL44WJYexqUso8/+eKxO7vpHZ6viAJksg2m5KPy49GebZASa5sZiFcWGKJRc+pU6K JR/ceoRx6XYBcQL1p4qOo7YOezWaWc+QERz6r6v1q8tIY6MbAroQmvcENZBWndx6WTm4 07hL8gdHB/EGdSzWavAl7tkqjZBGRuiHJbH0yYoJhdUmvmcaB/YY+va6H3y6184s/TK8 M+Njuwwq+s4dVbrCYFKZJmajP8XyYTUU1O2KwXERzmuXJMNYVxSKjKZOTrZ617ODssvc XqDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082871; x=1707687671; 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=zDxVow85zGZrsh8Lo3sBxluiD4KZqah1pBli11XwX78=; b=nawOt+QfQXSao+xrZerno67ylarHimBiXQdbYkUKT8q2WrH1R3XUyAY/JL3vcZpFNP Yf4+jgVWbH2E2fFOQxzGcGoZt4Yx/Ecxp2MyDzB287RXAdRWRiIHj4bfIPd4S8C2YZam /J4Q9sHxLUup6HcQvvSyQmbH9mikB0Y624guDzGuwCIRvsB3oEeqDOWHCoS99/qoroB4 BLQ6Ilc+zxFhhird7UwAOibP7Uhx3ZKuCsqj8w+mQAVt9DeimG1za2AU1xk+6EqC8Ku8 8xp0JOtONXD30xpnnk25VadBoxYxpACqSbSKK+eAZkOoonxCC+Xf7XJBLo8t9yXpgiis Uo7w== X-Gm-Message-State: AOJu0YzGh8hfHsLCZsuthTGHHzPxSyJRtRC2De5lXWLItAM8GOQEw1T5 UMT2PId2yBFHemL1KHyA1LmzMGUWc93f9H6KO4SdzK16fLDe2PJLDKddYegqtY1mP5+5HWrDBQw AVVU= X-Received: by 2002:a17:902:cec6:b0:1d9:4ebd:b94d with SMTP id d6-20020a170902cec600b001d94ebdb94dmr14796366plg.55.1707082871420; Sun, 04 Feb 2024 13:41:11 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 07/39] tcg/optimize: Lower TCG_COND_TST{EQ,NE} if unsupported Date: Mon, 5 Feb 2024 07:40:20 +1000 Message-Id: <20240204214052.5639-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org After having performed other simplifications, lower any remaining test comparisons with AND. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/tcg-internal.h | 2 ++ tcg/optimize.c | 60 +++++++++++++++++++++++++++++++++++++++------- tcg/tcg.c | 2 +- 3 files changed, 55 insertions(+), 9 deletions(-) diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index 6c9d9e48db..9b0d982f65 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -83,6 +83,8 @@ static inline TCGv_i64 TCGV128_HIGH(TCGv_i128 t) bool tcg_target_has_memory_bswap(MemOp memop); +TCGTemp *tcg_temp_new_internal(TCGType type, TCGTempKind kind); + /* * Locate or create a read-only temporary that is a constant. * This kind of temporary need not be freed, but for convenience diff --git a/tcg/optimize.c b/tcg/optimize.c index 2ed6322f97..79e701652b 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -364,6 +364,13 @@ static TCGArg arg_new_constant(OptContext *ctx, uint64_t val) return temp_arg(ts); } +static TCGArg arg_new_temp(OptContext *ctx) +{ + TCGTemp *ts = tcg_temp_new_internal(ctx->type, TEMP_EBB); + init_ts_info(ctx, ts); + return temp_arg(ts); +} + static bool tcg_opt_gen_mov(OptContext *ctx, TCGOp *op, TCGArg dst, TCGArg src) { TCGTemp *dst_ts = arg_temp(dst); @@ -782,7 +789,7 @@ static bool swap_commutative2(TCGArg *p1, TCGArg *p2) * Return -1 if the condition can't be simplified, * and the result of the condition (0 or 1) if it can. */ -static int do_constant_folding_cond1(OptContext *ctx, TCGArg dest, +static int do_constant_folding_cond1(OptContext *ctx, TCGOp *op, TCGArg dest, TCGArg *p1, TCGArg *p2, TCGArg *pcond) { TCGCond cond; @@ -818,11 +825,28 @@ static int do_constant_folding_cond1(OptContext *ctx, TCGArg dest, ? INT32_MIN : INT64_MIN))) { *p2 = arg_new_constant(ctx, 0); *pcond = tcg_tst_ltge_cond(cond); + return -1; + } + + /* Expand to AND with a temporary if no backend support. */ + if (!TCG_TARGET_HAS_tst) { + TCGOpcode and_opc = (ctx->type == TCG_TYPE_I32 + ? INDEX_op_and_i32 : INDEX_op_and_i64); + TCGOp *op2 = tcg_op_insert_before(ctx->tcg, op, and_opc, 3); + TCGArg tmp = arg_new_temp(ctx); + + op2->args[0] = tmp; + op2->args[1] = *p1; + op2->args[2] = *p2; + + *p1 = tmp; + *p2 = arg_new_constant(ctx, 0); + *pcond = tcg_tst_eqne_cond(cond); } return -1; } -static int do_constant_folding_cond2(OptContext *ctx, TCGArg *args) +static int do_constant_folding_cond2(OptContext *ctx, TCGOp *op, TCGArg *args) { TCGArg al, ah, bl, bh; TCGCond c; @@ -898,6 +922,26 @@ static int do_constant_folding_cond2(OptContext *ctx, TCGArg *args) return -1; } } + + /* Expand to AND with a temporary if no backend support. */ + if (!TCG_TARGET_HAS_tst && is_tst_cond(c)) { + TCGOp *op1 = tcg_op_insert_before(ctx->tcg, op, INDEX_op_and_i32, 3); + TCGOp *op2 = tcg_op_insert_before(ctx->tcg, op, INDEX_op_and_i32, 3); + TCGArg t1 = arg_new_temp(ctx); + TCGArg t2 = arg_new_temp(ctx); + + op1->args[0] = t1; + op1->args[1] = al; + op1->args[2] = bl; + op2->args[0] = t2; + op2->args[1] = ah; + op2->args[2] = bh; + + args[0] = t1; + args[1] = t2; + args[3] = args[2] = arg_new_constant(ctx, 0); + args[4] = tcg_tst_eqne_cond(c); + } return -1; } @@ -1298,7 +1342,7 @@ static bool fold_andc(OptContext *ctx, TCGOp *op) static bool fold_brcond(OptContext *ctx, TCGOp *op) { - int i = do_constant_folding_cond1(ctx, NO_DEST, &op->args[0], + int i = do_constant_folding_cond1(ctx, op, NO_DEST, &op->args[0], &op->args[1], &op->args[2]); if (i == 0) { tcg_op_remove(ctx->tcg, op); @@ -1317,7 +1361,7 @@ static bool fold_brcond2(OptContext *ctx, TCGOp *op) TCGArg label; int i, inv = 0; - i = do_constant_folding_cond2(ctx, &op->args[0]); + i = do_constant_folding_cond2(ctx, op, &op->args[0]); cond = op->args[4]; label = op->args[5]; if (i >= 0) { @@ -1815,7 +1859,7 @@ static bool fold_movcond(OptContext *ctx, TCGOp *op) op->args[5] = tcg_invert_cond(op->args[5]); } - i = do_constant_folding_cond1(ctx, NO_DEST, &op->args[1], + i = do_constant_folding_cond1(ctx, op, NO_DEST, &op->args[1], &op->args[2], &op->args[5]); if (i >= 0) { return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[4 - i]); @@ -2151,7 +2195,7 @@ static void fold_setcond_tst_pow2(OptContext *ctx, TCGOp *op, bool neg) static bool fold_setcond(OptContext *ctx, TCGOp *op) { - int i = do_constant_folding_cond1(ctx, op->args[0], &op->args[1], + int i = do_constant_folding_cond1(ctx, op, op->args[0], &op->args[1], &op->args[2], &op->args[3]); if (i >= 0) { return tcg_opt_gen_movi(ctx, op, op->args[0], i); @@ -2165,7 +2209,7 @@ static bool fold_setcond(OptContext *ctx, TCGOp *op) static bool fold_negsetcond(OptContext *ctx, TCGOp *op) { - int i = do_constant_folding_cond1(ctx, op->args[0], &op->args[1], + int i = do_constant_folding_cond1(ctx, op, op->args[0], &op->args[1], &op->args[2], &op->args[3]); if (i >= 0) { return tcg_opt_gen_movi(ctx, op, op->args[0], -i); @@ -2182,7 +2226,7 @@ static bool fold_setcond2(OptContext *ctx, TCGOp *op) TCGCond cond; int i, inv = 0; - i = do_constant_folding_cond2(ctx, &op->args[1]); + i = do_constant_folding_cond2(ctx, op, &op->args[1]); cond = op->args[5]; if (i >= 0) { goto do_setcond_const; diff --git a/tcg/tcg.c b/tcg/tcg.c index eeeb9b0c70..60cb31c400 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1655,7 +1655,7 @@ TCGv_ptr tcg_global_mem_new_ptr(TCGv_ptr reg, intptr_t off, const char *name) return temp_tcgv_ptr(ts); } -static TCGTemp *tcg_temp_new_internal(TCGType type, TCGTempKind kind) +TCGTemp *tcg_temp_new_internal(TCGType type, TCGTempKind kind) { TCGContext *s = tcg_ctx; TCGTemp *ts; From patchwork Sun Feb 4 21:40:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769867 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842464wrc; Sun, 4 Feb 2024 13:44:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IG2hm/bej+pcNc6Y/5NhvtwdvfByS8yFHK+xAjIIgziQYC8o4OMpxDXLwA9oxAzLW62/fDr X-Received: by 2002:a0c:e0ca:0:b0:681:7bab:be38 with SMTP id x10-20020a0ce0ca000000b006817babbe38mr6017854qvk.13.1707083052342; Sun, 04 Feb 2024 13:44:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083052; cv=none; d=google.com; s=arc-20160816; b=BakoMpokkp3z4Pk6Tp9DuviNuf1N5lXgrmL0f0KhdWD0GTZnDHmGUEvXxLQOothSxV 8pr2wGbP6wwGH0sevtLIoohas1/alOHLl0gDbp8NEr5MjhqpgM5HYrTNf3E5+O1sMSyr 1x7YYY67jrItwS7VJQmm2vyactSsmCzbETNc1jsyTiYdWxKx1Gtf7d6mgut+WZ8mRy5i c+MhrtsCXgPt+dpY4jSpA7sQCbgCNOZMpc0uQ22UTRWN401msmJqedoo6VcaRCQq4fB/ /1oPXYQ1HQEPx5Nb5VU0rO8vGGWy4VYzYqV5oZVvJR0JCFyTq6aDYHUvDZDpXdjmsJoy e3cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PdjLaL1s4T12GYUYF4WyCqbK9Vrp5G+xso0HVv7zwQk=; fh=C+g5t+++EdwIPkhnYLUSvWWbt42UnJdyo2wn3BggdAI=; b=F+hl2plyLekl8SVfgJxonkMo5ANy/8bpO9o6XGUV0xN3+TrdiDMwEYXPE3BP2M5FOM oy+A7E+ejVq0NSCL0CSDaIBy0O2JhBjH2Ze+H4nPxTUgm9bvluDb0ODc6R+sqbJOJ6bk aYcha+i268mdY8EX8Kp39Rgmj1P8zpe9DUCbHJ5aS5Qpare8etIl0PoQ2N9ZeojmJuEn Xtv4Zzhh51YkaJatTUKp6v5wlTFago4lyVeBrELdB3UFIgRUNCXFSK6SFQz+LbTgcITD oz4PLNV//oy0t9ngiVEQ68kJOZ0Yj+hGA6jecklt+02vbaesZZzSKN/s4dsazCtv6rV2 mgFg==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hbTtkZbJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCWGwyVNFagSDjKzvouc6OROV4ry7wxKe9HTskLrIczioxQ4OANd6JAxYy5yTBhXL/smxgJKke8Y82pcciOuOwxG Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k17-20020a0cf591000000b0068c4088317dsi7001861qvm.49.2024.02.04.13.44.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:44:12 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hbTtkZbJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkEs-000245-EO; Sun, 04 Feb 2024 16:41: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 1rWkEm-00022x-BV for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:16 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkEk-0003Vr-Qr for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:16 -0500 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1d7393de183so27249295ad.3 for ; Sun, 04 Feb 2024 13:41:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082873; x=1707687673; 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=PdjLaL1s4T12GYUYF4WyCqbK9Vrp5G+xso0HVv7zwQk=; b=hbTtkZbJlo2GsjUFzTHMv99axI2dUFEC5QQPagb4+c8SQtYtZTRASAPmcDJA8gLvjW /+Ygst5/5etzA5/IxHGbApVc4b2BQoVtiX8xy0h/90YdpeCJCizg0MCvDRo1TJ/mmGJw HB4F+yGZTj9MTPrTGEm2tX93gJUfrH2CPc+Gx2H36YUQQRHbSDOF1ncbHg1na4PieHso EuACX5qsmDMPpaxGcqyVMoAO+YN6uSRpt2UG5DhLSzNTYRCImKNRRYAoPIkAzkOEEqSG OouCFwglgZEjwuKD7ZS3jVtuBaUA5te2nubWzjxhuWLWiPKTpC9cZkWdCJT0azhAthUt fM8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082873; x=1707687673; 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=PdjLaL1s4T12GYUYF4WyCqbK9Vrp5G+xso0HVv7zwQk=; b=JeHZtZah5WIRoCYT+Pm0J2FKmA0Vman/L8L/p+d+3Z3s2wg1JPPVdl8XddaFQuMg9k CJq3JKddgr0rse2TUwhxEkw6O7IXIRnNXgDwYkg4nLe3cE/zsWwbolOX6qPQGhEWWUno g1CjC9rtt0IhzG8fxSW4GmUTwOjJp2RVK5AhWDh9ond1CqLjm3rQPjy+xpU2yW2+fCfv RwR65OaFmPnvVLYdVyS3BQZnQPR+to+sf5n14thK47oFhtChlKtgOM92PI5DNmn5P7W1 8c83jfl7dThF3gLyNDIDayAz0Cjc8fK/u7a/GT3GpZ5X86LJ6M8J4Vi1CdnyqENv3J6u ixvQ== X-Gm-Message-State: AOJu0Ywa2sq/ISdfkL1/J5BEnQvUNWSENV6QO23LQSYns0PL2KQ2CtWM KFHyHwPBjXNweAjC1ELHNLrRKfPvtXWfxrsgWOhGTACPTMGDFuLbgdimzW5AMH3p8Nq60NEnKWd si7Q= X-Received: by 2002:a17:902:6503:b0:1d9:50ca:c4e4 with SMTP id b3-20020a170902650300b001d950cac4e4mr10052932plk.27.1707082873451; Sun, 04 Feb 2024 13:41:13 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:13 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 08/39] target/alpha: Pass immediate value to gen_bcond_internal() Date: Mon, 5 Feb 2024 07:40:21 +1000 Message-Id: <20240204214052.5639-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Simplify gen_bcond() by passing an immediate value. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20231028194522.245170-33-richard.henderson@linaro.org> [PMD: Split from bigger patch, part 1/2] Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20231108205247.83234-1-philmd@linaro.org> --- 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 4b464f8651..e9cb623277 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -453,13 +453,13 @@ static DisasJumpType gen_bdirect(DisasContext *ctx, int ra, int32_t disp) } static DisasJumpType gen_bcond_internal(DisasContext *ctx, TCGCond cond, - TCGv cmp, int32_t disp) + TCGv cmp, uint64_t imm, int32_t disp) { uint64_t dest = ctx->base.pc_next + (disp << 2); TCGLabel *lab_true = gen_new_label(); if (use_goto_tb(ctx, dest)) { - tcg_gen_brcondi_i64(cond, cmp, 0, lab_true); + tcg_gen_brcondi_i64(cond, cmp, imm, lab_true); tcg_gen_goto_tb(0); tcg_gen_movi_i64(cpu_pc, ctx->base.pc_next); @@ -472,11 +472,11 @@ static DisasJumpType gen_bcond_internal(DisasContext *ctx, TCGCond cond, return DISAS_NORETURN; } else { - TCGv_i64 z = load_zero(ctx); + TCGv_i64 i = tcg_constant_i64(imm); TCGv_i64 d = tcg_constant_i64(dest); TCGv_i64 p = tcg_constant_i64(ctx->base.pc_next); - tcg_gen_movcond_i64(cond, cpu_pc, cmp, z, d, p); + tcg_gen_movcond_i64(cond, cpu_pc, cmp, i, d, p); return DISAS_PC_UPDATED; } } @@ -484,15 +484,8 @@ static DisasJumpType gen_bcond_internal(DisasContext *ctx, TCGCond cond, static DisasJumpType gen_bcond(DisasContext *ctx, TCGCond cond, int ra, int32_t disp, int mask) { - if (mask) { - TCGv tmp = tcg_temp_new(); - DisasJumpType ret; - - tcg_gen_andi_i64(tmp, load_gpr(ctx, ra), 1); - ret = gen_bcond_internal(ctx, cond, tmp, disp); - return ret; - } - return gen_bcond_internal(ctx, cond, load_gpr(ctx, ra), disp); + return gen_bcond_internal(ctx, cond, load_gpr(ctx, ra), + mask, disp); } /* Fold -0.0 for comparison with COND. */ @@ -533,7 +526,7 @@ static DisasJumpType gen_fbcond(DisasContext *ctx, TCGCond cond, int ra, DisasJumpType ret; gen_fold_mzero(cond, cmp_tmp, load_fpr(ctx, ra)); - ret = gen_bcond_internal(ctx, cond, cmp_tmp, disp); + ret = gen_bcond_internal(ctx, cond, cmp_tmp, 0, disp); return ret; } From patchwork Sun Feb 4 21:40:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769865 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842403wrc; Sun, 4 Feb 2024 13:43:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IGV6kwQ2nyd4RkjtleWA/BXijTeVPzc4qF2QHuKelGK8xi5v4N0q2QLB1wxVV1BISO8p0PI X-Received: by 2002:ac8:7118:0:b0:42b:e44e:7056 with SMTP id z24-20020ac87118000000b0042be44e7056mr4740297qto.36.1707083027427; Sun, 04 Feb 2024 13:43:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083027; cv=none; d=google.com; s=arc-20160816; b=UKA/ZjkX9taFzLlpS6stl91hZxI8XaogCEGzyCNWAKpa3GTRe5Npfx3jkVwybofjKw s583ryhH/lBHm4kll6qTqweCugEfs6tpCfyPZIZbBaH05HIzwOUv4jImCVtH9o6TJ7Lp mVqRwdyXDZZIP/krZNKx+AEbCwW0Bc11xDNiOc3UGBtsdwzbFNNtUfjvXDfgV5KQQOaW jdd5TanROZw2RKvaZMG1+nVaT4MU8Hg+UbrwoxswyYSJWjvuX3aglvp/zczuYZQ/PE87 8xwMA29yEPPVkwBBAEEXdheL8wnnwykdButxH/ZLBR3HAYD9SHtCEAybPe4KyaNLrZNA 5ZiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ql63af8QTrJWvJEiTJspYZ98jeTo0xtPlbE2bH3uphk=; fh=pzVW+MOY3WTFzO2BsUru77RNIxXZ28+llc26BghTdGs=; b=RXLijN1zQT9rRCvOAnFf75JMY1WDVqYYf+3Pfz6szCfWvpL7nSOr6zGsLz4L3m4Xej JJzxsyJ42m3MKi2zYJthBaUrIId5lynVsVPSdP3YL7/HXHdQD9nIu6G3GH92Vs+klMbA GD9sgbNYQ0Vzuk56afasdj3lgno2nPPfAO0E64MRnVh3/a4YoIy6B4hZXHp0qAXhX5x9 h3m1kD66VdjpHmKVCaxnnZQzH5B3EVh5nQTxIbgrfwT22m+BT/JxbjvAruDrLvuXQyLG 5EchqyO5dVOry9kNtWCnRppa8Tn5AIM+vvLl1RC3FN2tXvFAZc51AADYGGZFRd+jwEj7 J4rg==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="gw/nLbpQ"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCVMQveD4pi45+cwIUr96egRilhR7pDuvQwsf949R6miEC/pFOub2Wn3/fLsSRZHqLIWaoqRbmMNHWPKVSjrVQLy Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c15-20020a05622a024f00b0042c2765fcedsi443838qtx.610.2024.02.04.13.43.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:43:47 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="gw/nLbpQ"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkEs-00024G-IC; Sun, 04 Feb 2024 16:41: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 1rWkEo-000238-9R for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:18 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkEm-0003W2-Od for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:17 -0500 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1d934c8f8f7so30947585ad.2 for ; Sun, 04 Feb 2024 13:41:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082875; x=1707687675; 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=ql63af8QTrJWvJEiTJspYZ98jeTo0xtPlbE2bH3uphk=; b=gw/nLbpQ+FEkCeqFGK+JPc/TSOtb7pX07V43Wg8pUKDfXXB82il/E0MOiQ0ryc2TBZ O1CIlz/KZ607DS2QB4GMBGE/4u/sYAHe2LwQF62zxKcmC8zhqBlImd3ahdoRbJOyggFc cS9+koBkMrrHlzzn2m927nfELa4zsKgQ9214czhSKSWcU+ombl04qTe3shwJiXl7bIf9 2u25N5nmRlBGvqoEsun7Th4D2r+CVbwFpbjLuG+/QPsIqGFdNxnPd75J8DJlljORkwp9 Bz+EibhHMLDN4Od/0gCmSF6qDpLwdaDMG3NvkMt5k8a/3/zhAv0zIwgF1iYdScX6o9bk UUCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082875; x=1707687675; 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=ql63af8QTrJWvJEiTJspYZ98jeTo0xtPlbE2bH3uphk=; b=BY37e/M0Ki33yHdhzRPljg1yYCnuE7esd0h8T3+5UfQdpcmYLKosCG86yuGe6GgHkB oyNquHht/osI2WEoV6D8vSCx79KrdlWfgwXOH4oUveTIg/K8v6IHuk6TeuOh9ycpfnJ6 sD6+vc4/nN5IpnNyL48k7jqCeqGm0Zfmrk+IwLiIAstgGbs9ha8NkjmnoWBQzT5Ly2Iy XQWiVAV/EDIjFNWl1o8jnEGThHMYhvIYwMAFZPoqSkX7m9ifdaQP1JCz9E9YRv9tFvpX DdkDaZnoPSy2DfolisD/z/F2nxpcnAyIuCDE5VBv6pqWzX19sl7ds5XV/w/RLGaiS4is Ngwg== X-Gm-Message-State: AOJu0YwxPlP8+64uvzV9vNk+YYR7pzy4PUOmJXTc8V/ZHl//Y7ALzrUd jCaG0b1+ESHMdUzakNv4A4Ma+MT82bG4TsX9HlOVrVfQWL5OBYZp1o76T97nvXSDR8oUXg94Qsa 5IHU= X-Received: by 2002:a17:902:8602:b0:1d3:45c8:bc0f with SMTP id f2-20020a170902860200b001d345c8bc0fmr10970356plo.46.1707082875496; Sun, 04 Feb 2024 13:41:15 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:15 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 09/39] target/alpha: Use TCG_COND_TST{EQ,NE} for BLB{C,S} Date: Mon, 5 Feb 2024 07:40:22 +1000 Message-Id: <20240204214052.5639-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20231028194522.245170-33-richard.henderson@linaro.org> [PMD: Split from bigger patch, part 2/2] Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20231108205247.83234-2-philmd@linaro.org> --- 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 e9cb623277..566adc4cd6 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -482,10 +482,10 @@ static DisasJumpType gen_bcond_internal(DisasContext *ctx, TCGCond cond, } static DisasJumpType gen_bcond(DisasContext *ctx, TCGCond cond, int ra, - int32_t disp, int mask) + int32_t disp) { return gen_bcond_internal(ctx, cond, load_gpr(ctx, ra), - mask, disp); + is_tst_cond(cond), disp); } /* Fold -0.0 for comparison with COND. */ @@ -2820,35 +2820,35 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn) break; case 0x38: /* BLBC */ - ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 1); + ret = gen_bcond(ctx, TCG_COND_TSTEQ, ra, disp21); break; case 0x39: /* BEQ */ - ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 0); + ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21); break; case 0x3A: /* BLT */ - ret = gen_bcond(ctx, TCG_COND_LT, ra, disp21, 0); + ret = gen_bcond(ctx, TCG_COND_LT, ra, disp21); break; case 0x3B: /* BLE */ - ret = gen_bcond(ctx, TCG_COND_LE, ra, disp21, 0); + ret = gen_bcond(ctx, TCG_COND_LE, ra, disp21); break; case 0x3C: /* BLBS */ - ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 1); + ret = gen_bcond(ctx, TCG_COND_TSTNE, ra, disp21); break; case 0x3D: /* BNE */ - ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 0); + ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21); break; case 0x3E: /* BGE */ - ret = gen_bcond(ctx, TCG_COND_GE, ra, disp21, 0); + ret = gen_bcond(ctx, TCG_COND_GE, ra, disp21); break; case 0x3F: /* BGT */ - ret = gen_bcond(ctx, TCG_COND_GT, ra, disp21, 0); + ret = gen_bcond(ctx, TCG_COND_GT, ra, disp21); break; invalid_opc: ret = gen_invalid(ctx); From patchwork Sun Feb 4 21:40:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769876 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842653wrc; Sun, 4 Feb 2024 13:45:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IFTHz4i+ZuEZcSey/H6R4vwn+X32bhRiNTXNIR/nDv94AoFRiInIDBYz0fv+ulvkW9HRGRF X-Received: by 2002:a05:6808:640f:b0:3bf:db87:186f with SMTP id fg15-20020a056808640f00b003bfdb87186fmr2236066oib.0.1707083114558; Sun, 04 Feb 2024 13:45:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083114; cv=none; d=google.com; s=arc-20160816; b=B1dzdD79kHgR+uymXH7CqZ0g9JcJrJnpQzkYhth35zjAkyZl+CT1bIq0qtguHKLPor Z/BFSJWBjaTBYkEXC4I7eiWnz11Y5Z4g4MgPoPUnTItoAJs+LP2aKHZqRFMegJHDYOAW yWQlQVXRcy6781C5VKW+54LLTwC8q8RUu9qVgl5E12Mc8BkGVZCFCmIryuk260kzllCB HJzw/+leA2ES8AgXhnCnkS2bZ6QzlNDE2o5qhnR5scHYXDcQY7/bjZjqeROZKZ87xf0v HPP64NteGdbksCtVK4Zhtx6u1j6arWMCy4Cs/8LCdy9fQXw4/Yic9i5xgQijeF7VDapJ IS/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=flGmqvYthRKnWcX4jGxDQrsUCR7InVU8Hdnql3IBa7U=; fh=Z7j8N8Rb5qQ31tPdtUQ8NCam11ge5fkgHmdBE2C65gM=; b=SVaVRdc5QuNgW1ulvxVOGFOMy2x3mzG/6Qh8RO4Qw98bC728kcBZ8hLvl7+nSBaiDm 3zUl2lYmcu7hG9TmVzpMGI8exLoAhBlHRq1CA+q4SsA2+FXWIScHETH2XicNrEjd8T/6 ZCwuF3+JnEna0lquLax5UUbkGMzRFz1wothFgCz3zqWUG5K7WUEFCcVrFnFzkGH2aS/8 JbqlALLD7/TBzX0Ad+UwEWnPja8omnjbaUraPGg4PtqCGi4XpSDbYlPnxpXiKUxdefkH bY+FuCBcmJDpdHc6OnI/Of8lDRDyVkNjyuWn5DldOI2/Si8Rp1zBQCmNS128hp4552d6 S6Sg==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f+Re3r5K; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCU3uu5V3OzBUtgzBuFbElJLCNL9vKxWc7yg5q1j7WORJz1ShU+MqFnzc4CCge63DElEfhsPD4RpS/tWLQa3HQtf Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h19-20020ac85e13000000b0042bed30bd76si7163171qtx.421.2024.02.04.13.45.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:45:14 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f+Re3r5K; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkEw-00026f-S6; Sun, 04 Feb 2024 16:41:26 -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 1rWkEr-00023r-3B for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:22 -0500 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkEp-0003WE-IA for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:20 -0500 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1d751bc0c15so32846495ad.2 for ; Sun, 04 Feb 2024 13:41:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082877; x=1707687677; 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=flGmqvYthRKnWcX4jGxDQrsUCR7InVU8Hdnql3IBa7U=; b=f+Re3r5KhUFK/XfQHWLhvLWnl/cMGJqmLTnIsmlA+rZV9khswLsZohCLKoFxUH3vPP Xc40sQmwxcEO6ckkygohwBW1TSp1SeSJxqC7B077SL8nsKrROl1yP1PAnEjhqA8eRkKN pdOxYEkYWHASta6RNHpCfp+NZ/33pRBIak/cPPSohvz+dtgDUhdDZF+fEd1uUOUO4iet q5u3+2sA6FO9nCt+z53IP4QWIBm5Kn8KZe5v/GfCRmPewbNFQoByo4vCQ7lJRwV/JBrQ +4W7Byo9JAzbFDKWVAlLgWDKsf8Iv8Kpj04SXBDTqXxn9tlEfWt3JBYN4rPV5kOX4XGs rM1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082877; x=1707687677; 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=flGmqvYthRKnWcX4jGxDQrsUCR7InVU8Hdnql3IBa7U=; b=QRlMgGo1a1TEGr69pu2dnQWuPBGa8Rbkb0zcEfBq3wMkoveKWND+S0e9D0iwWmFS8D 1jryfaozehOCoTr/5/CG2dGlNh3SaSKdMaJUHhGJgUkoGPEjwwdxqenJ7b7faGonEC8E tVZCHelFZFfCUwyYcO0336Ipv+9tuKSPSJHuYkUjCMm0iBUofMnNZqzanoKvMr5uDaL6 F1H7kSmX3i+zGNvYfRvPLdVwntun3x8JDfokC9tie0H+1lzh2hUMzrmYzOFq69BH1nxg q/8l5hcWRms5VpLRm54aDjbRDt9ZV4J6XL1OMdspCySqBVVuvZJUN56uQyC8a1cjC0ds +/7A== X-Gm-Message-State: AOJu0YzxiqBenCYvp2XkUhN5Ml3W1R4RgHRSimZWVQGyCbFKP5KqmAIO Eqe+9HacnJU1XkgaxGHfRF+IAvHD7igFa0Dp3gb5ob5v2DL7bdGGStu2YX4laCjRjFUFvniQAuL oO2w= X-Received: by 2002:a17:902:eb82:b0:1d9:8082:4573 with SMTP id q2-20020a170902eb8200b001d980824573mr9357779plg.2.1707082877528; Sun, 04 Feb 2024 13:41:17 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:17 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 10/39] target/alpha: Use TCG_COND_TST{EQ,NE} for CMOVLB{C,S} Date: Mon, 5 Feb 2024 07:40:23 +1000 Message-Id: <20240204214052.5639-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/alpha/translate.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/target/alpha/translate.c b/target/alpha/translate.c index 566adc4cd6..220eda2137 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -1676,16 +1676,12 @@ static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn) break; case 0x14: /* CMOVLBS */ - tmp = tcg_temp_new(); - tcg_gen_andi_i64(tmp, va, 1); - tcg_gen_movcond_i64(TCG_COND_NE, vc, tmp, load_zero(ctx), + tcg_gen_movcond_i64(TCG_COND_TSTNE, vc, va, tcg_constant_i64(1), vb, load_gpr(ctx, rc)); break; case 0x16: /* CMOVLBC */ - tmp = tcg_temp_new(); - tcg_gen_andi_i64(tmp, va, 1); - tcg_gen_movcond_i64(TCG_COND_EQ, vc, tmp, load_zero(ctx), + tcg_gen_movcond_i64(TCG_COND_TSTEQ, vc, va, tcg_constant_i64(1), vb, load_gpr(ctx, rc)); break; case 0x20: From patchwork Sun Feb 4 21:40:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769862 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842346wrc; Sun, 4 Feb 2024 13:43:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IFhltqIdB79GTRuK+gp3o5rvp4+zYImHYOYmoCWsEvqhjVBGVEHcLqVKJ/OlPh0Qzi97DOC X-Received: by 2002:a05:620a:214f:b0:785:60a2:c798 with SMTP id m15-20020a05620a214f00b0078560a2c798mr6170888qkm.46.1707083005671; Sun, 04 Feb 2024 13:43:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083005; cv=none; d=google.com; s=arc-20160816; b=VG9iIN5ZbaQ0fTeutHJVAfPSC+YhVBUO1Uy985TSvk7ZhdWELXyy+WbEqRCSdPVIIr S2eWaM+ZA9vvQxcHkobJHUsQveIg4dPePYMbyL5KbdwLjsP7/p85ERBoTip4z8H85JUR f9qARUZx52S1U8QQinkfX+dZZ7UFyj9gKnkiybDbjfXmRzmboWIcgpWWHKJjq2Cujed1 uG1fOOCeoIX3b8guZ4MML/erLjTWXsX8y9HLMVOY4AaQtYR1s7Q4NRPnefLN+FeC9Ibz JyQrynAuqTDux/GLKnM35+1AFX01RyT229vbCCAd7k9BnIdubBMFq9hXsZD32NEF/NiK XoDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QUVZCd5J0t9hl0sHMhDVNqIs8ATVsECXvY1CwvamRqY=; fh=68Jrg3f1vTbasa3qZymmZLpjVcVeiOqlM9OyRis4Kcw=; b=pPIpVvKREBWgXu1pG4SdXhyv5TLYvCw0cQA7pllZiRoVx7avJPuPKLCvPXUKBF9KiB Ysk59ui48og05U+dIBP8j+h0VyTO4vMq7uIUSaVzXxdZHvUpN9Rl/MiTdrOz7sZbYQOE ozQTs7BYycoYezEzECGlQT0+ktRVFGo4Ih6ALOMAdPkcfU5f43/KgesC214czzZazs7m KEpPJqSQltYJkI+FAS6znoZ2A/8Qa6WEUtY7jsYzY5oLMz2KsQNkJPrAcYF07LWnTftb y6+sM+5/y1pyQevb0Vl/3wV19+CoBgLtPDACQiBPVTMd4PRI8EOF5KLR2WwwXfDju8mW RW/Q==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Jo/CuqwT"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCUAAf1Um18UCCvW/enVm9kPu/94xWWWONvpWJKrHRFD80rFeLrOrlJruy0JiaA2PEa8XMRhDaeSifpZ1pVgzR++ Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b13-20020a05620a04ed00b007856eda4f99si3323656qkh.329.2024.02.04.13.43.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:43:25 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Jo/CuqwT"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkEv-00025s-99; Sun, 04 Feb 2024 16:41:25 -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 1rWkEs-00024K-KG for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:22 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkEq-0003WN-T2 for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:22 -0500 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1d94323d547so29784445ad.3 for ; Sun, 04 Feb 2024 13:41:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082879; x=1707687679; 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=QUVZCd5J0t9hl0sHMhDVNqIs8ATVsECXvY1CwvamRqY=; b=Jo/CuqwTtE9S1/udy1TBfhqSLavhhGzNiUYSCcOeskTUDbqBopOct+z26jo5sNQ/l0 eJdgY5nmrUmrnlO80DpZrhFmOBSjLiEN5tjuLJN5vzIRgaLR7AIku37a3F1vD4F/ngr9 T+aCF9DNafID1MUuEeiElKwc+meWVH+R339SMCx6XgUJw49U8AFVCb6mwhb67W6WGGEl aCoi2uCZ58ACJvzxASni5nfD1wiG4lUZcrrqWe+LfYozElVq7+QjxnI0SriG0CStvTDy J/UQ3r3DU/3YD5CXkvAPHVwepAqVDm6TUkp/8D+VTasct0AYMMn7UEPp4BPggtZV4RtA W0VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082879; x=1707687679; 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=QUVZCd5J0t9hl0sHMhDVNqIs8ATVsECXvY1CwvamRqY=; b=WPIccwbxiwVrHU9ja956wIeuIMHydM+1eWzGIyUPc1WNy9H8QeU6hNDLH6nfGH5Zsc 992cUKoOtHgxj8u08PywZH6ciXY7pl0/ltuu8UAkCiJjZYPL9CDR8e5VkBtum8+oFpn+ KJ/GbksZYVoOJv7L9ke5jLwYCrwg28CdBbxAhkL9C12ADPpZ6AXn2R30YFbjSbyRR4Rr 5jr/7JgVN3lb+oQxvV4MuP9Iv3aekb8RUklwZFPq95rSt0vO1IDJdAKXndEnelZxD5FP OMk1mRP6RcXU7v01mgX+CBtCk11688AsVWAqtgVAvlQ6PWonFIoeTMAUBDTL2atRtFx8 d82Q== X-Gm-Message-State: AOJu0YzQn9I6P1AP0XdxiUvf2WZkPM1wp9UJc8TuZbqMwYmsPIviVkvf C5a7SrRMiJMmrOnTev3asCUtsiDlbE6GoOUeUiWWPdJq1y9sySsnDiVkUDX9R0ij6wjGQ7JR2Ae iswU= X-Received: by 2002:a17:902:e804:b0:1d9:bd8d:d81e with SMTP id u4-20020a170902e80400b001d9bd8dd81emr353954plg.47.1707082879566; Sun, 04 Feb 2024 13:41:19 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 11/39] target/alpha: Use TCG_COND_TSTNE for gen_fold_mzero Date: Mon, 5 Feb 2024 07:40:24 +1000 Message-Id: <20240204214052.5639-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/alpha/translate.c | 49 +++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/target/alpha/translate.c b/target/alpha/translate.c index 220eda2137..882cf6cea0 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -490,56 +490,53 @@ static DisasJumpType gen_bcond(DisasContext *ctx, TCGCond cond, int ra, /* Fold -0.0 for comparison with COND. */ -static void gen_fold_mzero(TCGCond cond, TCGv dest, TCGv src) +static TCGv_i64 gen_fold_mzero(TCGCond *pcond, uint64_t *pimm, TCGv_i64 src) { - uint64_t mzero = 1ull << 63; + TCGv_i64 tmp; - switch (cond) { + *pimm = 0; + switch (*pcond) { case TCG_COND_LE: case TCG_COND_GT: /* For <= or >, the -0.0 value directly compares the way we want. */ - tcg_gen_mov_i64(dest, src); - break; + return src; case TCG_COND_EQ: case TCG_COND_NE: - /* For == or !=, we can simply mask off the sign bit and compare. */ - tcg_gen_andi_i64(dest, src, mzero - 1); - break; + /* For == or !=, we can compare without the sign bit. */ + *pcond = *pcond == TCG_COND_EQ ? TCG_COND_TSTEQ : TCG_COND_TSTNE; + *pimm = INT64_MAX; + return src; case TCG_COND_GE: case TCG_COND_LT: /* For >= or <, map -0.0 to +0.0. */ - tcg_gen_movcond_i64(TCG_COND_NE, dest, src, tcg_constant_i64(mzero), - src, tcg_constant_i64(0)); - break; + tmp = tcg_temp_new_i64(); + tcg_gen_movcond_i64(TCG_COND_EQ, tmp, + src, tcg_constant_i64(INT64_MIN), + tcg_constant_i64(0), src); + return tmp; default: - abort(); + g_assert_not_reached(); } } static DisasJumpType gen_fbcond(DisasContext *ctx, TCGCond cond, int ra, int32_t disp) { - TCGv cmp_tmp = tcg_temp_new(); - DisasJumpType ret; - - gen_fold_mzero(cond, cmp_tmp, load_fpr(ctx, ra)); - ret = gen_bcond_internal(ctx, cond, cmp_tmp, 0, disp); - return ret; + uint64_t imm; + TCGv_i64 tmp = gen_fold_mzero(&cond, &imm, load_fpr(ctx, ra)); + return gen_bcond_internal(ctx, cond, tmp, imm, disp); } static void gen_fcmov(DisasContext *ctx, TCGCond cond, int ra, int rb, int rc) { - TCGv_i64 va, vb, z; - - z = load_zero(ctx); - vb = load_fpr(ctx, rb); - va = tcg_temp_new(); - gen_fold_mzero(cond, va, load_fpr(ctx, ra)); - - tcg_gen_movcond_i64(cond, dest_fpr(ctx, rc), va, z, vb, load_fpr(ctx, rc)); + uint64_t imm; + TCGv_i64 tmp = gen_fold_mzero(&cond, &imm, load_fpr(ctx, ra)); + tcg_gen_movcond_i64(cond, dest_fpr(ctx, rc), + tmp, tcg_constant_i64(imm), + load_fpr(ctx, rb), load_fpr(ctx, rc)); } #define QUAL_RM_N 0x080 /* Round mode nearest even */ From patchwork Sun Feb 4 21:40:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769848 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1841994wrc; Sun, 4 Feb 2024 13:41:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IE3iZ1TwG4I8+bCyJ+U32WeXrghcRCPr4g/55thZpVFzYaeQiv/4V9Z1uMMH7ego4ZmKcr2 X-Received: by 2002:a05:620a:1da8:b0:783:df50:1e71 with SMTP id pj40-20020a05620a1da800b00783df501e71mr11646188qkn.30.1707082904949; Sun, 04 Feb 2024 13:41:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707082904; cv=none; d=google.com; s=arc-20160816; b=WQOm0HcQMQxIblnTsLl6KB4J20VcxT/peYhxQIHDJ6QzLbtFEuiA7OhdMDM8aIg6Wz Mb5dX+S+gL2CCGzwynTV1tLRM8I7/DBO5I8nGKaeCFxImi59V72+ATUe9OXf2ugJ5QNc /mWcBO/mbfKfBndITwOveHCPKXKsv3in29WLk1RBb0kli5jvJ9WFBpLGVTspC83mSfRu iE3uERrvJG9A0vbMR5mI0uKvid4nAN9ITRzQGdUfWx466OcNV0TqySDOqUL9SAvxoj8W As+D/RFtbDZ/V9M9ODwG8d6OX/1xbJK9URHHZ2tCRa1+v1Dkp8eQ5hmVyrc+kKvBqzPO uSyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3vyZhh9F6fWmSs4Bpq5S+VCME8YHT+VYlvyj+usF/4Q=; fh=Ij8GUjkD/X3shQIO3LUwEHQWxX6ofnW9arF8fVLJJV0=; b=ADTkXJGr76K5p34ur4bb/3uY/ifr1m4JvsobcF8M/b+jDhsy9KlNvgpwWU5XSzyU1i N+BBp+f1bQlAYCewS1qj6VWpuGhDs00mHxFMZdfazytqaoMZnho/ygmug+3CwT/NS2Yv KnRjWaShFzF99+L6I76lb9Vmq0ptbOAWJSpzk4/kDmHvhNW47My0ki80/69ck3v/RDnO PzrQGVXrRr/pKXrU7vnJ0IKdtH7tsdcZ0ruzIkdDsKTvJ4dZ4lS1Bn6uXfB4gm+ekKuG mllckBWFUqKA6nO71ulY7pUca9ywQd7CjTz2j79xPbT3fst1FZ2PUSqKfXFKWPsqZqXv 3FaA==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="PC1VR/SY"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCVii94wXwKkhwb0o8yuUJnX60YVePY7YJkue2tAwnxJTWMEdqzTnhJFsddc561pNYxysi0hUY+VrrIXzu1Dl/m6 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c28-20020a05620a135c00b00783b5c83466si7048581qkl.336.2024.02.04.13.41.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:41:44 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="PC1VR/SY"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkEx-00026y-KJ; Sun, 04 Feb 2024 16:41:27 -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 1rWkEu-00025Z-Kr for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:24 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkEs-0003WX-Rf for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:24 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1d751bc0c15so32846735ad.2 for ; Sun, 04 Feb 2024 13:41:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082881; x=1707687681; 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=3vyZhh9F6fWmSs4Bpq5S+VCME8YHT+VYlvyj+usF/4Q=; b=PC1VR/SYbxSyifvT2XaiBH7/cbKT5k2dU4ynhrdyvJQPHxoiEEJUEdrtsWnVIKhMA0 aiU+du57V9hwcCEgEsPDje2KY7xaDoav9vva2E98sGDkUsBY9sgSAk8BcBuXU+8VuFGs TIuvpi0d7RCSNI8iNp//VEfq8WZ6c06rrzW1Z0P+8EIVxsVcmkV/UQ4SQGNVax1k1kc3 cJBHXiLat/Si8sBzayM0B4AESmDdk7GyJ7Tn3NPlwo2j+HkDsHohqF/r0bddiecDHM7R TdPXU2qVbVFluUsPArfedO2tPuOk7P3Ogo3uZEwAM3tjVHWftLb2hfX2Nr5hN3pisC5g RRSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082881; x=1707687681; 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=3vyZhh9F6fWmSs4Bpq5S+VCME8YHT+VYlvyj+usF/4Q=; b=TwFF1o1sL9cC6BduFA0mNGhTOtHikn2aQBnnaKQylcDDZkvyntExU74Eti+lPlqV7T 9f+xzbxgv0SG24e51XZiZ3aMqYaO/QPIeDUt0acb5eYiaMOQvCcCZPwhiExNTYm4UPU/ dlxusi4AAVbEmilaLjOZMA8+InXlLx67kfR/SUfvDjhg30Yk0aT9xT6FAMMQrlEdEtu2 l45voAuvPlKq7m9IRxDSXuJwzsZ2GvVaGqnbm4OrpmX/MeUUEkXx9UKvybNDgd3vSaur 894GQfR34ShUdgBkNL+602gkInUm9IuF0aapr2Qb9L8zM/H3GBo8sBytZEAUage3NWnN NLBw== X-Gm-Message-State: AOJu0YwXEW2lN5hTBgd8wOZTFWtO9oNyTC12BljS/ms3Qpk38IqhoKIR qL9c05+4t3O3ydcSLINhywqZbvjzkl2GYOTH6dUoBkNZFPEAKudvJAmx5qdm0qMemtTYVUdsHP1 jjY4= X-Received: by 2002:a17:902:e750:b0:1d9:bf28:8bda with SMTP id p16-20020a170902e75000b001d9bf288bdamr265739plf.68.1707082881600; Sun, 04 Feb 2024 13:41:21 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 12/39] target/m68k: Use TCG_COND_TST{EQ,NE} in gen_fcc_cond Date: Mon, 5 Feb 2024 07:40:25 +1000 Message-Id: <20240204214052.5639-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/m68k/translate.c | 74 ++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 41 deletions(-) diff --git a/target/m68k/translate.c b/target/m68k/translate.c index f886190f88..d7d5ff4300 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -5129,46 +5129,44 @@ undef: static void gen_fcc_cond(DisasCompare *c, DisasContext *s, int cond) { TCGv fpsr; + int imm = 0; - c->v2 = tcg_constant_i32(0); /* TODO: Raise BSUN exception. */ fpsr = tcg_temp_new(); gen_load_fcr(s, fpsr, M68K_FPSR); + c->v1 = fpsr; + switch (cond) { case 0: /* False */ case 16: /* Signaling False */ - c->v1 = c->v2; c->tcond = TCG_COND_NEVER; break; case 1: /* EQual Z */ case 17: /* Signaling EQual Z */ - c->v1 = tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_Z); - c->tcond = TCG_COND_NE; + imm = FPSR_CC_Z; + c->tcond = TCG_COND_TSTNE; break; case 2: /* Ordered Greater Than !(A || Z || N) */ case 18: /* Greater Than !(A || Z || N) */ - c->v1 = tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, - FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N); - c->tcond = TCG_COND_EQ; + imm = FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N; + c->tcond = TCG_COND_TSTEQ; break; case 3: /* Ordered Greater than or Equal Z || !(A || N) */ case 19: /* Greater than or Equal Z || !(A || N) */ c->v1 = tcg_temp_new(); tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A); tcg_gen_shli_i32(c->v1, c->v1, ctz32(FPSR_CC_N) - ctz32(FPSR_CC_A)); - tcg_gen_andi_i32(fpsr, fpsr, FPSR_CC_Z | FPSR_CC_N); tcg_gen_or_i32(c->v1, c->v1, fpsr); tcg_gen_xori_i32(c->v1, c->v1, FPSR_CC_N); - c->tcond = TCG_COND_NE; + imm = FPSR_CC_Z | FPSR_CC_N; + c->tcond = TCG_COND_TSTNE; break; case 4: /* Ordered Less Than !(!N || A || Z); */ case 20: /* Less Than !(!N || A || Z); */ c->v1 = tcg_temp_new(); tcg_gen_xori_i32(c->v1, fpsr, FPSR_CC_N); - tcg_gen_andi_i32(c->v1, c->v1, FPSR_CC_N | FPSR_CC_A | FPSR_CC_Z); - c->tcond = TCG_COND_EQ; + imm = FPSR_CC_N | FPSR_CC_A | FPSR_CC_Z; + c->tcond = TCG_COND_TSTEQ; break; case 5: /* Ordered Less than or Equal Z || (N && !A) */ case 21: /* Less than or Equal Z || (N && !A) */ @@ -5176,49 +5174,45 @@ static void gen_fcc_cond(DisasCompare *c, DisasContext *s, int cond) tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A); tcg_gen_shli_i32(c->v1, c->v1, ctz32(FPSR_CC_N) - ctz32(FPSR_CC_A)); tcg_gen_andc_i32(c->v1, fpsr, c->v1); - tcg_gen_andi_i32(c->v1, c->v1, FPSR_CC_Z | FPSR_CC_N); - c->tcond = TCG_COND_NE; + imm = FPSR_CC_Z | FPSR_CC_N; + c->tcond = TCG_COND_TSTNE; break; case 6: /* Ordered Greater or Less than !(A || Z) */ case 22: /* Greater or Less than !(A || Z) */ - c->v1 = tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A | FPSR_CC_Z); - c->tcond = TCG_COND_EQ; + imm = FPSR_CC_A | FPSR_CC_Z; + c->tcond = TCG_COND_TSTEQ; break; case 7: /* Ordered !A */ case 23: /* Greater, Less or Equal !A */ - c->v1 = tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A); - c->tcond = TCG_COND_EQ; + imm = FPSR_CC_A; + c->tcond = TCG_COND_TSTEQ; break; case 8: /* Unordered A */ case 24: /* Not Greater, Less or Equal A */ - c->v1 = tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A); - c->tcond = TCG_COND_NE; + imm = FPSR_CC_A; + c->tcond = TCG_COND_TSTNE; break; case 9: /* Unordered or Equal A || Z */ case 25: /* Not Greater or Less then A || Z */ - c->v1 = tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A | FPSR_CC_Z); - c->tcond = TCG_COND_NE; + imm = FPSR_CC_A | FPSR_CC_Z; + c->tcond = TCG_COND_TSTNE; break; case 10: /* Unordered or Greater Than A || !(N || Z)) */ case 26: /* Not Less or Equal A || !(N || Z)) */ c->v1 = tcg_temp_new(); tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_Z); tcg_gen_shli_i32(c->v1, c->v1, ctz32(FPSR_CC_N) - ctz32(FPSR_CC_Z)); - tcg_gen_andi_i32(fpsr, fpsr, FPSR_CC_A | FPSR_CC_N); tcg_gen_or_i32(c->v1, c->v1, fpsr); tcg_gen_xori_i32(c->v1, c->v1, FPSR_CC_N); - c->tcond = TCG_COND_NE; + imm = FPSR_CC_A | FPSR_CC_N; + c->tcond = TCG_COND_TSTNE; break; case 11: /* Unordered or Greater or Equal A || Z || !N */ case 27: /* Not Less Than A || Z || !N */ c->v1 = tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N); - tcg_gen_xori_i32(c->v1, c->v1, FPSR_CC_N); - c->tcond = TCG_COND_NE; + tcg_gen_xori_i32(c->v1, fpsr, FPSR_CC_N); + imm = FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N; + c->tcond = TCG_COND_TSTNE; break; case 12: /* Unordered or Less Than A || (N && !Z) */ case 28: /* Not Greater than or Equal A || (N && !Z) */ @@ -5226,27 +5220,25 @@ static void gen_fcc_cond(DisasCompare *c, DisasContext *s, int cond) tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_Z); tcg_gen_shli_i32(c->v1, c->v1, ctz32(FPSR_CC_N) - ctz32(FPSR_CC_Z)); tcg_gen_andc_i32(c->v1, fpsr, c->v1); - tcg_gen_andi_i32(c->v1, c->v1, FPSR_CC_A | FPSR_CC_N); - c->tcond = TCG_COND_NE; + imm = FPSR_CC_A | FPSR_CC_N; + c->tcond = TCG_COND_TSTNE; break; case 13: /* Unordered or Less or Equal A || Z || N */ case 29: /* Not Greater Than A || Z || N */ - c->v1 = tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N); - c->tcond = TCG_COND_NE; + imm = FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N; + c->tcond = TCG_COND_TSTNE; break; case 14: /* Not Equal !Z */ case 30: /* Signaling Not Equal !Z */ - c->v1 = tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_Z); - c->tcond = TCG_COND_EQ; + imm = FPSR_CC_Z; + c->tcond = TCG_COND_TSTEQ; break; case 15: /* True */ case 31: /* Signaling True */ - c->v1 = c->v2; c->tcond = TCG_COND_ALWAYS; break; } + c->v2 = tcg_constant_i32(imm); } static void gen_fjmpcc(DisasContext *s, int cond, TCGLabel *l1) From patchwork Sun Feb 4 21:40:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769861 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842338wrc; Sun, 4 Feb 2024 13:43:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHzLMx+/EG/85y0Z6dM6/kk4I92YYRCZY2AZsZp2PVQpwL5qxREoremoqV4xSMNpATPG5Jl X-Received: by 2002:ac8:714d:0:b0:42c:b29:ad6a with SMTP id h13-20020ac8714d000000b0042c0b29ad6amr6788636qtp.31.1707083004186; Sun, 04 Feb 2024 13:43:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083004; cv=none; d=google.com; s=arc-20160816; b=Kqsjmmm5BtTuJQt4aLvAt7TSIAE3xH+eg2txikEVJUQ6BG2SBRQiOIIqvjVmQ3pLPJ 4TW8KaMmEOp+pcN40HWHnHFesZM58wJJyHGpG5wdjNFo+nImshZp4AIbeZ12Ux1XsKLN HkLR+/hyfzAVij1IVqzkHJHsko3O0K5xlEzzFXT9GH2scSBGeQB5QaAqDCULvOK4979h IE0EaQdO/bKg9tekpK5Fbhq1Q+bbiMXElqsbHoKyjRlLWBdVKicya6p0NzUX1vV7HoOf CLcUiFGTY4/bx0dXfRzL8oOfXdufEgekhIGGldspBL5IC5k6r0uR0perIEOVDzk18XXe 5iew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Mppe2/7nayBXlypsR6xMk/9OKA8uIp/hf0zJVbJSgnk=; fh=3HffvhHX9LmrVu6o+B8R4VZbQl0v9bqbe5e9GAYJ6/Y=; b=ACZBu22FvGXRktNdpSo+cPe/R/YK3/SG3yjTcMrPG/ibywlWpbz6GgsF/Tl+90QmnP qFDvIHT/ci3mxr+44DWgb+j3eNoMe5ZJoTlQ/V0m0mTvbgQ05ZCpjGGC4DHk39grTyD8 lzOGldb0Ud1+NVtMQANFFmmPPso3UYavTHoYu2zT1RvVRi4BE+/OOW8EaYNNdAIJLXT4 5WUcQWgLnCHVhH1rjCJYcF4jrSh+M6Km9wRm3tuSO6y65Wt9d8SBVnmqrc0F1DuRSJrF lqnrN0MMVlkdJALRtL7EDyJZXBb3Tt4Jx8sncfJtKDrFJRYlV7oyzhLhwYJl3u9K2+Rw F0ug==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QrBqKVJu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCWehyTBY9TTlNjiBTnPpuV9BaLYw5NJTWKWoJM9hWV+9VYfOncMWikp6UAMglVyLYjoP0Zv//s03rlqHtCcYQer Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f8-20020a05622a104800b0042a8967cdb6si7339195qte.533.2024.02.04.13.43.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:43:24 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QrBqKVJu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkEy-000277-6r; Sun, 04 Feb 2024 16:41: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 1rWkEw-000267-C4 for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:26 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkEu-0003Wk-Ri for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:26 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1d958e0d73dso19351635ad.1 for ; Sun, 04 Feb 2024 13:41:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082883; x=1707687683; 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=Mppe2/7nayBXlypsR6xMk/9OKA8uIp/hf0zJVbJSgnk=; b=QrBqKVJuFlBzRqgz/UF3XyZ7jYEH7N9K3r3pzZL1/iR/ffTvACmJi7y9PgFqbo5y9J hnwCQioDmql1P6hx10a4fT55wp4FRf/yht8PvP9ECYAzvCE+tj7eO+0Hzpe8OlVnk1is Bx3A/HUFSlPme8y23Ih8SqXwR2ATOwD92Bj0xrn3DDCPeavDSYRytsZPFcCwrA7EcHlO qHkVamgrpWz60ec3eBG5GEtAsj48xfVjSg/RONAD4f7vy0mAmOJX9LDe7Xf0cksaN0v0 R25wDcIfjNz2ZRZ4OLhCA5gnzZ5qbOdSLeggjBn2d1X1apcieXuHWwYnRxY8gicdVBv4 BKow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082883; x=1707687683; 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=Mppe2/7nayBXlypsR6xMk/9OKA8uIp/hf0zJVbJSgnk=; b=tp1hJI8//TvrtBwwSs+bU6Tp3zVpJIZKrpnBoIlbYlz/dyAasvLV6ax69F3re7mLuU W8AK5Q5xXJm53o7NilGXDwAZXZXhHqHCWNuj1NtrrlKs03FGsB9rYm7AuMMF4ULTZQst KjKaHBgZvcOwKDhurX9dNr3LNKyYPeSNe9YAn+ddYKs+ypDGpfe8Ou1E2pnigyiE8uj0 34+2l17bULHW2AiaHPnIfY/kc9U+YjTgtnB9ro6JSfmTMLxB48HWa0qIo9PmuQa1K/M3 DrE6fat52SxLepVRIjQ5MZana2PixO2j8dKrm+nZoDcmA9Er4wg3HrVzlEAQYviZHqPb ipaA== X-Gm-Message-State: AOJu0YwM8OvvhyzR5Dkg3FONzgPYSNdmvPL/TKIm7yvlWRcE3JP3Xu6A pryNPo0aOt4K0JtVjl3hQ5RKsDs+1cMs3SGFi536ZWL6xbnMbHOY6ZfXwr63c4RSfJvielQTaJy c2gE= X-Received: by 2002:a17:902:e752:b0:1d7:57e1:5202 with SMTP id p18-20020a170902e75200b001d757e15202mr6877929plf.20.1707082883626; Sun, 04 Feb 2024 13:41:23 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:23 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 13/39] target/sparc: Use TCG_COND_TSTEQ in gen_op_mulscc Date: Mon, 5 Feb 2024 07:40:26 +1000 Message-Id: <20240204214052.5639-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/sparc/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 7df6f83b13..d9304a5bc4 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -488,6 +488,7 @@ static void gen_op_subccc(TCGv dst, TCGv src1, TCGv src2) static void gen_op_mulscc(TCGv dst, TCGv src1, TCGv src2) { TCGv zero = tcg_constant_tl(0); + TCGv one = tcg_constant_tl(1); TCGv t_src1 = tcg_temp_new(); TCGv t_src2 = tcg_temp_new(); TCGv t0 = tcg_temp_new(); @@ -499,8 +500,7 @@ static void gen_op_mulscc(TCGv dst, TCGv src1, TCGv src2) * if (!(env->y & 1)) * src2 = 0; */ - tcg_gen_andi_tl(t0, cpu_y, 0x1); - tcg_gen_movcond_tl(TCG_COND_EQ, t_src2, t0, zero, zero, t_src2); + tcg_gen_movcond_tl(TCG_COND_TSTEQ, t_src2, cpu_y, one, zero, t_src2); /* * b2 = src1 & 1; From patchwork Sun Feb 4 21:40:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769858 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842275wrc; Sun, 4 Feb 2024 13:43:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IEyvBsZiNrJTK/Rtp2PeMHvz7bd4wB74jkEbYHW7cxdgj+pCtAufNQvKz7TncWf69csxccL X-Received: by 2002:a05:620a:1226:b0:784:8c3:3503 with SMTP id v6-20020a05620a122600b0078408c33503mr9002062qkj.30.1707082988970; Sun, 04 Feb 2024 13:43:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707082988; cv=none; d=google.com; s=arc-20160816; b=Gwu+K/JDLfabryaPg/GT1Q9pDp4fYXdiqzv23CxaaWWjz3uahXi5aC4cVXjzLKV0n6 K4aJ1sYmt1AOfCh1QYZgqdhzbNFgbjjhsQ9FjyEYafxhW6a04bjZGzO1EBHlrcGY1hHs PyUIIt/C6xunCyFju3jInnMAtUxo3mmCdlc1in+Ey2lErHghIMBR0o8qRs6AuCPf6Vd/ IfTWNwihfUuf93jIsSRA4/2M7rxD3jKZErIcZiWIs1BkHCXmoFGgpsXsaS4RS3d4r2l3 hfCtITelm2xCpvOjAbOc88UH2v+01sSqdRvOK9Orrz+Ev2HkA5krCKll3CRCQ2qVdaiu HacQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cadphwjaQtxJbfsAaQ8Tf54zJ/KIUtYE/z1XZRnv4ls=; fh=HzRDhqFXUvBnCUufIWd9t17y4Q2CamcYNfihKwTPeU4=; b=yvSm4Mo2Hg0ydw4XtpzeHOiKZFJ+WRBWlmm41DhDN91MpMnp3RVkamJA08IYCGf5Qw lisXMoyd4us+XsWPfqVtqq1+2h89DdwOQ3RpPmtriXfCVVeGlNHy04ceZ6duYFhhGE29 L9ap3JH7HvgcMTU35Y7FhA7UkWXZEvvX7xbTi6uSPbn5Mjxjx0WENqHfrDvTJXJ+d4ga lBFNpJavi2iAR54xfJDSatauJ6fuclVv4JlPsemzPvZW8317t4O8a613V1O+jjRMtiS5 C4gE7uJ1Q7WnzR+9BZzotzmnkXKQYq5pO1sWgOptvryJE08yuqFIHY6ciEwR7MrncPC9 UHIA==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ku22g3nG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCUla0mAv2e6Oqi02ZnGLsCxtWVdkzKm5B9lkTDMuAabgZkq8S4E21qHl4mOQKFPMFNhnWNixzml1+ILAAWa82D7 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 17-20020a05620a04d100b007857ad9bd10si1753775qks.315.2024.02.04.13.43.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:43:08 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ku22g3nG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkF0-00027W-E1; Sun, 04 Feb 2024 16:41:30 -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 1rWkEy-00027M-Jt for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:28 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkEw-0003Wx-T4 for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:28 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1d7881b1843so33273865ad.3 for ; Sun, 04 Feb 2024 13:41:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082885; x=1707687685; 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=cadphwjaQtxJbfsAaQ8Tf54zJ/KIUtYE/z1XZRnv4ls=; b=ku22g3nGIuWxxSCPbBcJd3oPlrdueh62068hPqewhZklqkBz2mPJbmvHFeuMmIytOb 4jGvXhrIaQungek92sEULLt94mGB/V5tmbp2bP4VkIyUgCyukuT9BxeUeOLAaqFUnLfm e5udlxLwS+pUrP9qGqplr/tQdTOEN0ztvXejetLCDobFnCQExV90YHKSag5CGXj8RKtN O3ZLop0KJbGxMZEAIUZB6xBT8qkQkFY2zovNlMcrQv1ZijCbWEIlNsYi3xHcS0f2ZnlN 04xtOIli9vLxpj1nzVmXE2x4i25aw/+qK5eJS1KO/ifgukFym/Hd7L6EG8ktczkSxBk2 0wYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082885; x=1707687685; 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=cadphwjaQtxJbfsAaQ8Tf54zJ/KIUtYE/z1XZRnv4ls=; b=LV1kPRqyaOyUXYaQvYjGG66LXUDJcipBy2gqYe5bBnALyyth/sRGCzZUJ+EMa6Zgdt pX54+wFYnamhZdluixORgcTNBK+QAOlzAPd7XEBrGk7qyDApS90oj4phZ5npfJFMowCR nOaH0G1NUZYbuArzpxe54cRZwUF6+MOw3sZO/OCvFK5NZeCSywk1pMWTHzblFRHjlJVK NiJQSwwzVr5382MJ4nUguYQxjsjE0pCWODltzBmMpUAPWkEJhVsF6tdxwP+dpalr6A07 qXv2enLpCy273OOn8NZQ8VIsE63MoolYzmItJcR7q7m8zQsjj8z+WxQ8/43tbL6xRMKW YK+w== X-Gm-Message-State: AOJu0Yyjc0esvimY77p7njT9CdF+Qsvce0PTVospSB0MZ6zLENyipD7C ydiuJHT+ZbyeUiKYEcBdZu+DEpPdV9STxaXTPmKJTKU5dShoaQcxF040Me/SH13p67r5Lbv+99i 01YU= X-Received: by 2002:a17:902:d34d:b0:1d9:5ed4:ec07 with SMTP id l13-20020a170902d34d00b001d95ed4ec07mr9583863plk.52.1707082885716; Sun, 04 Feb 2024 13:41:25 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 14/39] target/s390x: Use TCG_COND_TSTNE for CC_OP_{TM,ICM} Date: Mon, 5 Feb 2024 07:40:27 +1000 Message-Id: <20240204214052.5639-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org These are all test-and-compare type instructions. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- 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 a5fd9cccaa..05fd29589c 100644 --- a/target/s390x/tcg/translate.c +++ b/target/s390x/tcg/translate.c @@ -754,10 +754,10 @@ static void disas_jcc(DisasContext *s, DisasCompare *c, uint32_t mask) case CC_OP_TM_64: switch (mask) { case 8: - cond = TCG_COND_EQ; + cond = TCG_COND_TSTEQ; break; case 4 | 2 | 1: - cond = TCG_COND_NE; + cond = TCG_COND_TSTNE; break; default: goto do_dynamic; @@ -768,11 +768,11 @@ static void disas_jcc(DisasContext *s, DisasCompare *c, uint32_t mask) case CC_OP_ICM: switch (mask) { case 8: - cond = TCG_COND_EQ; + cond = TCG_COND_TSTEQ; break; case 4 | 2 | 1: case 4 | 2: - cond = TCG_COND_NE; + cond = TCG_COND_TSTNE; break; default: goto do_dynamic; @@ -854,18 +854,14 @@ static void disas_jcc(DisasContext *s, DisasCompare *c, uint32_t mask) c->u.s64.a = cc_dst; c->u.s64.b = tcg_constant_i64(0); break; + case CC_OP_LTGT_64: case CC_OP_LTUGTU_64: - c->u.s64.a = cc_src; - c->u.s64.b = cc_dst; - break; - case CC_OP_TM_32: case CC_OP_TM_64: case CC_OP_ICM: - c->u.s64.a = tcg_temp_new_i64(); - c->u.s64.b = tcg_constant_i64(0); - tcg_gen_and_i64(c->u.s64.a, cc_src, cc_dst); + c->u.s64.a = cc_src; + c->u.s64.b = cc_dst; break; case CC_OP_ADDU: From patchwork Sun Feb 4 21:40:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769880 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842819wrc; Sun, 4 Feb 2024 13:46:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IHXzpgSEBrSrOqMlgEQ/2cb95FL0RFD+JMb7M0J988EcF0mJYwKe/jfRSq2YWQRo6E5i+eb X-Received: by 2002:ad4:4ea1:0:b0:68c:92cb:31d1 with SMTP id ed1-20020ad44ea1000000b0068c92cb31d1mr7388876qvb.22.1707083168209; Sun, 04 Feb 2024 13:46:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083168; cv=none; d=google.com; s=arc-20160816; b=fm9jWYLimTVuwg1UqZEmHh+oq3bIMTbIN8fcYB1DfE/NX1AlfB3Y3hoZTQTLFlfw8W 1PGhBoyVFdyrBhftAu6jwje3zeN5qi83Bf0fEzgioCtEyQ93+tF96gMcRwq+WjNOL+i9 8hqCCA0sxlHxb1LwFm/5oTkRkDOy7dDgzYCpJu9N21Pwhd5kmt0oUEgfBVG+V29ZVXcA VTkDN+5ckd6URY1M0hD9kI45ZS1pIZYnkqFiBnyYPIJaklFkXOtMGHoLLGGJHBHV5gu7 ALZ26bAMyQ9yh6SRnrocYp2G7Z5buSy8VIx2OrboZm6/F7Zoj+a5fqbBTVm/HlbAc1X7 jjcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WG70x2tVTekUt4Dpwv8+YTTzoZtnr5bDrng9DlCBKcQ=; fh=uA9umpHVKZ1uSoRIutpzoG1zNT6bKFyMeSy9FQ9IjBM=; b=LfYx9UVCAW4uLkTWru5u+azm4vGK0QLNAimExV4MeB17JTwJTtQdyQzFjuRFeFiQY4 DsXHxw3MLJneLc2OiAyYFBoUm/L10naPL07drJa5b492vCgWdY1FzFzU574CdgMjiafa ZG9gdsp5g2I/YHZxyFpvaELmWFaShFILam0y/dEOPQQ4gyBwJkNXsmbEShAp9IEMACvs 69v9YxYKlKaaYsdA1KEprX5I1J/ODpUjbMmef5nJPEPGJQPtCgq5Myfpeu/Q7yyPgFsV pLt5lDwozKQqop5HP8aHFgfBBYA5IlLYLq+KSiwehuSYy2PvsBTo2SYVp50AmABmsZ2O qL4g==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="HmxRKm1/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCU+egLJLZ1U2CMeAKlyBt1APEiFSUjxaxSnm/Re8Rzwzz490hSzirvKFKvzfIwpkaFS4Lsq2+6NjB1/jKgJ8Xaw Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t17-20020a0cea31000000b0068c711cf6casi6976690qvp.391.2024.02.04.13.46.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:46:08 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="HmxRKm1/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkFG-0002Vq-Hr; Sun, 04 Feb 2024 16:41: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 1rWkFE-0002Ps-SD for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:44 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkEz-0003XF-96 for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:44 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d93edfa76dso32447215ad.1 for ; Sun, 04 Feb 2024 13:41:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082888; x=1707687688; 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=WG70x2tVTekUt4Dpwv8+YTTzoZtnr5bDrng9DlCBKcQ=; b=HmxRKm1/fBW8bpS5NIshhkyMLGl0haMMI+Fv9yWwT7v6HEwYqpVwZ3E4cgBlsIfdzy O76TvrzNGAV+Gw1DmZ6owtWlWiD8ktp2RyDtycNLYvv08FAtorhWcoGuQCR1gl1w07xR hnUjAO9t3R7bghtB08RmLf3+s/2k8vimhtjGEM9lWi9LzA39kN6aKR6MF/ZZ2LurIXYL ayOa04aZvnDPC3jFPTPydCT7RDMPBTg4QllsxE9aqHp1XCXU/y0/y06oZFbrzDkc/+QZ mRkZ92FcFgVZ/4OvIUdwX3HJfSbxZrOkuD07WBgvvSQ0WAnWcO3Lr2s5BcVKt6pm3duY DdsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082888; x=1707687688; 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=WG70x2tVTekUt4Dpwv8+YTTzoZtnr5bDrng9DlCBKcQ=; b=Qi/jcXj+WvTfSOiX3PWBgr9lnhKm4crYHcwV4Km5vKXsssIT6ArH50PcsUHnbUzxAz rQ5UFmKNGkctIawr4nmD5pIUy8uvNMCJlKPCy4CEu6HGJisO23Vh8ndLFLG41AIoTNVN oraYzAudkb5/drT3tltJiVbx+JgtotS/eKvsHS5Cp+VpHRK0Jj8dCHRiTSKXvKu72FGY l7CwwYRLaXm/B1nyfSOmZopr2Lvf5NobJDyLdY/9vHL3dyLYOmLuhWJWYMP14LfPuvwB JrH5z7UyIn2u/FhHvT8RszYSCCkIHFVkChJ6yexjoA0mowqMG3bI0fVtD8dk0Q+aynHC 4JPQ== X-Gm-Message-State: AOJu0YxFmAUfuQGC3ZP1ocgc7c4EsJP4maWVRQn24k1+2NGUQaPuagUC nXFtGuhDnQr6u5wpxwD3z/ibuzIzwyreCarDrGx4OJbe+o7lxi4B2exSwEAqXZBhxuZ84XmlzPk 8g2w= X-Received: by 2002:a17:902:a981:b0:1d7:310e:1e0d with SMTP id bh1-20020a170902a98100b001d7310e1e0dmr11863765plb.32.1707082888055; Sun, 04 Feb 2024 13:41:28 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXlcAwujfbiLMTD9rBjzWNCgUIUfXBf82trUPaOWVu4OHMEh6jvKdiFMIGZL6mz0b68XsPDFVaYXvFtfVueo5Tucw== Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:27 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 15/39] target/s390x: Improve general case of disas_jcc Date: Mon, 5 Feb 2024 07:40:28 +1000 Message-Id: <20240204214052.5639-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Avoid code duplication by handling 7 of the 14 cases by inverting the test for the other 7 cases. Use TCG_COND_TSTNE for cc in {1,3}. Use (cc - 1) <= 1 for cc in {1,2}. Acked-by: Ilya Leoshkevich Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- 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 05fd29589c..3d6a9f44a6 100644 --- a/target/s390x/tcg/translate.c +++ b/target/s390x/tcg/translate.c @@ -885,67 +885,45 @@ static void disas_jcc(DisasContext *s, DisasCompare *c, uint32_t mask) case CC_OP_STATIC: c->is_64 = false; c->u.s32.a = cc_op; - switch (mask) { - case 0x8 | 0x4 | 0x2: /* cc != 3 */ - cond = TCG_COND_NE; + + /* Fold half of the cases using bit 3 to invert. */ + switch (mask & 8 ? mask ^ 0xf : mask) { + case 0x1: /* cc == 3 */ + cond = TCG_COND_EQ; c->u.s32.b = tcg_constant_i32(3); break; - case 0x8 | 0x4 | 0x1: /* cc != 2 */ - cond = TCG_COND_NE; - c->u.s32.b = tcg_constant_i32(2); - break; - case 0x8 | 0x2 | 0x1: /* cc != 1 */ - cond = TCG_COND_NE; - c->u.s32.b = tcg_constant_i32(1); - break; - case 0x8 | 0x2: /* cc == 0 || cc == 2 => (cc & 1) == 0 */ - cond = TCG_COND_EQ; - c->u.s32.a = tcg_temp_new_i32(); - c->u.s32.b = tcg_constant_i32(0); - tcg_gen_andi_i32(c->u.s32.a, cc_op, 1); - break; - case 0x8 | 0x4: /* cc < 2 */ - cond = TCG_COND_LTU; - c->u.s32.b = tcg_constant_i32(2); - break; - case 0x8: /* cc == 0 */ - cond = TCG_COND_EQ; - c->u.s32.b = tcg_constant_i32(0); - break; - case 0x4 | 0x2 | 0x1: /* cc != 0 */ - cond = TCG_COND_NE; - c->u.s32.b = tcg_constant_i32(0); - break; - case 0x4 | 0x1: /* cc == 1 || cc == 3 => (cc & 1) != 0 */ - cond = TCG_COND_NE; - c->u.s32.a = tcg_temp_new_i32(); - c->u.s32.b = tcg_constant_i32(0); - tcg_gen_andi_i32(c->u.s32.a, cc_op, 1); - break; - case 0x4: /* cc == 1 */ - cond = TCG_COND_EQ; - c->u.s32.b = tcg_constant_i32(1); - break; - case 0x2 | 0x1: /* cc > 1 */ - cond = TCG_COND_GTU; - c->u.s32.b = tcg_constant_i32(1); - break; case 0x2: /* cc == 2 */ cond = TCG_COND_EQ; c->u.s32.b = tcg_constant_i32(2); break; - case 0x1: /* cc == 3 */ + case 0x4: /* cc == 1 */ cond = TCG_COND_EQ; - c->u.s32.b = tcg_constant_i32(3); + c->u.s32.b = tcg_constant_i32(1); + break; + case 0x2 | 0x1: /* cc == 2 || cc == 3 => cc > 1 */ + cond = TCG_COND_GTU; + c->u.s32.b = tcg_constant_i32(1); + break; + case 0x4 | 0x1: /* cc == 1 || cc == 3 => (cc & 1) != 0 */ + cond = TCG_COND_TSTNE; + c->u.s32.b = tcg_constant_i32(1); + break; + case 0x4 | 0x2: /* cc == 1 || cc == 2 => (cc - 1) <= 1 */ + cond = TCG_COND_LEU; + c->u.s32.a = tcg_temp_new_i32(); + c->u.s32.b = tcg_constant_i32(1); + tcg_gen_addi_i32(c->u.s32.a, cc_op, -1); + break; + case 0x4 | 0x2 | 0x1: /* cc != 0 */ + cond = TCG_COND_NE; + c->u.s32.b = tcg_constant_i32(0); break; default: - /* CC is masked by something else: (8 >> cc) & mask. */ - cond = TCG_COND_NE; - c->u.s32.a = tcg_temp_new_i32(); - c->u.s32.b = tcg_constant_i32(0); - tcg_gen_shr_i32(c->u.s32.a, tcg_constant_i32(8), cc_op); - tcg_gen_andi_i32(c->u.s32.a, c->u.s32.a, mask); - break; + /* case 0: never, handled above. */ + g_assert_not_reached(); + } + if (mask & 8) { + cond = tcg_invert_cond(cond); } break; From patchwork Sun Feb 4 21:40:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769884 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842911wrc; Sun, 4 Feb 2024 13:46:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IFXsF5ZZlk7df5NsO771vQl7aG70PkjZp26S9OAWuh4FcKRY3sruOVxSdVuNO3nj5IbNFZH X-Received: by 2002:a05:620a:12dc:b0:783:d001:4d43 with SMTP id e28-20020a05620a12dc00b00783d0014d43mr11504084qkl.64.1707083199626; Sun, 04 Feb 2024 13:46:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083199; cv=none; d=google.com; s=arc-20160816; b=IDDTf3Exr5tuQbLhhf2AxPQSLPI7/aFyY5JJM3sNkgWtrPAkrCGgfu84xF7czN38Cp bgNvnFXuV5oEfB7qQA5y2myuE+LOb4X+Og3mxiBMO0j9TRfb40Iou4NFmoRngkKlhthk 6n6nboD5ipP0uiQR95Ukyuc5XEk+GcLwDgtbcPk7E6JIDe81dhtO124eRtPypwn8l+VL lpdrFersRqOwXSQ8EbDnN9EhMFACeC1flZQajn88e0BMV4HhgvKzcEmMsMiQGSGjiztG ln6niOh0mrBMLo3QZU2cba39O01sg8DGDO2Rwk3S/79KIpguh8lbPCYx/1j2ot6Fpluy 0R9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Jqq6u+q1v4CNoIoGh6nUoMc6HIISs+w/ePs4mgq4UxI=; fh=+gLQ9kKLCYwjlbTkaCWzz7meVguwf+JWhLvpm0u0XXg=; b=Kzz0vhUppOQ1L/56IbMamKRixfkM+OkSDMO/7aYGiB9SHJlK8dmvsTQjubMZLo4KyB nqZvgQ9T2+EbV0QV/rlec1UivYJGk1yoFUmFXPKWwuaOXouIUxoZrvCX8LUVwknN5ZIX /+Fx8DMV0Ofq1SxThByu2T7OnbWB2RC+GCGqBV0dlIDOZ0Bsw+T94Rzvs4XS1LkTC54f Tj3bgoDoq4Z7XpJcsLC9Uy6DRendlOB0KpfUbYhz+C7cq613dPX46DcalP4kamKzgwSd 7MyMTzSCt9mJ1OzMpLA/ZTxo+SQrVylUsPsYrG/Opy74adakDwjQmqJ88KqWIfFjVA2h rq3A==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iSU68U3r; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCUKAu8WBCDbMBs5X/FVP6Cvx3MiT9eaZcyYeBuuUQFVBf+I8TP/MTB0Py58gVZamY4fre2kjjWa/fYkZcg2OKU6 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v11-20020a05620a122b00b007817072c0fesi7047908qkj.493.2024.02.04.13.46.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:46:39 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iSU68U3r; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkF5-00028E-2k; Sun, 04 Feb 2024 16:41:35 -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 1rWkF3-00027s-Fv for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:33 -0500 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkF1-0003XR-JP for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:33 -0500 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-5d8df2edd29so3004780a12.2 for ; Sun, 04 Feb 2024 13:41:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082890; x=1707687690; 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=Jqq6u+q1v4CNoIoGh6nUoMc6HIISs+w/ePs4mgq4UxI=; b=iSU68U3rj/B/WsrFGoSAqK7u83X4qBuHZPeDkh4dDRAhPZDL81RMGdEZA/bslepWGp GAVNk7YxPDqpcycYOLkijnZVudFFO5FvAVb5+SPIw8aCi/hl9R198ETgkLv8105iaUrk 9zGDn9Akp/5uLGhOiHO21/ZB45ardX3JG6fHn4lrF1DlCJbghrekTLktLxAHcknKCBsL n30znDj0yk1ZPHMG232bi4QgN6o6Y/tV8QruwQXdtLB3GYxcKxcDm223/H6+KGuTht7f 07eGj50LpLI4Z3TEFuRHLMvfiKunY/mbHUlWpYL5Bpq4SmwafqS4a5VIPW5+3JRRFZp5 5HgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082890; x=1707687690; 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=Jqq6u+q1v4CNoIoGh6nUoMc6HIISs+w/ePs4mgq4UxI=; b=bIRxZa3HYGM5bgFhqdHlCKk+rkYsnQd6stmV4NbqE2qpY/1Hy7E6ypIVI3f/iOQTB/ tkpncBfaiP40zwWLTh5YqUPqL63Ab0SgvHzI3+quGU2FBtlXpdLSFQAbFIIjrqt97uzi cigH6GDIXLP/7y5CryXXbqVFJ64DqcQcOlnij0M7Kj9eMYMtDOQQClJTHePwABzYLAEv RlSSwZwKaxEc1MJPH7x3mQvnVcYu7qaQHW25jXnVyh2GBWnzVbjXkPd1gsRHIFScTWkP N24jy++wyKWaAObqzzNYyHoajzvOglgkYj5KuZvGAFjn2+7I+NldNqDegRxnP0WAGxim npIg== X-Gm-Message-State: AOJu0YxXedejdMpNTjbOHzKoYS6dTNJbUPRhxGWMJNpzHTX9L/qamT5G MaPnvkHwJTo9eSedhp3Dsuihoc7hxpBX7LO+bI+JpUWqnSb2uU+JiFGIWZ+6TMmMYyZK7MNnlLj Z+Q0= X-Received: by 2002:a05:6a20:bd1e:b0:19c:a202:3f96 with SMTP id fy30-20020a056a20bd1e00b0019ca2023f96mr9023837pzb.51.1707082890142; Sun, 04 Feb 2024 13:41:30 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 16/39] tcg: Add TCGConst argument to tcg_target_const_match Date: Mon, 5 Feb 2024 07:40:29 +1000 Message-Id: <20240204214052.5639-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Fill the new argument from any condition within the opcode. Not yet used within any backend. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/tcg.c | 34 ++++++++++++++++++++++++++++++-- tcg/aarch64/tcg-target.c.inc | 3 ++- tcg/arm/tcg-target.c.inc | 3 ++- tcg/i386/tcg-target.c.inc | 3 ++- tcg/loongarch64/tcg-target.c.inc | 3 ++- tcg/mips/tcg-target.c.inc | 3 ++- tcg/ppc/tcg-target.c.inc | 3 ++- tcg/riscv/tcg-target.c.inc | 3 ++- tcg/s390x/tcg-target.c.inc | 3 ++- tcg/sparc64/tcg-target.c.inc | 3 ++- tcg/tci/tcg-target.c.inc | 3 ++- 11 files changed, 52 insertions(+), 12 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 60cb31c400..d6670237fb 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -173,7 +173,8 @@ static bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target, const TCGHelperInfo *info); static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot); -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int vece); +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece); #ifdef TCG_TARGET_NEED_LDST_LABELS static int tcg_out_ldst_finalize(TCGContext *s); #endif @@ -4786,6 +4787,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) TCGTemp *ts; TCGArg new_args[TCG_MAX_OP_ARGS]; int const_args[TCG_MAX_OP_ARGS]; + TCGCond op_cond; nb_oargs = def->nb_oargs; nb_iargs = def->nb_iargs; @@ -4798,6 +4800,33 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) i_allocated_regs = s->reserved_regs; o_allocated_regs = s->reserved_regs; + switch (op->opc) { + case INDEX_op_brcond_i32: + case INDEX_op_brcond_i64: + op_cond = op->args[2]; + break; + case INDEX_op_setcond_i32: + case INDEX_op_setcond_i64: + case INDEX_op_negsetcond_i32: + case INDEX_op_negsetcond_i64: + case INDEX_op_cmp_vec: + op_cond = op->args[3]; + break; + case INDEX_op_brcond2_i32: + op_cond = op->args[4]; + break; + case INDEX_op_movcond_i32: + case INDEX_op_movcond_i64: + case INDEX_op_setcond2_i32: + case INDEX_op_cmpsel_vec: + op_cond = op->args[5]; + break; + default: + /* No condition within opcode. */ + op_cond = TCG_COND_ALWAYS; + break; + } + /* satisfy input constraints */ for (k = 0; k < nb_iargs; k++) { TCGRegSet i_preferred_regs, i_required_regs; @@ -4811,7 +4840,8 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) ts = arg_temp(arg); if (ts->val_type == TEMP_VAL_CONST - && tcg_target_const_match(ts->val, ts->type, arg_ct->ct, TCGOP_VECE(op))) { + && tcg_target_const_match(ts->val, arg_ct->ct, ts->type, + op_cond, TCGOP_VECE(op))) { /* constant is OK for instruction */ const_args[i] = 1; new_args[i] = ts->val; diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index a3efa1e67a..420e4a35ea 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -270,7 +270,8 @@ static bool is_shimm1632(uint32_t v32, int *cmode, int *imm8) } } -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index a9aa8aa91c..113094a5b2 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -501,7 +501,8 @@ static bool is_shimm1632(uint32_t v32, int *cmode, int *imm8) * mov operand2: values represented with x << (2 * y), x < 0x100 * add, sub, eor...: ditto */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index d268199fc1..accaaa2660 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -195,7 +195,8 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, } /* test if a constant matches the constraint */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index dcf0205458..69c5b8ac4f 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -183,7 +183,8 @@ static inline tcg_target_long sextreg(tcg_target_long val, int pos, int len) } /* test if a constant matches the constraint */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return true; diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 8328dbdecc..3b5b5c6d5b 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -188,7 +188,8 @@ static bool is_p2m1(tcg_target_long val) } /* test if a constant matches the constraint */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 54816967bc..850ace98b2 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -282,7 +282,8 @@ static bool reloc_pc34(tcg_insn_unit *src_rw, const tcg_insn_unit *target) } /* test if a constant matches the constraint */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 34e10e77d9..639363039b 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -145,7 +145,8 @@ static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) #define sextreg sextract64 /* test if a constant matches the constraint */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc index 7f6b84aa2c..54645d1f55 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -538,7 +538,8 @@ static bool risbg_mask(uint64_t c) } /* Test if a constant matches the constraint. */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc index a91defd0ac..ac86b92b75 100644 --- a/tcg/sparc64/tcg-target.c.inc +++ b/tcg/sparc64/tcg-target.c.inc @@ -322,7 +322,8 @@ static bool patch_reloc(tcg_insn_unit *src_rw, int type, } /* test if a constant matches the constraint */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc index 461f4b47ff..c740864b96 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -913,7 +913,8 @@ static inline bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, } /* Test if a constant matches the constraint. */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { return ct & TCG_CT_CONST; } From patchwork Sun Feb 4 21:40:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769850 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842039wrc; Sun, 4 Feb 2024 13:41:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBMNf7C59fuil8zRgExDh6UvH9DXolwU3zmaGnGi402WZkeqctgK0ZBcn4sGi+29NbRz6Y X-Received: by 2002:a05:620a:4954:b0:783:fa37:1f98 with SMTP id vz20-20020a05620a495400b00783fa371f98mr9068879qkn.38.1707082917759; Sun, 04 Feb 2024 13:41:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707082917; cv=none; d=google.com; s=arc-20160816; b=CPlvLdAi62oqYd5U3/w5NCOpucgPM1WOYnhq4WJd4fQaFl7kY33YL6HHrhANbgCkKo g8N1gB97zw+B6bvQy7cq/yGzTgww+jDIJVQmg2cWJl/dfs5+gowfUqXA4Iv6dIfXuZKy ZFl37/E77pGx+8rOLfMA3bU8Dsisdron7ThLQgbgEr896Kr10AwjM8fEQWhdk4bXSvhF IMveLFV5trhVITI79iRcV5l1i3AD4NlBRLKGxXeLLanbairJXPQr5OUEfzYDvg52Jpkg 4azhBuUr5ANNCncP0QtV1HNhW7mLCuJb2HSzw5mjsSKn5pjec6PikYlYiIDl8P+39KAZ DX0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8UBGb+wxegdURiW3iZlXgf7tcUJqtD8TzwZuo64Djqc=; fh=/eRlB3zXCzqdvzzexV/h0EuSf2EfGVLsKJsbbTO0JBY=; b=0cuaAJGYNlMjoH24ZJgjYKi/c+8cL9AhyCScsbBxBqhbrx7XSXuQp1x8P5ogUCTTQg Sg8yiY6P+ij4xTJ+z6va9HYnawgzd35lhrt/KziRISWdx5VnpknZqMMa84lUGMjXQwyj 3dw+ur7pgWPY65RzaiKMYDZS3i7r403RGmzwfHEgrhjUVyC/WzQQDBabhhsh7VlMKfHk TuctcoSheyIQ+qlmpTA5Zvj0aohRAaru9sYxknGrz3lYgDAgsio4tDWGwP/SlwCCu0k3 5tobkoIlqQu9TxrVJDQvjP/RLUlbzSNZc0vL52acgQfkTRc2JE5IlnxYCTnNVAaT6Lhn l1Fw==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dRBvIkdO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCXRlyrLgb+VRU9UftpGe+UTlLunEfpWn6LPN/cy85tPuBGoXGzFh0AnIJmAGmARf6GPldqqadzN/SjS5livRg2B Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w14-20020a05620a094e00b00783ddf60e2fsi6917901qkw.208.2024.02.04.13.41.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:41:57 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dRBvIkdO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkF7-0002Bg-Ra; Sun, 04 Feb 2024 16:41: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 1rWkF6-00028L-Cb for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:36 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkF4-0003XZ-FX for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:36 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1d7232dcb3eso27235795ad.2 for ; Sun, 04 Feb 2024 13:41:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082892; x=1707687692; 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=8UBGb+wxegdURiW3iZlXgf7tcUJqtD8TzwZuo64Djqc=; b=dRBvIkdO76d6W1HDDBhYfXDti68+DEX6OfrFcxuvfQWlAxIKatwxPfIHlzw6t6914z cSXM1oXOqP9pRkb9bY3Yo4XkToAl9ZKCR0lAe9Nx+NAFRGnea1gQC+9RzKzZqZk8X5E6 A2Z2VSdgLJnolO7HqKNn5ZegxbVSwH3OJ840546HmW18EhjUMEooeR0aC0FF/h/hrsb2 ekTsk4PUC9UFZucB8Wp4AXjc43U/xgOi1GWErx2YHYfVILW80DlAfk/uIoYIzVHFZB5a AvbI561PYh9u7pJhWojUE6C/DvEbR7wHDDG9BgxbFAFOP8XRLUvoWHpG96LwysHjQr79 vNgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082892; x=1707687692; 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=8UBGb+wxegdURiW3iZlXgf7tcUJqtD8TzwZuo64Djqc=; b=F2nrNbbDy+eY1igpHa9i/yvuaJqw2kmBB9oPFFmDJKTZ9iriX0i4hZdiLowut3nP5a XdNEMZ+N8WpV1a/5Huxk4WmEYWCSsd1twDT/2lLcUcILqFnEnXTMcQzRqM58B/HTyhDY 0+NJsQ6Q/wm7whCSDB7m2SQZBiYOwbb/F+W+ghp932vkyoELPpGsH303y0l86H1Kn7m5 9VnWLAVijSDT+rms/xUxgKNBzKM9bF4DX6D/YtQaKClNdSlgvzTJMMVCZ2gp3t/P1HtW lE+phsbSZMgwPlDgTghW0r3vxf5HZey5+A7HCZ7lmCxU6Uebt0BEIVE1xbS454C2U9pH TcCw== X-Gm-Message-State: AOJu0Yy1mIT9+aZ8/JSiE4XP9KGlb8D3tOUqi5Vgy6zJMHaWxfgB+EcI f8IAhbWuTu5kU4L+IQhB9sGmx2T4pnyJTCM4X331bzBKtDyIkOqekBSrWNKIqdA9/z/Z+Lf2h1J cOEg= X-Received: by 2002:a17:902:db07:b0:1d8:cd7b:85fa with SMTP id m7-20020a170902db0700b001d8cd7b85famr9084561plx.68.1707082892205; Sun, 04 Feb 2024 13:41:32 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:31 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 17/39] tcg/aarch64: Support TCG_COND_TST{EQ,NE} Date: Mon, 5 Feb 2024 07:40:30 +1000 Message-Id: <20240204214052.5639-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target-con-set.h | 5 +-- tcg/aarch64/tcg-target-con-str.h | 1 + tcg/aarch64/tcg-target.h | 2 +- tcg/aarch64/tcg-target.c.inc | 56 ++++++++++++++++++++++---------- 4 files changed, 44 insertions(+), 20 deletions(-) diff --git a/tcg/aarch64/tcg-target-con-set.h b/tcg/aarch64/tcg-target-con-set.h index 3fdee26a3d..44fcc1206e 100644 --- a/tcg/aarch64/tcg-target-con-set.h +++ b/tcg/aarch64/tcg-target-con-set.h @@ -10,7 +10,7 @@ * tcg-target-con-str.h; the constraint combination is inclusive or. */ C_O0_I1(r) -C_O0_I2(r, rA) +C_O0_I2(r, rC) C_O0_I2(rZ, r) C_O0_I2(w, r) C_O0_I3(rZ, rZ, r) @@ -22,6 +22,7 @@ C_O1_I2(r, 0, rZ) C_O1_I2(r, r, r) C_O1_I2(r, r, rA) C_O1_I2(r, r, rAL) +C_O1_I2(r, r, rC) C_O1_I2(r, r, ri) C_O1_I2(r, r, rL) C_O1_I2(r, rZ, rZ) @@ -31,6 +32,6 @@ C_O1_I2(w, w, wN) C_O1_I2(w, w, wO) C_O1_I2(w, w, wZ) C_O1_I3(w, w, w, w) -C_O1_I4(r, r, rA, rZ, rZ) +C_O1_I4(r, r, rC, rZ, rZ) C_O2_I1(r, r, r) C_O2_I4(r, r, rZ, rZ, rA, rMZ) diff --git a/tcg/aarch64/tcg-target-con-str.h b/tcg/aarch64/tcg-target-con-str.h index fb1a845b4f..48e1722c68 100644 --- a/tcg/aarch64/tcg-target-con-str.h +++ b/tcg/aarch64/tcg-target-con-str.h @@ -16,6 +16,7 @@ REGS('w', ALL_VECTOR_REGS) * CONST(letter, TCG_CT_CONST_* bit set) */ CONST('A', TCG_CT_CONST_AIMM) +CONST('C', TCG_CT_CONST_CMP) CONST('L', TCG_CT_CONST_LIMM) CONST('M', TCG_CT_CONST_MONE) CONST('O', TCG_CT_CONST_ORRI) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index b4ac13be7b..ef5ebe91bd 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -138,7 +138,7 @@ typedef enum { #define TCG_TARGET_HAS_qemu_ldst_i128 1 #endif -#define TCG_TARGET_HAS_tst 0 +#define TCG_TARGET_HAS_tst 1 #define TCG_TARGET_HAS_v64 1 #define TCG_TARGET_HAS_v128 1 diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 420e4a35ea..70df250c04 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -126,6 +126,7 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, #define TCG_CT_CONST_MONE 0x800 #define TCG_CT_CONST_ORRI 0x1000 #define TCG_CT_CONST_ANDI 0x2000 +#define TCG_CT_CONST_CMP 0x4000 #define ALL_GENERAL_REGS 0xffffffffu #define ALL_VECTOR_REGS 0xffffffff00000000ull @@ -279,6 +280,15 @@ static bool tcg_target_const_match(int64_t val, int ct, if (type == TCG_TYPE_I32) { val = (int32_t)val; } + + if (ct & TCG_CT_CONST_CMP) { + if (is_tst_cond(cond)) { + ct |= TCG_CT_CONST_LIMM; + } else { + ct |= TCG_CT_CONST_AIMM; + } + } + if ((ct & TCG_CT_CONST_AIMM) && (is_aimm(val) || is_aimm(-val))) { return 1; } @@ -345,6 +355,9 @@ static const enum aarch64_cond_code tcg_cond_to_aarch64[] = { [TCG_COND_GTU] = COND_HI, [TCG_COND_GEU] = COND_HS, [TCG_COND_LEU] = COND_LS, + /* bit test */ + [TCG_COND_TSTEQ] = COND_EQ, + [TCG_COND_TSTNE] = COND_NE, }; typedef enum { @@ -1342,19 +1355,26 @@ static inline void tcg_out_dep(TCGContext *s, TCGType ext, TCGReg rd, tcg_out_bfm(s, ext, rd, rn, a, b); } -static void tcg_out_cmp(TCGContext *s, TCGType ext, TCGReg a, +static void tcg_out_cmp(TCGContext *s, TCGType ext, TCGCond cond, TCGReg a, tcg_target_long b, bool const_b) { - if (const_b) { - /* Using CMP or CMN aliases. */ - if (b >= 0) { - tcg_out_insn(s, 3401, SUBSI, ext, TCG_REG_XZR, a, b); + if (is_tst_cond(cond)) { + if (!const_b) { + tcg_out_insn(s, 3510, ANDS, ext, TCG_REG_XZR, a, b); } else { - tcg_out_insn(s, 3401, ADDSI, ext, TCG_REG_XZR, a, -b); + tcg_debug_assert(is_limm(b)); + tcg_out_logicali(s, I3404_ANDSI, 0, TCG_REG_XZR, a, b); } } else { - /* Using CMP alias SUBS wzr, Wn, Wm */ - tcg_out_insn(s, 3502, SUBS, ext, TCG_REG_XZR, a, b); + if (!const_b) { + tcg_out_insn(s, 3502, SUBS, ext, TCG_REG_XZR, a, b); + } else if (b >= 0) { + tcg_debug_assert(is_aimm(b)); + tcg_out_insn(s, 3401, SUBSI, ext, TCG_REG_XZR, a, b); + } else { + tcg_debug_assert(is_aimm(-b)); + tcg_out_insn(s, 3401, ADDSI, ext, TCG_REG_XZR, a, -b); + } } } @@ -1402,7 +1422,7 @@ static void tcg_out_brcond(TCGContext *s, TCGType ext, TCGCond c, TCGArg a, need_cmp = false; } else { need_cmp = true; - tcg_out_cmp(s, ext, a, b, b_const); + tcg_out_cmp(s, ext, c, a, b, b_const); } if (!l->has_value) { @@ -1575,7 +1595,7 @@ static void tcg_out_cltz(TCGContext *s, TCGType ext, TCGReg d, } else { AArch64Insn sel = I3506_CSEL; - tcg_out_cmp(s, ext, a0, 0, 1); + tcg_out_cmp(s, ext, TCG_COND_NE, a0, 0, 1); tcg_out_insn(s, 3507, CLZ, ext, TCG_REG_TMP0, a1); if (const_b) { @@ -1720,7 +1740,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h, addr_adj, compare_mask); /* Perform the address comparison. */ - tcg_out_cmp(s, addr_type, TCG_REG_TMP0, TCG_REG_TMP2, 0); + tcg_out_cmp(s, addr_type, TCG_COND_NE, TCG_REG_TMP0, TCG_REG_TMP2, 0); /* If not equal, we jump to the slow path. */ ldst->label_ptr[0] = s->code_ptr; @@ -2276,7 +2296,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, a2 = (int32_t)a2; /* FALLTHRU */ case INDEX_op_setcond_i64: - tcg_out_cmp(s, ext, a1, a2, c2); + tcg_out_cmp(s, ext, args[3], a1, a2, c2); /* Use CSET alias of CSINC Wd, WZR, WZR, invert(cond). */ tcg_out_insn(s, 3506, CSINC, TCG_TYPE_I32, a0, TCG_REG_XZR, TCG_REG_XZR, tcg_invert_cond(args[3])); @@ -2286,7 +2306,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, a2 = (int32_t)a2; /* FALLTHRU */ case INDEX_op_negsetcond_i64: - tcg_out_cmp(s, ext, a1, a2, c2); + tcg_out_cmp(s, ext, args[3], a1, a2, c2); /* Use CSETM alias of CSINV Wd, WZR, WZR, invert(cond). */ tcg_out_insn(s, 3506, CSINV, ext, a0, TCG_REG_XZR, TCG_REG_XZR, tcg_invert_cond(args[3])); @@ -2296,7 +2316,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, a2 = (int32_t)a2; /* FALLTHRU */ case INDEX_op_movcond_i64: - tcg_out_cmp(s, ext, a1, a2, c2); + tcg_out_cmp(s, ext, args[5], a1, a2, c2); tcg_out_insn(s, 3506, CSEL, ext, a0, REG0(3), REG0(4), args[5]); break; @@ -2896,11 +2916,13 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_add_i64: case INDEX_op_sub_i32: case INDEX_op_sub_i64: + return C_O1_I2(r, r, rA); + case INDEX_op_setcond_i32: case INDEX_op_setcond_i64: case INDEX_op_negsetcond_i32: case INDEX_op_negsetcond_i64: - return C_O1_I2(r, r, rA); + return C_O1_I2(r, r, rC); case INDEX_op_mul_i32: case INDEX_op_mul_i64: @@ -2950,11 +2972,11 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_brcond_i32: case INDEX_op_brcond_i64: - return C_O0_I2(r, rA); + return C_O0_I2(r, rC); case INDEX_op_movcond_i32: case INDEX_op_movcond_i64: - return C_O1_I4(r, r, rA, rZ, rZ); + return C_O1_I4(r, r, rC, rZ, rZ); case INDEX_op_qemu_ld_a32_i32: case INDEX_op_qemu_ld_a64_i32: From patchwork Sun Feb 4 21:40:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769849 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842027wrc; Sun, 4 Feb 2024 13:41:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IFoc85ZiTplqNjD190tvS528yybM9Me/dqAp2QSRxaZvKg2/+/xW9wfxLkwHJqHW2/rs8ZO X-Received: by 2002:a05:620a:210b:b0:785:504a:88e2 with SMTP id l11-20020a05620a210b00b00785504a88e2mr9656619qkl.66.1707082912625; Sun, 04 Feb 2024 13:41:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707082912; cv=none; d=google.com; s=arc-20160816; b=rHvVEFtvKwYGDKKyeNOlzgSRZ7RMyy7goVVbew4ccyl+juHI73X91A9W5cjNkKSk1g LKnUcWxJ12/64p85N3Yjnk6Ekf/WDnpkbv+niWVcIuOrUP9l3XmU6Uke6vamNub4DgQF CQ/sCYJLOIG+HWWGyDoLtaGite9iVV+EfHwN2GTnLLOKjvx+aTzaZqImkHiCkvN/65pk 3/GK2QUcMttxTR/t7lMxQL2UTc1lqmzDr7KaS4yKPvjmCB47hiQIqqQ0Dl8EsYILsO3Y dPQVmUxDt+HCF1SykKiXvYGyLwtBgmujGFyYwZetmwC+AAf+BiKeWhepBTspCgeivlf3 j0Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wnrIxg69BVtmJ/0Uf+G15vykcNV6rAlJagI7YZZGePs=; fh=jcHvANMkD+algoWO9uYFiBAYgEAm7sx5MCehm+xIpj0=; b=ISJPKH7fc7CsQCsw/q5k7vbLJO+3Tr6YFLUq55ozpdtxt+/hBeTaIPnWSKkvHwTUSC dK7O91r1PTJFDecpA8HnmFnarCL40iUxQ6y/fNMgT208SQaojjkmpA+C4W8TjnC5ZFLQ dOxd/byTWbM9QwWR7RHCeEjQoK27aiO673TNdok+46FqY1glvBwKJZHGfjDIg0XNqU+S OCLualRCrN33i2CBK7gzf4ZeZEDeL3rxWTKgVT/ZAGlEVz1pbEpm/alZBZdc+YbUHG6C Pl354tDumDKrOSSplH6MgWQS46yWiU0mXBWU42DaaAWm0iGNY93Jno7sbE1Qhc3BA10C rqBg==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=svLr56db; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCUeQMDTKO8ll9FEoPO1zl0F0O9JtKiHD0W7rgz5XTGkLqabCAteXcV1R+Qs3wRzfFDU+8ffy58OgNaG7q6RYrmB Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w27-20020a05620a149b00b0078553af1792si6640070qkj.276.2024.02.04.13.41.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:41:52 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=svLr56db; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkF9-0002Gi-QY; Sun, 04 Feb 2024 16:41: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 1rWkF7-0002B1-Lb for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:37 -0500 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkF5-0003Xk-IQ for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:37 -0500 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-5ce2aada130so3527642a12.1 for ; Sun, 04 Feb 2024 13:41:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082894; x=1707687694; 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=wnrIxg69BVtmJ/0Uf+G15vykcNV6rAlJagI7YZZGePs=; b=svLr56dbTX/i/EFmKdxXiJZjhE+arTdr2rUcBJpRc5FRiFw+/8kJpb85+r1zNj776z zigvJlF+tFnfkr32Vo1tWwivqVRSGNKgrCJpqgsZ//yLPUSfSyZKaVfMqi9VLBvFYwOi OIy9F0W4I5NBCgqOZSmCoJAIJr2B+HztvCsmikxoQucfidcRPjC9vAaIJpEw+AlLDJQB 0MU/6nzweq4Y/0KM+Pth9c8pNcP3lsOaM52fHy2LpNLWUlrizxpWIc+CqDTdBScLI18W p9l5gdTGgadEjISQAf3BkEZVdMDdUZA8sOJ69JHG7/2Ppwy8ml35b5wVYUqc8UIATpk3 2Bog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082894; x=1707687694; 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=wnrIxg69BVtmJ/0Uf+G15vykcNV6rAlJagI7YZZGePs=; b=baRmqNAYRv0qMhhD8A6/40evcyMO3/JxcO6C4uj7j4XO0LxAyydtjwPQEbQe33VPwh LYdOmynLH2U2RjHfWmLoX1d+yiF99cgljQlzPwL591exOIjXoz3waOFJRuPdwO1DGwg9 8DKdUVOGbkJ4XH09EJPyhCehAcHhTU6K4EpHszxevq+apzfws5xMLIj2h4Oy8kt9Ds3W pPUhotXdjWwT7TownASDZ3fnzeWajCkPH6i3ensH5hcJWERSqFy7BaG6z/HqJwFXcPYs 8M8HkzJ8M97ir1sL76ODTaY6vWy2igvORWnlSpDjQYVEnvlq5PBupY9O6QR49xm6v/Ep nR6A== X-Gm-Message-State: AOJu0Ywl7/lazJPV4sQioGUI4IMNdRjFB0CRDUswlPGO7ovBhuIVkkFg nVCeegRdzQDY79/XB8X3ND51X1PVFT9CUC7seIxxyM9Q4Qc85xRcCUFfwpUr1qax5y5OtwlzI/4 lOIA= X-Received: by 2002:a17:902:d548:b0:1d9:3f27:42ed with SMTP id z8-20020a170902d54800b001d93f2742edmr17835271plf.1.1707082894279; Sun, 04 Feb 2024 13:41:34 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:33 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 18/39] tcg/aarch64: Massage tcg_out_brcond() Date: Mon, 5 Feb 2024 07:40:31 +1000 Message-Id: <20240204214052.5639-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé In order to ease next commit review, modify tcg_out_brcond() to switch over TCGCond. No logical change intended. Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20240119224737.48943-1-philmd@linaro.org> Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.c.inc | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 70df250c04..a19158f4ea 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1416,12 +1416,20 @@ 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; + bool need_cmp = true; - if (b_const && b == 0 && (c == TCG_COND_EQ || c == TCG_COND_NE)) { - need_cmp = false; - } else { - need_cmp = true; + switch (c) { + case TCG_COND_EQ: + case TCG_COND_NE: + if (b_const && b == 0) { + need_cmp = false; + } + break; + default: + break; + } + + if (need_cmp) { tcg_out_cmp(s, ext, c, a, b, b_const); } @@ -1435,10 +1443,17 @@ static void tcg_out_brcond(TCGContext *s, TCGType ext, TCGCond c, TCGArg a, if (need_cmp) { tcg_out_insn(s, 3202, B_C, c, offset); - } else if (c == TCG_COND_EQ) { - tcg_out_insn(s, 3201, CBZ, ext, a, offset); } else { - tcg_out_insn(s, 3201, CBNZ, ext, a, offset); + switch (c) { + case TCG_COND_EQ: + tcg_out_insn(s, 3201, CBZ, ext, a, offset); + break; + case TCG_COND_NE: + tcg_out_insn(s, 3201, CBNZ, ext, a, offset); + break; + default: + g_assert_not_reached(); + } } } From patchwork Sun Feb 4 21:40:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769881 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842847wrc; Sun, 4 Feb 2024 13:46:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IHcebfsHrQxsRybtNs3InD10FNTBcScvdzH0fyMpkwH3muOJGaryzkGLKDWz2B5VMk2ts2+ X-Received: by 2002:ac8:6e9d:0:b0:42a:a41e:f449 with SMTP id c29-20020ac86e9d000000b0042aa41ef449mr4247987qtv.55.1707083176902; Sun, 04 Feb 2024 13:46:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083176; cv=none; d=google.com; s=arc-20160816; b=reiTa/D1VwXnxCffFUnbPBTy0uiHyTFm1Q9nYCyu/zhBZuyv4NjksB09Rc3vT35Aby VxBXu8lIUynmqoidvxJX3AYrUJEAFTdTBYuRr4KS0991LVVz/SDV9Sv+8IRZU5ivfgPT Fs4opA16sMxa/5ZYpNjAL6KAyhy1i2AbBaDiHq7wCcFeRy5sCURBl9ELHmZO5IJhTf1p Kt3uEqr5vEzLzWL2LnQbUm4exBBQhH5FE3raktk4Xpm8KHBdCHwjXX3Q5EhYB55qHjDO uCEbMKpgRCPfaJjtp8iCOc7Q0YOUfUjPVOS1Ki1CpUhM0H6c5y7Cgyk/znf83mVIuUrA XZwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qQnugvxaaCXEKXnek38clmLInE+uwIUEavcKHzwPd5o=; fh=FxXXVbKt8F77HgGeofyXIORFcdk6WZu9Jn2PCykYx+c=; b=H9qxsLoSm2HfnhZ+hT1CSDruzQzMy1y4j1y8DcTGJn7x7XmceFpHpzhJNBVdxDJfjs gVhQ6OxCLvzkT3/8/1dG8SwTx+kAm4QdneippESTI6QoW1X9rHWMvW3ByEpKd7LvIBX5 EBLvb7mBQSriLdZ2QUYx4v2wnY1Tgb+8gQcmJmgX97GXRVklqNAzAg6gAeP16JEyqnex Pph9LMdFoDUd8QVAmfg2jvUgXxDDTnVjlnLVUhOw5QxVgYZpmJzkPGmbEDMerAHrLo3T whOfNZp/5WwFlcpFK1Hj+8ho+/hYyH/HI1bg9mUTp/GB4a+ElrNGUIJaiT2uWUeFJvxc 5x2w==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sdpon5on; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCV2Z3yuxq/6FYZyGcHQKmUf6p+JTgPB2eMiYWQEz6YHVGcfKpUIBhgfSRd1JPXBt7Sgj/qpXWmN6eIhLwxVSqSH Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 15-20020ac8594f000000b0042bf838e0dbsi7010670qtz.416.2024.02.04.13.46.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:46:16 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sdpon5on; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkFA-0002HB-Mr; Sun, 04 Feb 2024 16:41:40 -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 1rWkF9-0002Fq-CA for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:39 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkF7-0003Xv-Fn for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:39 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1d94323d547so29785395ad.3 for ; Sun, 04 Feb 2024 13:41:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082896; x=1707687696; 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=qQnugvxaaCXEKXnek38clmLInE+uwIUEavcKHzwPd5o=; b=sdpon5on07/DQB7g2xT3+qsGNZXQnETwiABUpvcp1Kmuf4Ivl9YjEzm2fn0CT/GLeu CNZ0LR+v78E1cW0EFNTb2ul8VGWpXK04fSJy7LDkHPVIMEN2IaWacTClafEIUTfbCaNh dY1wzsXF4+KTth9JdQ6ye3jlTUf5ntGvl/G61DocaW45Gl8P0sLleK1Vs/1frXkt2+Rk IBa4nS2SO5uPVkNK+mLdh93aR1ybnJBcmjVPA251mvHYR0yxHOvrDVNBMHvdO/gRvwBu P8MjqKXR7cjwAqVZVQVi8Beydn/Xk7MWXio6c1kBCLgDkXO+fc1iVyS37Hk07cnVFMwa P6sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082896; x=1707687696; 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=qQnugvxaaCXEKXnek38clmLInE+uwIUEavcKHzwPd5o=; b=XbO2P8KveIBQMvGGB/4y2RtGBlySnZ0/1Zjsi9VemBOzMMcUiV6AfKIpV369hAtmKm W57SugPyVxJZwngAMBfcVlIldNnnQ0O2M8MKgldRzx6Y7fDgzLTxDBVsLqlnNkR48hGS VIszAyqVvKqq6KLbc1uNR/06Zh16v1O6AeY4Vl73TivH9G33zFSBUNRTonXu2Oh10pgd cMsvXlYAtRQ/g9yAW71l+xwHOEN9iMyT7jQvYAYbzKObXkl6Z9H/6mOFJu4/0dFyLen6 oqzMxCnhwKZhgvwwDTRxEpAaxOmfDQzVT1AbA6T3J5IhPC70ORH6WLISfLajRPt4ZLVM LhHw== X-Gm-Message-State: AOJu0YwSIz3PEdjOmmY5sD7ksda/l5/HgMAnzbrfFE49E7ON/Ic2MdKH G/0C09sNAlM09qp++Je13SYtWvfBDJRy9FjKcoCjIHc7rzSRx3UJaDQDGDkWxT5a/+6BwL6XT+m cTfw= X-Received: by 2002:a17:902:c412:b0:1d9:a868:ec66 with SMTP id k18-20020a170902c41200b001d9a868ec66mr1826473plk.43.1707082896317; Sun, 04 Feb 2024 13:41:36 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:35 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 19/39] tcg/aarch64: Generate TBZ, TBNZ Date: Mon, 5 Feb 2024 07:40:32 +1000 Message-Id: <20240204214052.5639-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Test the sign bit for LT/GE vs 0, and TSTNE/EQ vs a power of 2. Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20240119224737.48943-2-philmd@linaro.org> Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.c.inc | 74 ++++++++++++++++++++++++++++++------ 1 file changed, 62 insertions(+), 12 deletions(-) diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index a19158f4ea..36fc46ae93 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -105,6 +105,18 @@ static bool reloc_pc19(tcg_insn_unit *src_rw, const tcg_insn_unit *target) return false; } +static bool reloc_pc14(tcg_insn_unit *src_rw, const tcg_insn_unit *target) +{ + const tcg_insn_unit *src_rx = tcg_splitwx_to_rx(src_rw); + ptrdiff_t offset = target - src_rx; + + if (offset == sextract64(offset, 0, 14)) { + *src_rw = deposit32(*src_rw, 5, 14, offset); + return true; + } + return false; +} + static bool patch_reloc(tcg_insn_unit *code_ptr, int type, intptr_t value, intptr_t addend) { @@ -115,6 +127,8 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, return reloc_pc26(code_ptr, (const tcg_insn_unit *)value); case R_AARCH64_CONDBR19: return reloc_pc19(code_ptr, (const tcg_insn_unit *)value); + case R_AARCH64_TSTBR14: + return reloc_pc14(code_ptr, (const tcg_insn_unit *)value); default: g_assert_not_reached(); } @@ -380,6 +394,10 @@ typedef enum { /* Conditional branch (immediate). */ I3202_B_C = 0x54000000, + /* Test and branch (immediate). */ + I3205_TBZ = 0x36000000, + I3205_TBNZ = 0x37000000, + /* Unconditional branch (immediate). */ I3206_B = 0x14000000, I3206_BL = 0x94000000, @@ -660,6 +678,14 @@ static void tcg_out_insn_3202(TCGContext *s, AArch64Insn insn, tcg_out32(s, insn | tcg_cond_to_aarch64[c] | (imm19 & 0x7ffff) << 5); } +static void tcg_out_insn_3205(TCGContext *s, AArch64Insn insn, + TCGReg rt, int imm6, int imm14) +{ + insn |= (imm6 & 0x20) << (31 - 5); + insn |= (imm6 & 0x1f) << 19; + tcg_out32(s, insn | (imm14 & 0x3fff) << 5 | rt); +} + static void tcg_out_insn_3206(TCGContext *s, AArch64Insn insn, int imm26) { tcg_out32(s, insn | (imm26 & 0x03ffffff)); @@ -1415,41 +1441,65 @@ 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; + int tbit = -1; bool need_cmp = true; switch (c) { case TCG_COND_EQ: case TCG_COND_NE: + /* cmp xN,0; b.ne L -> cbnz xN,L */ if (b_const && b == 0) { need_cmp = false; } break; + case TCG_COND_LT: + case TCG_COND_GE: + /* cmp xN,0; b.mi L -> tbnz xN,63,L */ + if (b_const && b == 0) { + c = (c == TCG_COND_LT ? TCG_COND_TSTNE : TCG_COND_TSTEQ); + tbit = ext ? 63 : 31; + need_cmp = false; + } + break; + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + /* tst xN,1< tbnz xN,B,L */ + if (b_const && is_power_of_2(b)) { + tbit = ctz64(b); + need_cmp = false; + } + break; default: break; } if (need_cmp) { tcg_out_cmp(s, ext, c, a, b, b_const); - } - - if (!l->has_value) { tcg_out_reloc(s, s->code_ptr, R_AARCH64_CONDBR19, l, 0); - offset = tcg_in32(s) >> 5; - } else { - offset = tcg_pcrel_diff(s, l->u.value_ptr) >> 2; - tcg_debug_assert(offset == sextract64(offset, 0, 19)); + tcg_out_insn(s, 3202, B_C, c, 0); + return; } - if (need_cmp) { - tcg_out_insn(s, 3202, B_C, c, offset); + if (tbit >= 0) { + tcg_out_reloc(s, s->code_ptr, R_AARCH64_TSTBR14, l, 0); + switch (c) { + case TCG_COND_TSTEQ: + tcg_out_insn(s, 3205, TBZ, a, tbit, 0); + break; + case TCG_COND_TSTNE: + tcg_out_insn(s, 3205, TBNZ, a, tbit, 0); + break; + default: + g_assert_not_reached(); + } } else { + tcg_out_reloc(s, s->code_ptr, R_AARCH64_CONDBR19, l, 0); switch (c) { case TCG_COND_EQ: - tcg_out_insn(s, 3201, CBZ, ext, a, offset); + tcg_out_insn(s, 3201, CBZ, ext, a, 0); break; case TCG_COND_NE: - tcg_out_insn(s, 3201, CBNZ, ext, a, offset); + tcg_out_insn(s, 3201, CBNZ, ext, a, 0); break; default: g_assert_not_reached(); From patchwork Sun Feb 4 21:40:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769853 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842097wrc; Sun, 4 Feb 2024 13:42:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IFDCBy9rJFZTcO7eIxsOX+XqQj9HJqxk6maqsva8dnH2t+0PpM49UFIvZmVSApO/O30xzXf X-Received: by 2002:a05:620a:b8b:b0:785:59fa:9b38 with SMTP id k11-20020a05620a0b8b00b0078559fa9b38mr6307314qkh.3.1707082936268; Sun, 04 Feb 2024 13:42:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707082936; cv=none; d=google.com; s=arc-20160816; b=GmJs7WdAPT4Opaqf7KCMGxjeIhZMsSCh5O/QDzEh6KS+qaHvFxFAWcu8nv3sX+WNgV G/ZpTJHCcXDxJtvhUJcrx3gSIGBsjPwki0zLgDDNAI9R1H6ILAoBs40mg2kKZqGkMXNl TlU1yQBpin6xeWLJ/KqQVqwVaNedgoChiRGgoXGMQRngrQccIFAW3m2EceFeE1cov2xM 9syUR7Ewp0+IAgUjYjjqb1jBFQn6scz1eYXX0GXBIh8W9Z3w3kpih6Y9xOuIeokMqAiD pkgQVwNSgoBUIhPa0ks1CsiBIZfQQXjpkNv6Q4SPXuTf7bE68eYhilNJXJJLTmqpt8+3 ThTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YlDly1L5SvwoPmODhXTBc/fHcqZbTHU7ULTRsNqIufw=; fh=MmTEpQyBoLoO2cGjeSrwZoiyPEZInP+Q1GgQobmg4Lk=; b=H1k3YKnaj/9R8WxnVzviLcThj7o4105XH6XY13Xmj3Y0Lo38LHJEh3e1Rw8NscsFxR Qkyb1GBphS/CoN2glpvTSsPsw9pWq8Y8b0j+pGU/HyMx7p/qY83CDkwYJGHI3cPn+dh0 WUzrvEq6XxWOA0pALd4oSzPsQo012ZeljW8UW0ZQabikfyFsWLTAkLKW1m673RBT0maq QMBjGBNq6D00TEEzXLa3G1/8fIlRZUTo3fNPgKioC0q4G3q1ey4pYBGOT0+RyeKQWGCy rdWUNt9Vbj9ta5AoMPNo3WbBDcio8bfsGjqZ7zry78Rkd0ZS3viPpJBFIcIsOs5jdoiW /Wgg==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oyHlJTi3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCWR2xTNPAYhZlC0GBwX5d5G8jWGsb/oQjtU9PFCEDM8i2QOipXng0jrwpB0Z9gxvEYbURfs+4Mcg6SVpA3BuL+w Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b4-20020a05620a088400b00785639c6e86si4019373qka.695.2024.02.04.13.42.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:42:16 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oyHlJTi3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkFD-0002IC-GV; Sun, 04 Feb 2024 16:41:43 -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 1rWkFB-0002Hf-N9 for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:41 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkFA-0003Y6-5F for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:41 -0500 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1d9b2400910so1721095ad.0 for ; Sun, 04 Feb 2024 13:41:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082898; x=1707687698; 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=YlDly1L5SvwoPmODhXTBc/fHcqZbTHU7ULTRsNqIufw=; b=oyHlJTi3BZgPGqVS2kSg7pkwhnRS8ConAapw6sAUr2XyB+CEFLV5pUUiE9qO1nxlJ/ ZFhsfrJxD5rLNK+o4NR+69zWY2gB5LLdlEjPlUj21U+/q7MPOUhauSezYhdrPXz1/1mI LKlnM4NtU08DaKLm3xKIWr0uQarjymFjr8whFijMaaDLfc42BhDKq9Z+loeEaULjAFKT wEXIG0xLS4bXpcTswuziX7D672c/xtzpMuMvruGEd+cLfbh6sIDKrjwEm5ty+G8TvANk 3iBJOhHf+PIWuNoLoaKejfLMY6NLORDVlqSyGH8e3TwvjWgikyXi2pkcJ1JgcrTAxKR+ SF3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082898; x=1707687698; 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=YlDly1L5SvwoPmODhXTBc/fHcqZbTHU7ULTRsNqIufw=; b=HomQDxO2Ie7zlCgEzYkf/zzD93ge8YVs8ZL0HX87MW/vBbjlLi30V1nLp2ncMbus5b FS4fz9K6d4DLy+fxg9mX8RbJSjsHmCzbD7ObMgq9/RGvazit5+Ynre95mD1rVLGqaQ87 ldlz3P2s4tik3QaZ8jaoU0vjTx5BOG/F+PDcMqu9ifpWtFxXLjUqbFjEIUVtf/SxdCSM dcmXOBDjq5uCN2C6oo/tGBIWgKTUQ3EVU8qH5YeRTkY+NKimVOVRU6pj7aZ/dEhGBPHC v3yghIi+c6Fco5ovzJrp/zX5FAGivu5skjqZz/O7RoOvWUqxLl6KAGfy+o+z3Gh8cQM7 hXHg== X-Gm-Message-State: AOJu0Yy+qZNZr/bH7lm/CwdWp0lcwe9b3QOMwVZgMR2lDrHSpWx4NIC4 p9fujBWr/I/rDuA01jS2u6vTE8nJpISo2yVCpaLdeXKI96ys7QXglHCLct0s0qHPZssj7qIN8LQ 4ud4= X-Received: by 2002:a17:902:c952:b0:1d9:adc9:2962 with SMTP id i18-20020a170902c95200b001d9adc92962mr1644927pla.20.1707082898629; Sun, 04 Feb 2024 13:41:38 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUMOjWLSGT8ox8/ySYP472LGlCuC10WJBFrh8hBA/drSBUjUWcE0B3aDYal0rrHxx/azxeeBsU3PTWbr8F9SpCz4Q== Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:38 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 20/39] tcg/aarch64: Generate CBNZ for TSTNE of UINT32_MAX Date: Mon, 5 Feb 2024 07:40:33 +1000 Message-Id: <20240204214052.5639-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org ... and the inverse, CBZ for TSTEQ. Suggested-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.c.inc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 36fc46ae93..dec8ecc1b6 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1463,6 +1463,12 @@ static void tcg_out_brcond(TCGContext *s, TCGType ext, TCGCond c, TCGArg a, break; case TCG_COND_TSTEQ: case TCG_COND_TSTNE: + /* tst xN,0xffffffff; b.ne L -> cbnz wN,L */ + if (b_const && b == UINT32_MAX) { + ext = TCG_TYPE_I32; + need_cmp = false; + break; + } /* tst xN,1< tbnz xN,B,L */ if (b_const && is_power_of_2(b)) { tbit = ctz64(b); From patchwork Sun Feb 4 21:40:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769852 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842092wrc; Sun, 4 Feb 2024 13:42:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IEqneqbC0YdUziOnnVflUhD61pmmCmQhmrQp7QxRiH1o8seyl3OZgX4neWRPsv/IsQAEcAH X-Received: by 2002:a05:6808:17a2:b0:3be:abd3:cbaa with SMTP id bg34-20020a05680817a200b003beabd3cbaamr18715525oib.53.1707082931608; Sun, 04 Feb 2024 13:42:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707082931; cv=none; d=google.com; s=arc-20160816; b=eYHP2iUCzFNyaOnTlYPthuDeU0v+s+qvlqEqEqTJdrAjtkp5hwyaeEzNvUjhVolZ4B KVC9V7e77rGLKC+2Y0T4NPj3CPs/CEkdi9U+JHY4rOuCTvMfXMtetCgTspEvKJpcIDsF +2gLo89+FsTqy2o5kwOtux2FgbfIQG3OThSDDXg0f4tlTf1m2uskzmjW6Ku9rQf3NU/N KbagYwCBqtGqiT81YqTR911dZvXeg8zo45PBTDfJhCvNw9bLGZl+4Za18Da7JqDPdZof h5bhVfzc8vynQ+nZzufiLugWNyfDTvQEA+TursBflf8z1LW1i/NnAeKc+AzFH4JJ2E7x pvhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ljp12UTJ8shSwK1Q4724Q6XhwFJKp2WnNNgAtGZJS18=; fh=+ClWV7DhA61JwOQAhfzOZN49B0dfi/ei/cDyhxagcxI=; b=HHO+XemSwLnzE2QCgm84HSj0hUg7/B4x4lZ/1U6IE2us5rYzyWqVNE3VjMBvnCSsiW YefSs2QNqF7oj/DK1jqvHWuAHpevcc1wxD0hZ6t51oXbaL0Tme3YCObgRGNbcjobtb4X 1lic/YMbBC80thSHlpNqr+CtaVhYsvxDceuCVs5l+d8wxCXsdtHeW2XNCYRUlp5x7uni MjY83V+4fLLZ7T3tuM+yqo8k4bEWGMN6ho3LW6/v+rIO/Bowc3K/7xQ1Okh62r22eqM2 MLMVaOz/avhNeuSnFfiE+mDPAW4HCmMVNHWaHnpXTDgkUsYd8AkP/924x8J/ZyszuCym 1fyA==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jqkNLjCL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCXl1m3X1U1Mszm6f5wicMiq70B0myL7Yguk3GOLpX2SY/i45kRnuYVLhAoEWOAIpJl6fzASZwLAdXcP2ZOoLVQ2 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p18-20020ac84612000000b0042c0509f5e9si5686543qtn.324.2024.02.04.13.42.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:42:11 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jqkNLjCL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkFF-0002Uw-TY; Sun, 04 Feb 2024 16:41: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 1rWkFD-0002IF-JF for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:43 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkFB-0003YJ-V8 for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:43 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1d73066880eso33260785ad.3 for ; Sun, 04 Feb 2024 13:41:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082900; x=1707687700; 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=Ljp12UTJ8shSwK1Q4724Q6XhwFJKp2WnNNgAtGZJS18=; b=jqkNLjCLJ661EsfgrwuCu1PrfyqJjSx/W0b22Snc6Hqj2PNTyw6bBQ4T5u+f2KoWv6 O1qfqz9l9nZX/j1KBwHvSudipLzqEf08Ejx8KMT7CFwEwO5K6LpXWnjb50Keosz2gMjn LBHQ+yQIX1gJRoQcL4nFHqYQo1jCZGPdbgRQFIQ9yhMFfGGVGUat5ni4dBuJNGHKkHj4 GPMr27ffe87VYcmsdAkkVeVnxjPjvvp07pvqlLoVQxoJvndzJMhL3nwtgJostY01akiB /CMb/BKVrumLOC78v3nimRosyZ/m7GO/M0UQEUGMr4pIfqnBsQTR26bdOe9JfzKsnhYi /gSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082900; x=1707687700; 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=Ljp12UTJ8shSwK1Q4724Q6XhwFJKp2WnNNgAtGZJS18=; b=dA8WnpptDwnn6HipEoI1l1yy7h0/jt6Azxs1Rm6Zyb2prsdKhvuagXAvVtqoGSu+9P mAqcYuUAIvu/2awWI3l0jo29Gu9+20ijHvcnwj+0/GgJEFIpyu2AxZwhDROPaA+LVvOK KIJdwjO+ujRz8Ax5usQLC6Dh1o2c703rnHX7obqRqJuRWazI5X9/i0NApDsdiCWMnlie GZNaXR/r7PSafXxAqYvOHeEF8b9iJSkKhz7J15emoFGr+EVD2NBmjZNJ1G/h22P5jGu8 yVlnsX81O1y1Fv2mZA2olXDtga8TzIB0sAlOrUXSOl7dfH4Ixugz61GfeSNqHQiUsbdG Pylg== X-Gm-Message-State: AOJu0YxdoPd/WFN+nya4KF/twMaNbBDKt2xTJwdll//UpAWdw0YluWqE INC9MgjKaxGWJJaPLQDH0gw2vI+bGxu6KvUUMlPbaqLrxkHsO01vljY+vMnaig1fSUs08vuccMl sG5c= X-Received: by 2002:a17:902:eb82:b0:1d9:8082:4573 with SMTP id q2-20020a170902eb8200b001d980824573mr9358736plg.2.1707082900696; Sun, 04 Feb 2024 13:41:40 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:40 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 21/39] tcg/arm: Split out tcg_out_cmp() Date: Mon, 5 Feb 2024 07:40:34 +1000 Message-Id: <20240204214052.5639-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20231028194522.245170-12-richard.henderson@linaro.org> [PMD: Split from bigger patch, part 1/2] Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20231108145244.72421-1-philmd@linaro.org> --- 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 113094a5b2..4ea17845bb 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1191,6 +1191,13 @@ static void tcg_out_mb(TCGContext *s, TCGArg a0) } } +static TCGCond tcg_out_cmp(TCGContext *s, TCGCond cond, TCGReg a, + TCGArg b, int b_const) +{ + tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, a, b, b_const); + return cond; +} + static TCGCond tcg_out_cmp2(TCGContext *s, const TCGArg *args, const int *const_args) { @@ -1809,9 +1816,8 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, /* Constraints mean that v2 is always in the same register as dest, * so we only need to do "if condition passed, move v1 to dest". */ - tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, - args[1], args[2], const_args[2]); - tcg_out_dat_rIK(s, tcg_cond_to_arm_cond[args[5]], ARITH_MOV, + c = tcg_out_cmp(s, args[5], args[1], args[2], const_args[2]); + tcg_out_dat_rIK(s, tcg_cond_to_arm_cond[c], ARITH_MOV, ARITH_MVN, args[0], 0, args[3], const_args[3]); break; case INDEX_op_add_i32: @@ -1961,25 +1967,21 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, break; case INDEX_op_brcond_i32: - tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, - args[0], args[1], const_args[1]); - tcg_out_goto_label(s, tcg_cond_to_arm_cond[args[2]], - arg_label(args[3])); + c = tcg_out_cmp(s, args[2], args[0], args[1], const_args[1]); + tcg_out_goto_label(s, tcg_cond_to_arm_cond[c], arg_label(args[3])); break; case INDEX_op_setcond_i32: - tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, - args[1], args[2], const_args[2]); - tcg_out_dat_imm(s, tcg_cond_to_arm_cond[args[3]], + c = tcg_out_cmp(s, args[3], args[1], args[2], const_args[2]); + tcg_out_dat_imm(s, tcg_cond_to_arm_cond[c], ARITH_MOV, args[0], 0, 1); - tcg_out_dat_imm(s, tcg_cond_to_arm_cond[tcg_invert_cond(args[3])], + tcg_out_dat_imm(s, tcg_cond_to_arm_cond[tcg_invert_cond(c)], ARITH_MOV, args[0], 0, 0); break; case INDEX_op_negsetcond_i32: - tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, - args[1], args[2], const_args[2]); - tcg_out_dat_imm(s, tcg_cond_to_arm_cond[args[3]], + c = tcg_out_cmp(s, args[3], args[1], args[2], const_args[2]); + tcg_out_dat_imm(s, tcg_cond_to_arm_cond[c], ARITH_MVN, args[0], 0, 0); - tcg_out_dat_imm(s, tcg_cond_to_arm_cond[tcg_invert_cond(args[3])], + tcg_out_dat_imm(s, tcg_cond_to_arm_cond[tcg_invert_cond(c)], ARITH_MOV, args[0], 0, 0); break; From patchwork Sun Feb 4 21:40:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769859 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842297wrc; Sun, 4 Feb 2024 13:43:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IE4RqivSFcpTuJY4U3e3m3+W7pLYMHo3xXFMSuLoI98GlLBZfLgkt+CbN5T5YrS6YdTCkb9 X-Received: by 2002:a05:620a:918:b0:785:445f:6a1b with SMTP id v24-20020a05620a091800b00785445f6a1bmr10049480qkv.4.1707082994949; Sun, 04 Feb 2024 13:43:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707082994; cv=none; d=google.com; s=arc-20160816; b=BK97ot+xK+GVdaPOIK1xoiCekSENkpki93Jm5qstOLS/TgLKE6ksMAnuVxrwk6f6Sk K4nRQpV0s69XAUhtKGxjwCAUQKVhH3Y0kbhA7UeV26ledmZa8h1TgJHZgAtyTWROQBty 90UWoNZD/DJtaCHuZHlpCnGh/aMsqLp+nR5dyVKHFmOmLTrxQ2V56/EPSAXl71GyN7pJ xlBC25jAy8YK7TAeek4PimcHIX1UL/9eGU7lUPp6fMpVy8F6fGwvZiCLNir09/ETH40B 80y7LypxPvISPr+RW9xTURDZNbJ0EvrInh6uHS1Rtc58pMAEiyJPxxsggMbhP5UsRKMe OK1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5CxoD/ygedGQlZZ8hQ+rOVALVQqC62zieEa9yKFNrZc=; fh=X8b0dR8EeG/ikgRVht7CunLT8jTt7ogw2i7+U/OrKsE=; b=OJyl3qpg+79Jovs20Q/Y6id1Dj1nqGaAepNt0Aw8ZXCthV6swiOg5ifenHpzJbm8mH t5aa6AP3TaTjDQvS6lwaRfqeCRnfd/K0M6hrnJy622qtMpdIwP/sncVJoBuwE9RwNi26 EEepkQyvId8EnTxSQZWnHbdReb1WQsum3tu7g86SDpKiDQzFvvYZIMRgG3Sa2MRJT//3 1WObNzWjh5YC7Be01BTwibeqj9zrIXfBWpqI0BPw6wSMbmqzXR7ShYOiAVL26To25Oy6 UU8ow2Jth56Xp8iWmHZSdgprusUQqnSzHLumXUccWyRThw12f/hsB1JOLT+kRK9V+MrV pkCw==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U7UcnqYr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCU+uopqAU5B9nUCVIyYakk8l+QbdnSSXKHUYiGHt9IYewPZJ4tdxPwTip+ADrYMidoataOLIXf9jiZTEsQu9iSh Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j24-20020a37ef18000000b00783f816a5e3si6960018qkk.107.2024.02.04.13.43.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:43:14 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U7UcnqYr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkFL-0002XD-4X; Sun, 04 Feb 2024 16:41: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 1rWkFH-0002WX-KB for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:47 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkFF-0003YW-6j for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:46 -0500 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1d780a392fdso32533585ad.3 for ; Sun, 04 Feb 2024 13:41:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082903; x=1707687703; 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=5CxoD/ygedGQlZZ8hQ+rOVALVQqC62zieEa9yKFNrZc=; b=U7UcnqYrqOm8eF34pC/W3tmb6nM7Zm4XqydlyaogPsFtzIFL4iYEH76VImqRWQxjda OYkg2hweShtz5yOj62TYTaE0EqsDgBqif9C5B+DPfnCCEvadE0oNy3DY+U5DjbUO9OA6 jakXqA3KyvOJS2Fk9oggShZ8KzqD+gcpOPTNu+g1pOwiMAaNGSh5kuEkrmfkxWSFxu9t gOMIELvZR6IBvkhrgCuCNiEEQc67xYqAviXs7Au7q1mdnMYVicxHL8X851zCdPjD2psK 2aEdezvYUlPC+xPkxnrBl/UdzKsoqsBQ+HPBqS6Ij+Qzmk1RxKrf5RRCBr+oFYMeqLsF wzLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082903; x=1707687703; 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=5CxoD/ygedGQlZZ8hQ+rOVALVQqC62zieEa9yKFNrZc=; b=D2I05lP4PdMT1zz85XcOVV6CU8iQCR+VaMQGlREziymEgWD55S7V8XeCH+ktWOKDAB xgoNsyCAT9KWhMI20PWNZNuCBTF5PgxFALyhZU8Othzo5H4tDBiCEx6kq+/3fQ34oLz0 6s+ONeYNJJ3vK9yJPw/dY1sgEQeVR4u4aT0Dzbub2LHU8EQjoUOt7OylQBVOmlHlz4p/ /nfcaPL5+TX2/KAuIJFp+5FgJxjuPF+lHgUPNGMCLD4AhO3joj1KeUKMCfQuhQkyVe5Z tKTR8wBnGA1DRBA8diA2DQ0afen5IkXWibRK5y48ELkb1GjbU9dleVhbkybeaBIv+T3t rzFw== X-Gm-Message-State: AOJu0YwOHNxVcUbPHcuv1ZYaPPiZyfiVWDH70uWaxQ/vdIqPJATe9Gqu Zt/GYGQBJmtqVr84XGg7xRatJx507ITLRvkHLuYp7RQsshJA+AzKkEvifVsGGnSFauq+p32+IlC Z2RU= X-Received: by 2002:a17:902:e88f:b0:1d9:bc11:66e with SMTP id w15-20020a170902e88f00b001d9bc11066emr703029plg.37.1707082902853; Sun, 04 Feb 2024 13:41:42 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:42 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 22/39] tcg/arm: Support TCG_COND_TST{EQ,NE} Date: Mon, 5 Feb 2024 07:40:35 +1000 Message-Id: <20240204214052.5639-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20231028194522.245170-12-richard.henderson@linaro.org> [PMD: Split from bigger patch, part 2/2] Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20231108145244.72421-2-philmd@linaro.org> --- tcg/arm/tcg-target.h | 2 +- tcg/arm/tcg-target.c.inc | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index 7bf42045a7..a43875cb09 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -125,7 +125,7 @@ extern bool use_neon_instructions; #define TCG_TARGET_HAS_qemu_ldst_i128 0 -#define TCG_TARGET_HAS_tst 0 +#define TCG_TARGET_HAS_tst 1 #define TCG_TARGET_HAS_v64 use_neon_instructions #define TCG_TARGET_HAS_v128 use_neon_instructions diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 4ea17845bb..ffd23ef789 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1194,7 +1194,27 @@ static void tcg_out_mb(TCGContext *s, TCGArg a0) static TCGCond tcg_out_cmp(TCGContext *s, TCGCond cond, TCGReg a, TCGArg b, int b_const) { - tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, a, b, b_const); + if (!is_tst_cond(cond)) { + tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, a, b, b_const); + return cond; + } + + cond = tcg_tst_eqne_cond(cond); + if (b_const) { + int imm12 = encode_imm(b); + + /* + * The compare constraints allow rIN, but TST does not support N. + * Be prepared to load the constant into a scratch register. + */ + if (imm12 >= 0) { + tcg_out_dat_imm(s, COND_AL, ARITH_TST, 0, a, imm12); + return cond; + } + tcg_out_movi32(s, COND_AL, TCG_REG_TMP, b); + b = TCG_REG_TMP; + } + tcg_out_dat_reg(s, COND_AL, ARITH_TST, 0, a, b, SHIFT_IMM_LSL(0)); return cond; } @@ -1225,6 +1245,13 @@ static TCGCond tcg_out_cmp2(TCGContext *s, const TCGArg *args, tcg_out_dat_rI(s, COND_EQ, ARITH_CMP, 0, al, bl, const_bl); return cond; + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + /* Similar, but with TST instead of CMP. */ + tcg_out_dat_rI(s, COND_AL, ARITH_TST, 0, ah, bh, const_bh); + tcg_out_dat_rI(s, COND_EQ, ARITH_TST, 0, al, bl, const_bl); + return tcg_tst_eqne_cond(cond); + case TCG_COND_LT: case TCG_COND_GE: /* We perform a double-word subtraction and examine the result. From patchwork Sun Feb 4 21:40:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769856 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842175wrc; Sun, 4 Feb 2024 13:42:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IHSaKky9ZLEoMsSMrF3cyf5ghuLLNmjFtV2LTop4obIVcxa/ZtuaikuYCd93md4CtEb5oy1 X-Received: by 2002:ac8:130a:0:b0:42b:e6ad:b020 with SMTP id e10-20020ac8130a000000b0042be6adb020mr5736275qtj.33.1707082961964; Sun, 04 Feb 2024 13:42:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707082961; cv=none; d=google.com; s=arc-20160816; b=tmBDyHgIzaek9uBiRPdQjmC063kuQXeekOyTLms6RpRl9tgTH4v0fhObWWOSOAoAO+ FYPakE0lzEfD5snxTUz57M8xUEH3f0/01ljJtIeoXxi+ObrDetatRRGOL7H9KdTFi0ae h2YYpbSrBT9a6+54No+SWlqHiwwTpfbGj4HIM04tLXo3GtdN/Oo0rvd5O3DXbMi8yLQm VqWNAohRwGPO3IJyRaI72+Xxig2VDvVR4HBPuVXhnA3fgWU0ZuJ1IMzSZvSgN+tuu9Qc +aojNfCYsx0VT7c2O+ElTriNwm5fo2B0sciWocjekiogMEXgWNcWeih97eUtoMoOw1ct z9Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hIn73/7L0/UvLzTpfBg1BsspTF3e93L6IUnQvuIa2EY=; fh=gz7q1jFrLb4fGwoZEXkmp9ggwsknK733cTRynvFpbtM=; b=SdJZ4CuMk24iKydWkUO24QQURCaJCcpqOPKhlaEjn8mvfLkDIxW/Q9cz1UoNEboujp UVa7dItO7TvmknYfIQdH4ZgWOHq1Jdxgpjlc7II3KeIkgofhwXaXbQxt4wdZZf7x7g/G F+Mig3ePfQTIYWp/Lw37rQOlaWcNLr6voUIfLDWC6OuN3zPIRCveXfo4tyVGb+h2ezdF ql/QxJ347Z1DLVBGUfWBhDYsGwjxDTn3cmWm7r0+mQDzDPxG8nIBDPIelhdjVQFLNSds bv3OlnN2ZAAiHDcUSx5LR9M6ugi5CmDuDFQHrCx64YfUudP7kGGqIdZZSHZslFfrJRf6 Lxhg==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ZZR/75q5"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCXpNYIQ/zWmzR/VBSDPYltNSGAmZROeQasBuV+o5go3RXStsC0LM6Ml8/off4One6xGEFsHJfip4FWJgwvOmPN0 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j5-20020a05620a0a4500b0078534458ea7si7016745qka.39.2024.02.04.13.42.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:42:41 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ZZR/75q5"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkFM-0002Xu-6n; Sun, 04 Feb 2024 16:41:52 -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 1rWkFH-0002We-S1 for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:47 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkFG-0003Yk-68 for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:47 -0500 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1d9b2400910so1721385ad.0 for ; Sun, 04 Feb 2024 13:41:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082905; x=1707687705; 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=ZZR/75q5nFwwSicoFVqm2pu2L2zRUXWXLfK6CoUEVO3Y/QggrGulSm3BunGNN98hAf d9wppF0yiBgTh7XNJMKmTo82IVwCWIzImyDG1a8texXDvmaYTfsQquSK1AR+LGonfM5h n6f7SiTe+csO1A/BJgh6YXbNyxfyxt8CBkGITTBgoBVlYqeKdL0E9Tq3T/soTjEJa8zC WhlccH1LmxuULH9GWhMxvqudkZ1MvVB3Fw4EIvDEbRHk2IqreovTNmxIfkq1+ZX4f+ks Jv2u/j8zfSplVq1tF2F78kfkEKbYg5Zo2ZXlPZRRnH457MEOjQf8LTbWMkeKT+688NBk V26w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082905; x=1707687705; 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=QjweXN2nhbIwYCW6uIAns/1PQi6p3wWQUkCXTnTM/0TwZc1ItF/Ryta4dLDhvvc9NA MEcu5z376E45qv1CsOHGNOqncNgShdsbcRn9cpMswBfzLLRD7mNYLGrvAR0m5DOro5JY F6IpA6+vF+BDz+OlCB3V4zRJ3rzPmjLNf8eE9S4RN6FYhfjrQdJJDI6JSp+qNTgc7Oj8 Zfdd7YLk+nrpgICV2su8EiSDXHn+kobhLYkPP2ruB1ilYP+yosxEm/LvlaXzV3I2eZiH VYe+rcTuLa57S7on0xh0fwy1TmgWBB1HotFtwNS4OLFnJ99L367qQSJTE+wTULMd9rYZ kTAQ== X-Gm-Message-State: AOJu0Yy3qR5/loiQZ0gZscUjsG+4xfzFLGsiUOy05wCFqEXxEySaKWki OXsEkGSvoGqo3yE2J2DYDBHBt7MOJZXv3DzBN9oCFb2617ObNVSunCoL10EaW7pGH6dAcvWSURK QEkk= X-Received: by 2002:a17:903:234b:b0:1d8:ff72:eef8 with SMTP id c11-20020a170903234b00b001d8ff72eef8mr7029712plh.18.1707082904974; Sun, 04 Feb 2024 13:41:44 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 23/39] tcg/i386: Pass x86 condition codes to tcg_out_cmov Date: Mon, 5 Feb 2024 07:40:36 +1000 Message-Id: <20240204214052.5639-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Hoist the tcg_cond_to_jcc index outside the function. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.c.inc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index accaaa2660..2d6100a8f4 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1699,14 +1699,14 @@ static void tcg_out_setcond2(TCGContext *s, const TCGArg *args, } #endif -static void tcg_out_cmov(TCGContext *s, TCGCond cond, int rexw, +static void tcg_out_cmov(TCGContext *s, int jcc, int rexw, TCGReg dest, TCGReg v1) { if (have_cmov) { - tcg_out_modrm(s, OPC_CMOVCC | tcg_cond_to_jcc[cond] | rexw, dest, v1); + tcg_out_modrm(s, OPC_CMOVCC | jcc | rexw, dest, v1); } else { TCGLabel *over = gen_new_label(); - tcg_out_jxx(s, tcg_cond_to_jcc[tcg_invert_cond(cond)], over, 1); + tcg_out_jxx(s, jcc ^ 1, over, 1); tcg_out_mov(s, TCG_TYPE_I32, dest, v1); tcg_out_label(s, over); } @@ -1717,7 +1717,7 @@ static void tcg_out_movcond(TCGContext *s, int rexw, TCGCond cond, TCGReg v1) { tcg_out_cmp(s, c1, c2, const_c2, rexw); - tcg_out_cmov(s, cond, rexw, dest, v1); + tcg_out_cmov(s, tcg_cond_to_jcc[cond], rexw, dest, v1); } static void tcg_out_ctz(TCGContext *s, int rexw, TCGReg dest, TCGReg arg1, @@ -1729,12 +1729,12 @@ static void tcg_out_ctz(TCGContext *s, int rexw, TCGReg dest, TCGReg arg1, tcg_debug_assert(arg2 == (rexw ? 64 : 32)); } else { tcg_debug_assert(dest != arg2); - tcg_out_cmov(s, TCG_COND_LTU, rexw, dest, arg2); + tcg_out_cmov(s, JCC_JB, rexw, dest, arg2); } } else { tcg_debug_assert(dest != arg2); tcg_out_modrm(s, OPC_BSF + rexw, dest, arg1); - tcg_out_cmov(s, TCG_COND_EQ, rexw, dest, arg2); + tcg_out_cmov(s, JCC_JE, rexw, dest, arg2); } } @@ -1747,7 +1747,7 @@ static void tcg_out_clz(TCGContext *s, int rexw, TCGReg dest, TCGReg arg1, tcg_debug_assert(arg2 == (rexw ? 64 : 32)); } else { tcg_debug_assert(dest != arg2); - tcg_out_cmov(s, TCG_COND_LTU, rexw, dest, arg2); + tcg_out_cmov(s, JCC_JB, rexw, dest, arg2); } } else { tcg_debug_assert(!const_a2); @@ -1760,7 +1760,7 @@ static void tcg_out_clz(TCGContext *s, int rexw, TCGReg dest, TCGReg arg1, /* Since we have destroyed the flags from BSR, we have to re-test. */ tcg_out_cmp(s, arg1, 0, 1, rexw); - tcg_out_cmov(s, TCG_COND_EQ, rexw, dest, arg2); + tcg_out_cmov(s, JCC_JE, rexw, dest, arg2); } } From patchwork Sun Feb 4 21:40:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769864 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842375wrc; Sun, 4 Feb 2024 13:43:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IEN8XCM50+dAFLi9a91eqNFkUaD4pADMaOFlZ/XoONuVcgCpYulcrkANOKW2BeZQrJLv7lw X-Received: by 2002:a05:6214:d63:b0:68c:9b62:a39c with SMTP id 3-20020a0562140d6300b0068c9b62a39cmr4799246qvs.0.1707083016115; Sun, 04 Feb 2024 13:43:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083016; cv=none; d=google.com; s=arc-20160816; b=V4dk4mY7AjvDtmig5r/DL8KJ4iB/yHp3YbxEfcaXV/I+nKoZVzRzy6g2CoPw47B6Os FOMTf4hLbraAVxtJZKAY+Vxey77qh2Y6OzmtfX/J4FfF7HSTMZrmubgtXXfK0Sc8UmS0 v0GH7n6BwMiRmBzJkumhOkjD0Cb7c6LP0enp+mLoMfJzV6FRhzom0uiUJmTJmqz+mKTI Wang0shryXN8moEeS8UfmQ2No5iVtVfFnqZGUPiTjLkoc8zkMVmncfsg91uytYrtMZM+ /eAJwILpT+LhooQLDId4PzVdqiuu4O4jRuodoqXkYMwuR55EOndATkwyOTJadtgq59C/ 9vsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SYMLLwA9gva4L4uzAlLYH7HUcuo07hrL8DJH/YZuBt8=; fh=AkktZJhrhHNP2Tl8Tm6Yn5QZGD/EAhsYstglmeHRrRk=; b=ljGV7Qu6yNIxZvpzNpqMCMsyQfFePF702rY5E5sFfq2SDEPY57sgp97Cz0f2R0LVt/ XG7Aq8xpGgVB+tKhueh/4diJTaDazq3iXjv5uzEAfcYprzUa0Pmsb5eRKNOA0ohmUIDv flkvSa0Vq8bTzvJbVWZNWBUdIIH53MCuymloEJX9g6ljn9iqVrVzXSYrhqjikyZ6V/oq mWFd6/3DPG47zYMJJAyHLVG6kjijLHmctcHI4tgcR8cb8frScZSi/mYTHpih4rmntYpy zEw82aWYND/b9xxHhvh2U65G2kJuNwfKt/UvKnTGmte/qD9BcGcPhxWilQbHBECTim3X qgvA==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GSebdVSu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCXmPVoLmqY4dbSRe+gjgU+lvaZgz1vgig3LeXTMDNjD392yNuB4HXsNnulsdVDFkaDELJe1uQLAXnpU6Lmb/+ar Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t11-20020a0cea2b000000b0068c7e6c4168si7001649qvp.281.2024.02.04.13.43.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:43:36 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GSebdVSu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkFU-0002jG-By; Sun, 04 Feb 2024 16:42:02 -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 1rWkFK-0002XE-Q8 for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:51 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkFJ-0003Yr-4d for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:50 -0500 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1d94323d547so29786105ad.3 for ; Sun, 04 Feb 2024 13:41:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082907; x=1707687707; 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=GSebdVSurZNb6NcQ68d5k/THNdh+/FUoAiMdoPp+85YcC8QM60JNah0jtvpsjNb9XQ X3XZBPEg7EaFwvWpuqdr2EYcw3Wdxmi4Zi4gEIhZhC34WuXy95EgvesdW9M1gJOYPWUI VmnCkB78YHHT46TjYyHIh8cfTHHaMamhow6jya/ZJ4DbXnAS84vpx3EWk6XnnJ4CryIP 4z2qqPVCDveChe9Vpef0rUntfE+BKp+cT0MKwA4KBLZdLzEIRTsoK0j6+ayBXw9YTpbP 0x1kqt/leOiXWL9SrL0sI0ruHf6iosW4tApTFFt53FyGdl+1YPLqttn9v26rt52gPqAr 2NIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082907; x=1707687707; 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=CLNgRHN8AQhewfSXYFDPGjG6z6NArmR6Ra6kiE4gQbxoNr2cEv8R/SZOSJLtqdXm3w vro/wCc8neAGmsxTzQlOi+VSxBq3NSX7SZXIud+XX0QquGlxEl/a1RHialVwsuuIuJoD dL7YFlwY2vATw1gfFznHBzNN7EfVaN5QzraDhh+rS3gSGzIFWHQfEbc4TJlhf55ahvOZ EsU4R8LsjmCLNZ2MSS4W7zO83gjWLf500DdBDs+cwcpbYsdJ6rrk77WqPEWDLp2ybOaN S/fC6WbGjcPvgikPJLPR/5tUD8GE924ja/2S7vX8DDnP9fbO7ZrXzd5xpcezAYHYBdnc WXyg== X-Gm-Message-State: AOJu0Yywf6ZIC2b3KYlb5z9yKMAohpmu7VLYfHer7XCiltYjicG5SeoM hPiGWYAsYzznemNCNpaclTcay5sNcxrQW88RYiHo2iklGl317oj+PFCgNsKVcKa+xH7USDrj1hP vh/k= X-Received: by 2002:a17:902:d507:b0:1d9:b789:b1b9 with SMTP id b7-20020a170902d50700b001d9b789b1b9mr1201114plg.40.1707082907030; Sun, 04 Feb 2024 13:41:47 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:46 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 24/39] tcg/i386: Move tcg_cond_to_jcc[] into tcg_out_cmp Date: Mon, 5 Feb 2024 07:40:37 +1000 Message-Id: <20240204214052.5639-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Return the x86 condition codes to use after the compare. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.c.inc | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 2d6100a8f4..02718a02d8 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1449,8 +1449,8 @@ static void tcg_out_jxx(TCGContext *s, int opc, TCGLabel *l, bool small) } } -static void tcg_out_cmp(TCGContext *s, TCGArg arg1, TCGArg arg2, - int const_arg2, int rexw) +static int tcg_out_cmp(TCGContext *s, TCGCond cond, TCGArg arg1, + TCGArg arg2, int const_arg2, int rexw) { if (const_arg2) { if (arg2 == 0) { @@ -1462,14 +1462,15 @@ static void tcg_out_cmp(TCGContext *s, TCGArg arg1, TCGArg arg2, } else { tgen_arithr(s, ARITH_CMP + rexw, arg1, arg2); } + return tcg_cond_to_jcc[cond]; } static void tcg_out_brcond(TCGContext *s, int rexw, TCGCond cond, TCGArg arg1, TCGArg arg2, int const_arg2, TCGLabel *label, bool small) { - tcg_out_cmp(s, arg1, arg2, const_arg2, rexw); - tcg_out_jxx(s, tcg_cond_to_jcc[cond], label, small); + int jcc = tcg_out_cmp(s, cond, arg1, arg2, const_arg2, rexw); + tcg_out_jxx(s, jcc, label, small); } #if TCG_TARGET_REG_BITS == 32 @@ -1561,6 +1562,7 @@ static void tcg_out_setcond(TCGContext *s, int rexw, TCGCond cond, { bool inv = false; bool cleared; + int jcc; switch (cond) { case TCG_COND_NE: @@ -1597,7 +1599,7 @@ static void tcg_out_setcond(TCGContext *s, int rexw, TCGCond cond, * We can then use NEG or INC to produce the desired result. * This is always smaller than the SETCC expansion. */ - tcg_out_cmp(s, arg1, arg2, const_arg2, rexw); + tcg_out_cmp(s, TCG_COND_LTU, arg1, arg2, const_arg2, rexw); /* X - X - C = -C = (C ? -1 : 0) */ tgen_arithr(s, ARITH_SBB + (neg ? rexw : 0), dest, dest); @@ -1644,8 +1646,8 @@ static void tcg_out_setcond(TCGContext *s, int rexw, TCGCond cond, cleared = true; } - tcg_out_cmp(s, arg1, arg2, const_arg2, rexw); - tcg_out_modrm(s, OPC_SETCC | tcg_cond_to_jcc[cond], 0, dest); + jcc = tcg_out_cmp(s, cond, arg1, arg2, const_arg2, rexw); + tcg_out_modrm(s, OPC_SETCC | jcc, 0, dest); if (!cleared) { tcg_out_ext8u(s, dest, dest); @@ -1716,8 +1718,8 @@ static void tcg_out_movcond(TCGContext *s, int rexw, TCGCond cond, TCGReg dest, TCGReg c1, TCGArg c2, int const_c2, TCGReg v1) { - tcg_out_cmp(s, c1, c2, const_c2, rexw); - tcg_out_cmov(s, tcg_cond_to_jcc[cond], rexw, dest, v1); + int jcc = tcg_out_cmp(s, cond, c1, c2, const_c2, rexw); + tcg_out_cmov(s, jcc, rexw, dest, v1); } static void tcg_out_ctz(TCGContext *s, int rexw, TCGReg dest, TCGReg arg1, @@ -1759,8 +1761,8 @@ static void tcg_out_clz(TCGContext *s, int rexw, TCGReg dest, TCGReg arg1, tgen_arithi(s, ARITH_XOR + rexw, dest, rexw ? 63 : 31, 0); /* Since we have destroyed the flags from BSR, we have to re-test. */ - tcg_out_cmp(s, arg1, 0, 1, rexw); - tcg_out_cmov(s, JCC_JE, rexw, dest, arg2); + int jcc = tcg_out_cmp(s, TCG_COND_EQ, arg1, 0, 1, rexw); + tcg_out_cmov(s, jcc, rexw, dest, arg2); } } From patchwork Sun Feb 4 21:40:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769857 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842276wrc; Sun, 4 Feb 2024 13:43:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IHb4iYvFi4Y0YGCqtTckcuIOSgxGhWsb5d9rBxbr4dSZPLfx046aWu6N2PdzZObFvZoWsdZ X-Received: by 2002:a05:620a:2205:b0:77f:8c54:da15 with SMTP id m5-20020a05620a220500b0077f8c54da15mr9482153qkh.40.1707082988922; Sun, 04 Feb 2024 13:43:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707082988; cv=none; d=google.com; s=arc-20160816; b=cEEXhoheJ1usbin8zVbv8sgm5J/M3j2Fxq4yW5WgdkIobTpBAYoeN5lwZ8cs0S5GoG YsLyor3IJSbaXV3xojEi1ngnp2dYAGZv2XZE1dAl0m61hvIvz9irtRqw9BOs8zxHgP7v IpjDw4aHviLVsFQzHICWanfpLJ//enTNsOIG2wrdUS4s5Uw9ArGaOLJ6T9bCZugrHOIr GJEEFTmsahv67K8xPLObOkgS9uIuKPy85xMS3NklG5lJnmAp46kJ9nUfJKcr/OJg+FaQ P5kTFTT1/aN8AtLwTlpccpRrN7a0ikqBS9YquYB/gHJdzaN2DkesuA425zuiV/f7ywSa fROA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Od/xSXS8NstAz+sWZVmhj5MEuIknHRPAQGdZXQ5yceo=; fh=DbNQnUR8Y8b+LRWhGXW9ESUBaqjcbJwkIAF5/fFgz10=; b=j4zKyOvToqoTiXAH3T/3hSYXyH6ZPLFL0O4LgoxsGC2bM/4gD0ul2SnWE76PUpaIaS hgKgLoS6/kxIh7wccRdIEAkCIcgcKevR5EsJwO/9hmYLmC+SWDboU3IHX8VlJAjsLfr2 su5X4yYY9II+flOHJKA08TXDzA4AznvUCR9+vVGaAdRJavuQi4HmmhF32k7GsikzTCOk kb/cPWJwNK40yu/QIua9uyEii7QeNf7wOkKtZYJrrR1tib0sCcsgbHqYa3HW2pf+9MiF M3H6EckyJpglm9Cz8XZbQtu0dKKf/9G5hTXDdpIocO935KVZsztQe1u2HOR+q7i73H1+ XwUg==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SLO9Ia3r; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCXt7sWeunnYdBy8C7AKcTimFoM87uAuUH5EV7lkd4QAlbvYKX1CgpTZz4VGdlfEphRNLoToJwWZ3OAqW3Fe1tEK Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h10-20020ac8744a000000b0042c00c3138csi6391076qtr.367.2024.02.04.13.43.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:43:08 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SLO9Ia3r; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkFQ-0002cE-Mi; Sun, 04 Feb 2024 16:41: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 1rWkFM-0002Y1-5R for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:52 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkFK-0003Z4-8E for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:51 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1d7232dcb3eso27236955ad.2 for ; Sun, 04 Feb 2024 13:41:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082909; x=1707687709; 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=SLO9Ia3r4v4Daltp8toKeIOQqe7vGnqHdX9DPV33H1hTxd2cM+AnyuDWJyfcmMgcq2 oroc779APiI8ZyBZBL/72U4y3zfFiAkLaQBq0132vv2+oW4djkxFUFC5dra6RipD0PkC rLwQMIjkNjyv4zGEc7YVrmi+oMrsA3VGY76T8dtQW4UrCNYfDZm+GVTEIBkNiy2vfisx OY1PpBEzLv2wsf5G8ZDLlwjSIKhw/1JxHHhDBzJDHC1h52lOBwW/Ag5mNgerAYfNl2Jn X7oeDHF4m49ZHqIDf/VzMTIOkyn0JPrjOdkwdiTEEULGLMO9IEttNWRG1u0gYcSWiEcP 0cXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082909; x=1707687709; 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=B7fckriWqkwxZO7YYt8jD52JY/V0ORqyUhDCTv5VDwHH+esWMRFtqMWW4zSqwhi7ur MoBaDchdWxhWZLxcuCeTpWW8Hm2njKk7icy4J0zocHrLQzJnNTpsMp0doE58RSyhqlFx RWWrWUbMpxtktPuTJenGsgwyEGjO326rpEVuF8qMCbGQNMO1flIJIkRVEKpuIP6PgHW4 gQnIXbtJgicKJ7a6Nu9+KGX43TDpR+UVDj4sE8KDIEJzY1VlbNcoJPPNj4SDq7Wwe5S4 /aE5N/Cn14Q6mYWDoSwMah5XVwnRYmjB2miP5LpQ4EnCXLev7gl5VpUMyuvn4hVdlp1o cz7Q== X-Gm-Message-State: AOJu0YxjaUPrEDAJiJKvGfJprHpHRzI9ID5r6Md1IiudkfCEVTp9D72M KE3Cze8z0AEYphe8WERk6AFBegcqimeQv/OP8O6l3fC0bXfjti1XQIKMmgLaRmvfa3Wkpqo3r0Y KlGI= X-Received: by 2002:a17:902:e9c4:b0:1d8:f06f:5cfa with SMTP id 4-20020a170902e9c400b001d8f06f5cfamr6575716plk.59.1707082909052; Sun, 04 Feb 2024 13:41:49 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:48 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 25/39] tcg/i386: Support TCG_COND_TST{EQ,NE} Date: Mon, 5 Feb 2024 07:40:38 +1000 Message-Id: <20240204214052.5639-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Merge tcg_out_testi into tcg_out_cmp and adjust the two uses. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.h | 2 +- tcg/i386/tcg-target.c.inc | 95 ++++++++++++++++++++++++--------------- 2 files changed, 60 insertions(+), 37 deletions(-) diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index 1dd917a680..a10d4e1fce 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -198,7 +198,7 @@ typedef enum { #define TCG_TARGET_HAS_qemu_ldst_i128 \ (TCG_TARGET_REG_BITS == 64 && (cpuinfo & CPUINFO_ATOMIC_VMOVDQA)) -#define TCG_TARGET_HAS_tst 0 +#define TCG_TARGET_HAS_tst 1 /* We do not support older SSE systems, only beginning with AVX1. */ #define TCG_TARGET_HAS_v64 have_avx1 diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 02718a02d8..f2414177bd 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -506,6 +506,8 @@ static const uint8_t tcg_cond_to_jcc[] = { [TCG_COND_GEU] = JCC_JAE, [TCG_COND_LEU] = JCC_JBE, [TCG_COND_GTU] = JCC_JA, + [TCG_COND_TSTEQ] = JCC_JE, + [TCG_COND_TSTNE] = JCC_JNE, }; #if TCG_TARGET_REG_BITS == 64 @@ -1452,17 +1454,49 @@ static void tcg_out_jxx(TCGContext *s, int opc, TCGLabel *l, bool small) static int tcg_out_cmp(TCGContext *s, TCGCond cond, TCGArg arg1, TCGArg arg2, int const_arg2, int rexw) { - if (const_arg2) { - if (arg2 == 0) { - /* test r, r */ + int jz; + + if (!is_tst_cond(cond)) { + if (!const_arg2) { + tgen_arithr(s, ARITH_CMP + rexw, arg1, arg2); + } else if (arg2 == 0) { tcg_out_modrm(s, OPC_TESTL + rexw, arg1, arg1); } else { + tcg_debug_assert(!rexw || arg2 == (int32_t)arg2); tgen_arithi(s, ARITH_CMP + rexw, arg1, arg2, 0); } - } else { - tgen_arithr(s, ARITH_CMP + rexw, arg1, arg2); + return tcg_cond_to_jcc[cond]; } - return tcg_cond_to_jcc[cond]; + + jz = tcg_cond_to_jcc[cond]; + + if (!const_arg2) { + tcg_out_modrm(s, OPC_TESTL + rexw, arg1, arg2); + return jz; + } + + if (arg2 <= 0xff && (TCG_TARGET_REG_BITS == 64 || arg1 < 4)) { + tcg_out_modrm(s, OPC_GRP3_Eb | P_REXB_RM, EXT3_TESTi, arg1); + tcg_out8(s, arg2); + return jz; + } + + if ((arg2 & ~0xff00) == 0 && arg1 < 4) { + tcg_out_modrm(s, OPC_GRP3_Eb, EXT3_TESTi, arg1 + 4); + tcg_out8(s, arg2 >> 8); + return jz; + } + + if (rexw) { + if (arg2 == (uint32_t)arg2) { + rexw = 0; + } else { + tcg_debug_assert(arg2 == (int32_t)arg2); + } + } + tcg_out_modrm(s, OPC_GRP3_Ev + rexw, EXT3_TESTi, arg1); + tcg_out32(s, arg2); + return jz; } static void tcg_out_brcond(TCGContext *s, int rexw, TCGCond cond, @@ -1479,18 +1513,21 @@ static void tcg_out_brcond2(TCGContext *s, const TCGArg *args, { TCGLabel *label_next = gen_new_label(); TCGLabel *label_this = arg_label(args[5]); + TCGCond cond = args[4]; - switch(args[4]) { + switch (cond) { case TCG_COND_EQ: - tcg_out_brcond(s, 0, TCG_COND_NE, args[0], args[2], const_args[2], - label_next, 1); - tcg_out_brcond(s, 0, TCG_COND_EQ, args[1], args[3], const_args[3], + case TCG_COND_TSTEQ: + tcg_out_brcond(s, 0, tcg_invert_cond(cond), + args[0], args[2], const_args[2], label_next, 1); + tcg_out_brcond(s, 0, cond, args[1], args[3], const_args[3], label_this, small); break; case TCG_COND_NE: - tcg_out_brcond(s, 0, TCG_COND_NE, args[0], args[2], const_args[2], + case TCG_COND_TSTNE: + tcg_out_brcond(s, 0, cond, args[0], args[2], const_args[2], label_this, small); - tcg_out_brcond(s, 0, TCG_COND_NE, args[1], args[3], const_args[3], + tcg_out_brcond(s, 0, cond, args[1], args[3], const_args[3], label_this, small); break; case TCG_COND_LT: @@ -1827,23 +1864,6 @@ static void tcg_out_nopn(TCGContext *s, int n) tcg_out8(s, 0x90); } -/* Test register R vs immediate bits I, setting Z flag for EQ/NE. */ -static void __attribute__((unused)) -tcg_out_testi(TCGContext *s, TCGReg r, uint32_t i) -{ - /* - * This is used for testing alignment, so we can usually use testb. - * For i686, we have to use testl for %esi/%edi. - */ - if (i <= 0xff && (TCG_TARGET_REG_BITS == 64 || r < 4)) { - tcg_out_modrm(s, OPC_GRP3_Eb | P_REXB_RM, EXT3_TESTi, r); - tcg_out8(s, i); - } else { - tcg_out_modrm(s, OPC_GRP3_Ev, EXT3_TESTi, r); - tcg_out32(s, i); - } -} - typedef struct { TCGReg base; int index; @@ -2104,16 +2124,17 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h, tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_L0, TCG_REG_L0, offsetof(CPUTLBEntry, addend)); } else if (a_mask) { - ldst = new_ldst_label(s); + int jcc; + ldst = new_ldst_label(s); ldst->is_ld = is_ld; ldst->oi = oi; ldst->addrlo_reg = addrlo; ldst->addrhi_reg = addrhi; - tcg_out_testi(s, addrlo, a_mask); /* jne slow_path */ - tcg_out_opc(s, OPC_JCC_long + JCC_JNE, 0, 0, 0); + jcc = tcg_out_cmp(s, TCG_COND_TSTNE, addrlo, a_mask, true, false); + tcg_out_opc(s, OPC_JCC_long + jcc, 0, 0, 0); ldst->label_ptr[0] = s->code_ptr; s->code_ptr += 4; } @@ -2259,9 +2280,10 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg datalo, TCGReg datahi, } else { TCGLabel *l1 = gen_new_label(); TCGLabel *l2 = gen_new_label(); + int jcc; - tcg_out_testi(s, h.base, 15); - tcg_out_jxx(s, JCC_JNE, l1, true); + jcc = tcg_out_cmp(s, TCG_COND_TSTNE, h.base, 15, true, false); + tcg_out_jxx(s, jcc, l1, true); tcg_out_vex_modrm_sib_offset(s, OPC_MOVDQA_VxWx + h.seg, TCG_TMP_VEC, 0, @@ -2387,9 +2409,10 @@ static void tcg_out_qemu_st_direct(TCGContext *s, TCGReg datalo, TCGReg datahi, } else { TCGLabel *l1 = gen_new_label(); TCGLabel *l2 = gen_new_label(); + int jcc; - tcg_out_testi(s, h.base, 15); - tcg_out_jxx(s, JCC_JNE, l1, true); + jcc = tcg_out_cmp(s, TCG_COND_TSTNE, h.base, 15, true, false); + tcg_out_jxx(s, jcc, l1, true); tcg_out_vex_modrm_sib_offset(s, OPC_MOVDQA_WxVx + h.seg, TCG_TMP_VEC, 0, From patchwork Sun Feb 4 21:40:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769863 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842353wrc; Sun, 4 Feb 2024 13:43:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IF8oervzNk77z0C/kd7Hxcc31PvqWAnCW5NvJx3arYrJMb4A/DLoJfaCmMgLORPf8NsTS78 X-Received: by 2002:a05:622a:1493:b0:42c:1f88:a559 with SMTP id t19-20020a05622a149300b0042c1f88a559mr2453507qtx.38.1707083007510; Sun, 04 Feb 2024 13:43:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083007; cv=none; d=google.com; s=arc-20160816; b=mSf1hvAQbwzf1NRELSHUH5AI+yTh3nL4z2aqaVFHgAj65CH9dU01o2jh3XhD8u3hgP MWKqN7kxn0iaV7T3prIeDUztP7wZs1cjp4boquZOMi0vyqqnvQEdZ0JqA25X6HhVMmLR hLAWOYwoj2gTcrbc1886/oJl2mfI9lYOp4MuUejDCjHX7ZtdLYceSgnPL2lEyMk9iyYF 01KOLPiIoQxbxZwQ1bIHKqMEGM8bMV4RdecxJi0JbRCoY3pS1F564QgnRDzp7+25YV9I pqOKRscX69giVRWsA3crRuJZQPrBSi5pAB3FaQY+u1gVOLWC0nXMmzbzorKM3N3RV8Jr EO2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=1PZbgXf7h9mbijZSSPVJBmVbPzLYGP5B2/srtOcMXg4=; fh=RGG3jYmCaGf47RNuSthOCuonESzegIURTZmcJjec+3U=; b=GgTKyt776GVluK9Ufp1k0OsG4lV+GYNa30JB3SFrF613vK/D3o4HERSE/rHD2aVV4N 9b5FKEQSHbBw0Ti82WJfzydbF7yxfQ3T4kK8GdRu8IHjSymWa5kzmSYJwMeFam2vTMff OPqS3HRj5NUAOVuV75O3Ai2M22omyf5nldyle+G4p6ZqvB2vC+fi1oafb96MWzgR11y4 scGsW99IsPqoso8byGwRctGUaaNXP8znVib5ldjFw++gaXZjVRv+BmPQAHcWRlOjO3oe jlZbHj1wy7bug76Y0N8TjVa6sJXbjA9kdyq61QF/U/YTmViQ8DA/Db8qvS+S3CLbCUqq lvCg==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fK+KUwmm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCVh5mOaiHSWL4MyKGdOrVR0ZF1P0moNtS+6rZpyQrrNIHUQ2fivmhXlvE11ol2rMCliBhn9EwiD8D3FjuQNEy1v Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n4-20020a05622a11c400b0042c26382d90si752224qtk.161.2024.02.04.13.43.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:43:27 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fK+KUwmm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkFY-0002wH-0x; Sun, 04 Feb 2024 16:42: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 1rWkFN-0002bt-W9 for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:54 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkFM-0003ZF-29 for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:53 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1d953fa3286so26175705ad.2 for ; Sun, 04 Feb 2024 13:41:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082911; x=1707687711; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=1PZbgXf7h9mbijZSSPVJBmVbPzLYGP5B2/srtOcMXg4=; b=fK+KUwmmEcSf8ocga9VcPhl/uz47PhvIDlYX8cfeglHSBDevSDoT3yqyz9zl3Wp48e mWpXKn2CNFTXCITBSyIktJZeyNF7e2t9Z6f0I/oLoMHLswc6ixcJSAiOqLDdK5eRYVBk I6fZaCMWaoPWe6Xq5ORwbA7S8LsmFuWSDQ35LVZZcI1wY7eSQwCRuEZTJVLmEDKtgr1W QcdRnnN8N631yq4pHad9YQ0KlLjCbjNEJNLP0+dwIEDD9vfsJ9w4C0VcWfuIb8eOzSD2 EXUIJimXAKjJ51HA/aMi2rKCB9Df2x+ykmNwqmeYIW+xkEnZw06q23jX5+/WrHzy9Kp7 82ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082911; x=1707687711; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1PZbgXf7h9mbijZSSPVJBmVbPzLYGP5B2/srtOcMXg4=; b=N7dtK+MtbnTMOhq/bjVX8BzD7a/VCDT6waOI2iMJy7OqvlXgWDiN0czUcx2C/BXqOW o3v5/nrlS+Gwp/oEZBLsXuOLlSFoXkV6Q6SruV26tOTMz0O3/iiK5VGOz9i9zZnZX2Rm tMKpLpcgEoKgAlVa2C0POPsQiYf3Mr8OZkniOvfXGcpLr3eJN1GQtBcmMvhDSu82AvLx Sk/hGx961NSoDQ9vc9Np4/zkMfzjbP1+b17ihPeUjXSF2OI98qlKYoUmUW5e8lOpJTWM L9y+DaaeiszpL16Wt4PfdQpBVFRQV1wuLDJiDCjF6Eozg9aqxByrfpANMQnJKKcSV3Du MFQw== X-Gm-Message-State: AOJu0YzrWvcrcvpsFuiHBLIpLC/MsrHc/az3WzuEWdte14A++/TD8jN9 F05F2G7upqOHfVO+SXRPnrMFuHIXGv/ALfjHyvbn9YGG2nUEWvSqgufTbnU26xXeM2WGK+a4Sq7 bvEg= X-Received: by 2002:a17:903:28e:b0:1d8:f016:cfae with SMTP id j14-20020a170903028e00b001d8f016cfaemr16394473plr.0.1707082910817; Sun, 04 Feb 2024 13:41:50 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:50 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 26/39] tcg/i386: Improve TSTNE/TESTEQ vs powers of two Date: Mon, 5 Feb 2024 07:40:39 +1000 Message-Id: <20240204214052.5639-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use "test x,x" when the bit is one of the 4 sign bits. Use "bt imm,x" otherwise. Signed-off-by: Richard Henderson --- tcg/i386/tcg-target-con-set.h | 6 ++-- tcg/i386/tcg-target-con-str.h | 1 + tcg/i386/tcg-target.c.inc | 54 +++++++++++++++++++++++++++++++---- 3 files changed, 53 insertions(+), 8 deletions(-) diff --git a/tcg/i386/tcg-target-con-set.h b/tcg/i386/tcg-target-con-set.h index 7d00a7dde8..e24241cfa2 100644 --- a/tcg/i386/tcg-target-con-set.h +++ b/tcg/i386/tcg-target-con-set.h @@ -20,7 +20,7 @@ C_O0_I2(L, L) C_O0_I2(qi, r) C_O0_I2(re, r) C_O0_I2(ri, r) -C_O0_I2(r, re) +C_O0_I2(r, reT) C_O0_I2(s, L) C_O0_I2(x, r) C_O0_I3(L, L, L) @@ -34,7 +34,7 @@ C_O1_I1(r, r) C_O1_I1(x, r) C_O1_I1(x, x) C_O1_I2(q, 0, qi) -C_O1_I2(q, r, re) +C_O1_I2(q, r, reT) C_O1_I2(r, 0, ci) C_O1_I2(r, 0, r) C_O1_I2(r, 0, re) @@ -50,7 +50,7 @@ C_N1_I2(r, r, r) C_N1_I2(r, r, rW) C_O1_I3(x, 0, x, x) C_O1_I3(x, x, x, x) -C_O1_I4(r, r, re, r, 0) +C_O1_I4(r, r, reT, r, 0) C_O1_I4(r, r, r, ri, ri) C_O2_I1(r, r, L) C_O2_I2(a, d, a, r) diff --git a/tcg/i386/tcg-target-con-str.h b/tcg/i386/tcg-target-con-str.h index 95a30e58cd..cc22db227b 100644 --- a/tcg/i386/tcg-target-con-str.h +++ b/tcg/i386/tcg-target-con-str.h @@ -28,5 +28,6 @@ REGS('s', ALL_BYTEL_REGS & ~SOFTMMU_RESERVE_REGS) /* qemu_st8_i32 data */ */ CONST('e', TCG_CT_CONST_S32) CONST('I', TCG_CT_CONST_I32) +CONST('T', TCG_CT_CONST_TST) CONST('W', TCG_CT_CONST_WSZ) CONST('Z', TCG_CT_CONST_U32) diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index f2414177bd..0b8c60d021 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -132,6 +132,7 @@ static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) #define TCG_CT_CONST_U32 0x200 #define TCG_CT_CONST_I32 0x400 #define TCG_CT_CONST_WSZ 0x800 +#define TCG_CT_CONST_TST 0x1000 /* Registers used with L constraint, which are the first argument registers on x86_64, and two random call clobbered registers on @@ -202,7 +203,8 @@ static bool tcg_target_const_match(int64_t val, int ct, return 1; } if (type == TCG_TYPE_I32) { - if (ct & (TCG_CT_CONST_S32 | TCG_CT_CONST_U32 | TCG_CT_CONST_I32)) { + if (ct & (TCG_CT_CONST_S32 | TCG_CT_CONST_U32 | + TCG_CT_CONST_I32 | TCG_CT_CONST_TST)) { return 1; } } else { @@ -215,6 +217,17 @@ static bool tcg_target_const_match(int64_t val, int ct, if ((ct & TCG_CT_CONST_I32) && ~val == (int32_t)~val) { return 1; } + /* + * This will be used in combination with TCG_CT_CONST_S32, + * so "normal" TESTQ is already matched. Also accept: + * TESTQ -> TESTL (uint32_t) + * TESTQ -> BT (is_power_of_2) + */ + if ((ct & TCG_CT_CONST_TST) + && is_tst_cond(cond) + && (val == (uint32_t)val || is_power_of_2(val))) { + return 1; + } } if ((ct & TCG_CT_CONST_WSZ) && val == (type == TCG_TYPE_I32 ? 32 : 64)) { return 1; @@ -396,6 +409,7 @@ static bool tcg_target_const_match(int64_t val, int ct, #define OPC_SHLX (0xf7 | P_EXT38 | P_DATA16) #define OPC_SHRX (0xf7 | P_EXT38 | P_SIMDF2) #define OPC_SHRD_Ib (0xac | P_EXT) +#define OPC_TESTB (0x84) #define OPC_TESTL (0x85) #define OPC_TZCNT (0xbc | P_EXT | P_SIMDF3) #define OPC_UD2 (0x0b | P_EXT) @@ -442,6 +456,12 @@ static bool tcg_target_const_match(int64_t val, int ct, #define OPC_GRP3_Ev (0xf7) #define OPC_GRP5 (0xff) #define OPC_GRP14 (0x73 | P_EXT | P_DATA16) +#define OPC_GRPBT (0xba | P_EXT) + +#define OPC_GRPBT_BT 4 +#define OPC_GRPBT_BTS 5 +#define OPC_GRPBT_BTR 6 +#define OPC_GRPBT_BTC 7 /* Group 1 opcode extensions for 0x80-0x83. These are also used as modifiers for OPC_ARITH. */ @@ -1454,7 +1474,7 @@ static void tcg_out_jxx(TCGContext *s, int opc, TCGLabel *l, bool small) static int tcg_out_cmp(TCGContext *s, TCGCond cond, TCGArg arg1, TCGArg arg2, int const_arg2, int rexw) { - int jz; + int jz, js; if (!is_tst_cond(cond)) { if (!const_arg2) { @@ -1469,6 +1489,7 @@ static int tcg_out_cmp(TCGContext *s, TCGCond cond, TCGArg arg1, } jz = tcg_cond_to_jcc[cond]; + js = (cond == TCG_COND_TSTNE ? JCC_JS : JCC_JNS); if (!const_arg2) { tcg_out_modrm(s, OPC_TESTL + rexw, arg1, arg2); @@ -1476,17 +1497,40 @@ static int tcg_out_cmp(TCGContext *s, TCGCond cond, TCGArg arg1, } if (arg2 <= 0xff && (TCG_TARGET_REG_BITS == 64 || arg1 < 4)) { + if (arg2 == 0x80) { + tcg_out_modrm(s, OPC_TESTB | P_REXB_R, arg1, arg1); + return js; + } tcg_out_modrm(s, OPC_GRP3_Eb | P_REXB_RM, EXT3_TESTi, arg1); tcg_out8(s, arg2); return jz; } if ((arg2 & ~0xff00) == 0 && arg1 < 4) { + if (arg2 == 0x8000) { + tcg_out_modrm(s, OPC_TESTB, arg1 + 4, arg1 + 4); + return js; + } tcg_out_modrm(s, OPC_GRP3_Eb, EXT3_TESTi, arg1 + 4); tcg_out8(s, arg2 >> 8); return jz; } + if (is_power_of_2(rexw ? arg2 : (uint32_t)arg2)) { + int jc = (cond == TCG_COND_TSTNE ? JCC_JB : JCC_JAE); + int sh = ctz64(arg2); + + rexw = (sh & 32 ? P_REXW : 0); + if ((sh & 31) == 31) { + tcg_out_modrm(s, OPC_TESTL | rexw, arg1, arg1); + return js; + } else { + tcg_out_modrm(s, OPC_GRPBT | rexw, OPC_GRPBT_BT, arg1); + tcg_out8(s, sh); + return jc; + } + } + if (rexw) { if (arg2 == (uint32_t)arg2) { rexw = 0; @@ -3399,7 +3443,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_brcond_i32: case INDEX_op_brcond_i64: - return C_O0_I2(r, re); + return C_O0_I2(r, reT); case INDEX_op_bswap16_i32: case INDEX_op_bswap16_i64: @@ -3447,11 +3491,11 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_setcond_i64: case INDEX_op_negsetcond_i32: case INDEX_op_negsetcond_i64: - return C_O1_I2(q, r, re); + return C_O1_I2(q, r, reT); case INDEX_op_movcond_i32: case INDEX_op_movcond_i64: - return C_O1_I4(r, r, re, r, 0); + return C_O1_I4(r, r, reT, r, 0); case INDEX_op_div2_i32: case INDEX_op_div2_i64: From patchwork Sun Feb 4 21:40:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769866 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842442wrc; Sun, 4 Feb 2024 13:44:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFdBCk5BNaEwvDmL7m3NjifT4ROzk+SZGT2YKNFSq0P5vm6aeKC3aPPgxIJdeCRY15FNVwN X-Received: by 2002:a05:6214:1409:b0:68c:7cbb:272e with SMTP id pr9-20020a056214140900b0068c7cbb272emr7193740qvb.19.1707083045462; Sun, 04 Feb 2024 13:44:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083045; cv=none; d=google.com; s=arc-20160816; b=SNMaIBZY0dYQ3bKBCk7fKnOLy9InnGrWAC3pU4C79x9JQwrx+Fa9myRPb7je9sRo2M Ie3Sv996bLJFA35DyWwTtK9hSddBPsh3tvhCQbsJre/S4UMTh+FCOLcAlBnbX4yHZkcJ Maio4bLFaFOrJlHn2nUIITKYkRcyVtvmU4IrmkWoZu9OD3DPSxisuoux3Si7Jlmujl7t 5f0/DuwTmz3pTrMlBLDOmU3b8bITPHTUmnyzyVUw03kiNrmto4pVQwskN6FzsfwtUWgG VMTh5aOhujZzek4dn6ob93rc6N9YmQiG0z7q2i6eBmA17AjFA7UtTha5roOb1HTFAOQz we7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=edCRhkheTbWQuXgwAiS/gonGTZ3kw+g3zID7Qd9CYvo=; fh=G8bOH1s0bf4XLT9m3QvGcWNnXGOWSr5kvOEPLiYj5qs=; b=dy/RzgHPsWdwCQx4sUd2XBsxUegmjoGSjAwI1T3kvDHI+lGOcPfHIfcIvWzimUHYKo v3wFHMUBmpWAfmbsQrc5mzVthbYPZVRH4eEMqqBz4XeLYBFs4iUuoB4wUQ9LoKBsiVbM NbQdhLUkeEpJHwGF0WGdQN9pCHXzcjPATwLyTqU/cuqbCv/F05eju5Lchj/BfGTkC2e7 MmsNdXJCJ+0znumo/YjQHYMJV0u+nVLtQPbcQ0NBmB064rPUJrgu7N+qUyASJ82wCkA9 uJCVD4/bnNaNEeDAyZg2rmHMXEfQxFa7YpxHc4zUgHNFzNXj5ajwGwFpqI6jzAiTKO3l onAA==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P2pMkmVl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCVACmz5T4ufsq4PgM9KvQWrCgvIbfdb/RxulCHGlMYgsXRrvPmpLQ149TyOfEA2IQebrmnUdV1jJxdYLpuBQ4rT Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y4-20020a0cf144000000b0068c5d1c3aa8si7184947qvl.221.2024.02.04.13.44.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:44:05 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P2pMkmVl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkFb-0003D5-H7; Sun, 04 Feb 2024 16:42:07 -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 1rWkFR-0002jD-3k for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:58 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkFO-0003ar-Dg for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:56 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1d9b2400910so1721715ad.0 for ; Sun, 04 Feb 2024 13:41:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082913; x=1707687713; 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=edCRhkheTbWQuXgwAiS/gonGTZ3kw+g3zID7Qd9CYvo=; b=P2pMkmVleiDXoiuFTahCg5mvh2hAR+xZ09QwFEeFbTls1C+G1pf8jFYT5Uz3u5lv4S S3vkFh2bNkDPAgzkCfw8yjzjVqQuhWg77uP1CU5YgeGgDWdxVLjOC9bzmZNTqvS0wf51 NNyZZSboJiMOy+IH2WnShGlbMh5OvtK1OQ6BAPY5dYGdL+VF96rP9QfIBkWRz6qm6018 00n0JXJhsFv5U3VLIFvQGNNJooluQ4KZXNAF66sjLCsXxNaHxuqoh89o4OajZl5fb2DD lwCYCCp/ENROXI+TLbKmaR2szu4IK0X9ry3q5bMQQo7ErdmosR/SOEch8dEzrqjOsys3 lwnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082913; x=1707687713; 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=edCRhkheTbWQuXgwAiS/gonGTZ3kw+g3zID7Qd9CYvo=; b=GQkCkWzlDUjaazyfTA65DS31L0xwmGmER46QFl/E/syt5abf5eucwdxGXgZlJAIrY0 ug9KHlhUYXXrgUFSVKKXPS/U6Yf0MqUZxej8TIh9bjk3ZXVE4ojf2+AJFDzDUTe9YCpw VvR39QoxyUipuMWsMH2K+/PDynkfzuTDzO3tF+82Ddp4Edz6zRSoohNl9F4uzdPGf/Dw USCCztDhERur8tbd6ey9jSHn3rU4kIRN/ZFaiDmJUbuuY4cTBvzsUUyEmZM5Ksvfpay6 Gv6jWd1PHZ0xt0jOFJ9fdMBpixZL3b1AacDTLEqX61coO3HNB1FuSHANXdoOghpRNNvH RVVw== X-Gm-Message-State: AOJu0YyZ/Sxf+cLa0TJrwGNE9J3m4aGEYGMCcBaQzTIFrkVpvuW5wuCi AMhjn3LGq3yGtY6NSjyDN94kIIU1KTZafnpLsVMwfQAjCiwPlozNZOh1KoDQ58XDmU+crVQnh+v ehUM= X-Received: by 2002:a17:903:41c6:b0:1d8:f6af:77db with SMTP id u6-20020a17090341c600b001d8f6af77dbmr5557498ple.12.1707082913232; Sun, 04 Feb 2024 13:41:53 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVidpJ+iI7gT50DufGL5Yz0fogQzJnYYlDnMat1HNEPWOygrhd1OQdNFQPT0psZRb2sWlmZ5G+wKa/mImin3RZb+A== Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 27/39] tcg/i386: Use TEST r,r to test 8/16/32 bits Date: Mon, 5 Feb 2024 07:40:40 +1000 Message-Id: <20240204214052.5639-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Paolo Bonzini Just like when testing against the sign bits, TEST r,r can be used when the immediate is 0xff, 0xff00, 0xffff, 0xffffffff. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.c.inc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 0b8c60d021..c6ba498623 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1501,6 +1501,10 @@ static int tcg_out_cmp(TCGContext *s, TCGCond cond, TCGArg arg1, tcg_out_modrm(s, OPC_TESTB | P_REXB_R, arg1, arg1); return js; } + if (arg2 == 0xff) { + tcg_out_modrm(s, OPC_TESTB | P_REXB_R, arg1, arg1); + return jz; + } tcg_out_modrm(s, OPC_GRP3_Eb | P_REXB_RM, EXT3_TESTi, arg1); tcg_out8(s, arg2); return jz; @@ -1511,11 +1515,24 @@ static int tcg_out_cmp(TCGContext *s, TCGCond cond, TCGArg arg1, tcg_out_modrm(s, OPC_TESTB, arg1 + 4, arg1 + 4); return js; } + if (arg2 == 0xff00) { + tcg_out_modrm(s, OPC_TESTB, arg1 + 4, arg1 + 4); + return jz; + } tcg_out_modrm(s, OPC_GRP3_Eb, EXT3_TESTi, arg1 + 4); tcg_out8(s, arg2 >> 8); return jz; } + if (arg2 == 0xffff) { + tcg_out_modrm(s, OPC_TESTL | P_DATA16, arg1, arg1); + return jz; + } + if (arg2 == 0xffffffffu) { + tcg_out_modrm(s, OPC_TESTL, arg1, arg1); + return jz; + } + if (is_power_of_2(rexw ? arg2 : (uint32_t)arg2)) { int jc = (cond == TCG_COND_TSTNE ? JCC_JB : JCC_JAE); int sh = ctz64(arg2); From patchwork Sun Feb 4 21:40:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769872 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842547wrc; Sun, 4 Feb 2024 13:44:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IFZEbxNqBFQwrnEG2ej/ciZjWLTnDAnTjEXsh6J/EEkN0+7isBBZHt0HHmjaJ5kv4gkFzXa X-Received: by 2002:a05:622a:20c:b0:42c:1083:df67 with SMTP id b12-20020a05622a020c00b0042c1083df67mr6446191qtx.6.1707083079810; Sun, 04 Feb 2024 13:44:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083079; cv=none; d=google.com; s=arc-20160816; b=p+vyw1Zu6zhJvvOIqBUZgeC0frYX/L98xg6PgnOQfH3EKjowuo04zULzCIHkh4zu3K Psc0vmKJMOkMph2yEj67J2XaDXuLHfcMqX96k7WElgbssiXFVd0JOq3Z9VQZhxok+Bw7 z1SYHkxtIEI3kRskIscofzsvZtLYUr5woSI6KkaoC/umM8iFCTKOZQ/jx8G/0Xk5UkGf SLjyERN7wOHlJB3I5TRSZEu0STkKufMzCkFTTAs5ZGCHmDaVaJ9OCpOFNnz4J7PWri2H K0+VKd/qwg6KIeW85M/sCKC10D+7LfBlEEpy+bC5IYfSUkvlUmouB41jqqK1YNtTQrLy mYww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=w7DMJgHEIfczGa+x10sgEDsRXfwUGwOd6p01k71b3vA=; fh=RO5wEP/eDHCjEqjWHB2V+MMzY34S5lXRW79/vTDpu7Q=; b=AIVkUOvf6S5bq7iaJ1woSc45qlIZBS0/rFcA49tTdfHIuhCXLhrRs1iP/VxDspA0Il gzfkg4NWWdSCUmjwZxWQVXtZcip7Zy1Dd2V/0oreXLfF/K8E0PEJ20L3apvUsjUJoLAH nIDYFtieAwKlc0awqdXuQv/RPVNole1reOjFTdoj+ygpZiwC6VVCaK6XhC3c1KDwHsGu v0a/wEf9Ekqqy0buGYt7+jaxD5Iz7Lp0eZXHz2ZvR0+MjA2h/lb2NMbNWho+meyn0BkR GpTAcyq4p35ET8gu8ji8umbFcTHJwIoHCwQnmvaBLbn8hGlqDe4umxIF06ACk0zXEWqq caZQ==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HlO9ieAY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCU/PJYJ2L/pwe0F6zuaXfqecWNs8Zs6ua0s0Cc19kTJmYsf7NBAI72PGGjTbNc4Jt21oNntC99mz+zc9LlJX50p Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e20-20020ac85994000000b0042c15d80e59si3341370qte.344.2024.02.04.13.44.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:44:39 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HlO9ieAY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkFd-0003Ow-16; Sun, 04 Feb 2024 16:42:09 -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 1rWkFS-0002t5-Nn for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:42:00 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkFQ-0003b3-Ka for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:41:58 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d9b2400910so1721775ad.0 for ; Sun, 04 Feb 2024 13:41:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082915; x=1707687715; 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=HlO9ieAYYe4uZC/h/HF3D/TWoMKTK1/YXtGVoBBEA1p+8roAmbjhGWETFPOUMeQreq ZZ1BOemCAP55GZ8E+uhleKjfbRAfnUG2JZMyuwqJc8ZvP8LQM1d15AG6vM/3BqWkbiWT b0naTO3CfUE6P5hMlcBtTqwkn3uwnl71Vl2/60aHEUJ8+Hq3vBJdZmJQHP2E0qnnjuwI ijJx3t+5P9spkpXDEpyAm8OOIa4mEq70Uk3INY3cvHaX7jbhWjYzlxPvas3SEbiqm85R XM+4k+p9QzrFeLbI/qgdL9TFeCEnmUCe9FGB3atIxhI2cmKylTn63KwbaH+77rfRrS90 WgTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082915; x=1707687715; 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=f49TXlGuB8x40f7DtfnxAq14aqB/xO5hOguBjHam4NBFiaMqk1f0xAfW/wsenlr51T q+jXmqJcLPiRApgcVwFfckV9AlvWwOdYuvWTnGn81wzVyUGnrN/de93EdpIRf8XfxPDp LdiGadMLZ6JHsjm+q3jr4AIIHbVDY6mXhT7NON0Pe4gWXzI5SyBwqsr3nJ4bqfAV3FcL u5jGtU+W5pgXXH5y2SJBwTzpCfioXG2piTCfQxsPigkIlcofQSV3S5FM3I2hxK6KtHNV 44zDyeSakM/5+HOTcXHjU/enWztnflV+qlvMQ+RYvdKBfvDKCS0ROoRU0QtsiT81ClIP v+Zw== X-Gm-Message-State: AOJu0YyMSP2vSW5WlM5JxNNmhRh+IkkgWqMVj5+YZ5Rt4sRN7Fi+BkOS eLM4yWqWmSsjcs/uCn1Oex+USUwG5HlmbCTP7e4qbi6uJ+RyD2mOFxXPioY/ZnZGXL5xiIG3F/c bZeg= X-Received: by 2002:a17:902:e882:b0:1d9:30e3:ea84 with SMTP id w2-20020a170902e88200b001d930e3ea84mr5965524plg.2.1707082915311; Sun, 04 Feb 2024 13:41:55 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 28/39] tcg/sparc64: Hoist read of tcg_cond_to_rcond Date: Mon, 5 Feb 2024 07:40:41 +1000 Message-Id: <20240204214052.5639-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use a non-zero value here (an illegal encoding) as a better condition than is_unsigned_cond for when MOVR/BPR is usable. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/sparc64/tcg-target.c.inc | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc index ac86b92b75..e16b25e309 100644 --- a/tcg/sparc64/tcg-target.c.inc +++ b/tcg/sparc64/tcg-target.c.inc @@ -620,7 +620,7 @@ static const uint8_t tcg_cond_to_bcond[] = { [TCG_COND_GTU] = COND_GU, }; -static const uint8_t tcg_cond_to_rcond[] = { +static const uint8_t tcg_cond_to_rcond[16] = { [TCG_COND_EQ] = RCOND_Z, [TCG_COND_NE] = RCOND_NZ, [TCG_COND_LT] = RCOND_LZ, @@ -679,7 +679,8 @@ static void tcg_out_brcond_i64(TCGContext *s, TCGCond cond, TCGReg arg1, int32_t arg2, int const_arg2, TCGLabel *l) { /* For 64-bit signed comparisons vs zero, we can avoid the compare. */ - if (arg2 == 0 && !is_unsigned_cond(cond)) { + int rcond = tcg_cond_to_rcond[cond]; + if (arg2 == 0 && rcond) { int off16 = 0; if (l->has_value) { @@ -688,7 +689,7 @@ static void tcg_out_brcond_i64(TCGContext *s, TCGCond cond, TCGReg arg1, tcg_out_reloc(s, s->code_ptr, R_SPARC_WDISP16, l, 0); } tcg_out32(s, INSN_OP(0) | INSN_OP2(3) | BPR_PT | INSN_RS1(arg1) - | INSN_COND(tcg_cond_to_rcond[cond]) | off16); + | INSN_COND(rcond) | off16); } else { tcg_out_cmp(s, arg1, arg2, const_arg2); tcg_out_bpcc(s, tcg_cond_to_bcond[cond], BPCC_XCC | BPCC_PT, l); @@ -696,11 +697,10 @@ static void tcg_out_brcond_i64(TCGContext *s, TCGCond cond, TCGReg arg1, tcg_out_nop(s); } -static void tcg_out_movr(TCGContext *s, TCGCond cond, TCGReg ret, TCGReg c1, +static void tcg_out_movr(TCGContext *s, int rcond, TCGReg ret, TCGReg c1, int32_t v1, int v1const) { - tcg_out32(s, ARITH_MOVR | INSN_RD(ret) | INSN_RS1(c1) - | (tcg_cond_to_rcond[cond] << 10) + tcg_out32(s, ARITH_MOVR | INSN_RD(ret) | INSN_RS1(c1) | (rcond << 10) | (v1const ? INSN_IMM10(v1) : INSN_RS2(v1))); } @@ -711,9 +711,9 @@ static void tcg_out_movcond_i64(TCGContext *s, TCGCond cond, TCGReg ret, /* For 64-bit signed comparisons vs zero, we can avoid the compare. Note that the immediate range is one bit smaller, so we must check for that as well. */ - if (c2 == 0 && !is_unsigned_cond(cond) - && (!v1const || check_fit_i32(v1, 10))) { - tcg_out_movr(s, cond, ret, c1, v1, v1const); + int rcond = tcg_cond_to_rcond[cond]; + if (c2 == 0 && rcond && (!v1const || check_fit_i32(v1, 10))) { + tcg_out_movr(s, rcond, ret, c1, v1, v1const); } else { tcg_out_cmp(s, c1, c2, c2const); tcg_out_movcc(s, cond, MOVCC_XCC, ret, v1, v1const); @@ -788,6 +788,8 @@ static void tcg_out_setcond_i32(TCGContext *s, TCGCond cond, TCGReg ret, static void tcg_out_setcond_i64(TCGContext *s, TCGCond cond, TCGReg ret, TCGReg c1, int32_t c2, int c2const, bool neg) { + int rcond; + if (use_vis3_instructions && !neg) { switch (cond) { case TCG_COND_NE: @@ -807,9 +809,10 @@ static void tcg_out_setcond_i64(TCGContext *s, TCGCond cond, TCGReg ret, /* For 64-bit signed comparisons vs zero, we can avoid the compare if the input does not overlap the output. */ - if (c2 == 0 && !is_unsigned_cond(cond) && c1 != ret) { + rcond = tcg_cond_to_rcond[cond]; + if (c2 == 0 && rcond && c1 != ret) { tcg_out_movi_s13(s, ret, 0); - tcg_out_movr(s, cond, ret, c1, neg ? -1 : 1, 1); + tcg_out_movr(s, rcond, ret, c1, neg ? -1 : 1, 1); } else { tcg_out_cmp(s, c1, c2, c2const); tcg_out_movi_s13(s, ret, 0); From patchwork Sun Feb 4 21:40:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769870 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842516wrc; Sun, 4 Feb 2024 13:44:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IE5ytQ8+g5YzdzWoqDU0WYzYgM0cSIKxf+qLNx9EdN/0PTGs726QX4gaHTk9vol0TSmN6Hm X-Received: by 2002:ac8:5f85:0:b0:42b:f6ac:ba3c with SMTP id j5-20020ac85f85000000b0042bf6acba3cmr5002534qta.12.1707083071603; Sun, 04 Feb 2024 13:44:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083071; cv=none; d=google.com; s=arc-20160816; b=PydnWcEkDME4XBN+kfcM36u8lc88tqQ9tryezDAmDN+OSHhv9TlztoqkLHUhjMnxpK 7RmXQvpm05Cg+Ygh1odg+Z/feuznM/ZTCQ/MpoRHpCoEB8cqwpoE8Et6KcW081CIDtrb Edd3o8i9uN7PwOOk07CzaiLpOxPmYVsVAgcKcFKnzzj8RtcZUDVYqLyuUbuTOHQViFCP QyL1TVqQrAhyCFvK7pjDF0STVgQGs3c2so+ZoXk8Euu+tJ315S6eF8x6esXMQ3nS8y7l q7g/speele8IDz9hXUZrEI9gxEtu3Psbvyt6w9udL7viSs7Kw81kMg3Cyqe8WVaKMo7u MXCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XTZQ8U70bvvwDjHMDYUT6Xyjxfqygw11gwaeaagFYFE=; fh=WKnMqj3muLuEGCdY/AA/4YMqVb5r5llQxZth0gxFdcY=; b=S4TNwWxxPDRfM4GD64BGPveMArrV2MoM85U3NfjVk7UjahUhTVG/+wFzxEmFBDj4mz 42oclKYxeCObl00f7m5xpLD3sWsEZRWm8DxbC99W/ziyl1FHKAMhIspTswKY5qDsVjGu ze6AaJNHde0Q+q3NxZJFjZW9MZZHaTFQed2XXqH9NFid0SK9zeUjn/cDh1T9lEIJ5+yV vJxpEjE+mzo6ATS5e63t1GX4xZixQZSXIRx6exLWGGz2f3hhTtL3mxpPUlQfZsIezUC9 0IrwtAX5R+FY4I/fZ65aUwZ0VnqHt2sJ+GvDHJhayjYnNXX+LC+R4QjQ4tN+L7q6x7z2 PanA==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eFNQBVmP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCWh2k+KdKCzhd6IG3YlMPf/W22w5rtpXoP5M30NfMky2OYGF5bYfwkhwm4j1KTnOL6/NlQB3ct7yHbpNmqyFIdV Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n4-20020a05622a11c400b0042c26382d90si753294qtk.161.2024.02.04.13.44.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:44:31 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eFNQBVmP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkFc-0003JQ-4A; Sun, 04 Feb 2024 16:42:08 -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 1rWkFU-0002wD-KW for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:42:02 -0500 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkFS-0003bB-TA for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:42:00 -0500 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-29080973530so3085173a91.1 for ; Sun, 04 Feb 2024 13:41:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082917; x=1707687717; 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=eFNQBVmPbCmOcdijg7KEpSp9IJqNMazEjT1efysaGojWLB8nC4+waa99K29G+B/gj3 YVwi+jM30idKpF/wIfs9NbIE471kuykmoEdviiNh2aJKdVjjWWlGlP+48ewpEk+qKCK0 p6DA1Hjj8e67vsen2I5R9HXJpUSx+DgddwAs5rrpECNKEPU/btJNgdBrS0eC6nfuv/O5 mtgQuPQe0ln8c8yFoL1lrgBTqNVPnvGsbjy0v3/Yz1CUjH0mUdC7veFx8pXU3xLbtmZV pI5og1wJnABCCrZ0KXcHFgAG3WwALCg8p9NrZ5bUuK7BFzUNJRJSghq9EF0RhPOqYU0J Aq8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082917; x=1707687717; 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=Dni18bqNZnbj8V+TBAHz7p+tUq+gFvt3IkOdsgpNw1cu2o7xoQUFl42JAuY7vZxAok f51cMe3Q2M+uE2j5d12zbVRGa0z6t4t9sZdzdsmckdu6K3JW9JqsXnPMjFdLgVj4J5ll Khhde6DwyHtuStbB/M1iW1HqP13DZiGG82+aVVT+tlFkW1ETVfBjwk6rRlKMAs4d9GIT B+V42vgqphXfuAJm4cwWm249mKCQzCROHQrtMjMGy6S3k2aKIXFzD3pdVaZcsnfmLsBf Tx+F7XAg5Vgzcy9DE/s1+z3S+G36l7MTrenvwNi1XLFug8cZCr8qEXjQjs7H4SRa0HY5 tTcg== X-Gm-Message-State: AOJu0Yy85IFXb3B10SBW9ClWO5XyHs3i6s6OxjSzoBNI38bEJZcJSKfp QRGORi6frZWWaakc4+ckfFQ3DUz9YQWx4VpSTzzJGf2kt1D2ErQF3dbY9W3h5ovS7iTYSKftpsa t6bE= X-Received: by 2002:a17:90a:b113:b0:295:b2e5:f907 with SMTP id z19-20020a17090ab11300b00295b2e5f907mr7658721pjq.4.1707082917363; Sun, 04 Feb 2024 13:41:57 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 29/39] tcg/sparc64: Pass TCGCond to tcg_out_cmp Date: Mon, 5 Feb 2024 07:40:42 +1000 Message-Id: <20240204214052.5639-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/sparc64/tcg-target.c.inc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc index e16b25e309..10fb8a1a0d 100644 --- a/tcg/sparc64/tcg-target.c.inc +++ b/tcg/sparc64/tcg-target.c.inc @@ -646,7 +646,8 @@ static void tcg_out_bpcc(TCGContext *s, int scond, int flags, TCGLabel *l) tcg_out_bpcc0(s, scond, flags, off19); } -static void tcg_out_cmp(TCGContext *s, TCGReg c1, int32_t c2, int c2const) +static void tcg_out_cmp(TCGContext *s, TCGCond cond, + TCGReg c1, int32_t c2, int c2const) { tcg_out_arithc(s, TCG_REG_G0, c1, c2, c2const, ARITH_SUBCC); } @@ -654,7 +655,7 @@ static void tcg_out_cmp(TCGContext *s, TCGReg c1, int32_t c2, int c2const) static void tcg_out_brcond_i32(TCGContext *s, TCGCond cond, TCGReg arg1, int32_t arg2, int const_arg2, TCGLabel *l) { - tcg_out_cmp(s, arg1, arg2, const_arg2); + tcg_out_cmp(s, cond, arg1, arg2, const_arg2); tcg_out_bpcc(s, tcg_cond_to_bcond[cond], BPCC_ICC | BPCC_PT, l); tcg_out_nop(s); } @@ -671,7 +672,7 @@ static void tcg_out_movcond_i32(TCGContext *s, TCGCond cond, TCGReg ret, TCGReg c1, int32_t c2, int c2const, int32_t v1, int v1const) { - tcg_out_cmp(s, c1, c2, c2const); + tcg_out_cmp(s, cond, c1, c2, c2const); tcg_out_movcc(s, cond, MOVCC_ICC, ret, v1, v1const); } @@ -691,7 +692,7 @@ static void tcg_out_brcond_i64(TCGContext *s, TCGCond cond, TCGReg arg1, tcg_out32(s, INSN_OP(0) | INSN_OP2(3) | BPR_PT | INSN_RS1(arg1) | INSN_COND(rcond) | off16); } else { - tcg_out_cmp(s, arg1, arg2, const_arg2); + tcg_out_cmp(s, cond, arg1, arg2, const_arg2); tcg_out_bpcc(s, tcg_cond_to_bcond[cond], BPCC_XCC | BPCC_PT, l); } tcg_out_nop(s); @@ -715,7 +716,7 @@ static void tcg_out_movcond_i64(TCGContext *s, TCGCond cond, TCGReg ret, if (c2 == 0 && rcond && (!v1const || check_fit_i32(v1, 10))) { tcg_out_movr(s, rcond, ret, c1, v1, v1const); } else { - tcg_out_cmp(s, c1, c2, c2const); + tcg_out_cmp(s, cond, c1, c2, c2const); tcg_out_movcc(s, cond, MOVCC_XCC, ret, v1, v1const); } } @@ -759,13 +760,13 @@ static void tcg_out_setcond_i32(TCGContext *s, TCGCond cond, TCGReg ret, /* FALLTHRU */ default: - tcg_out_cmp(s, c1, c2, c2const); + tcg_out_cmp(s, cond, c1, c2, c2const); tcg_out_movi_s13(s, ret, 0); tcg_out_movcc(s, cond, MOVCC_ICC, ret, neg ? -1 : 1, 1); return; } - tcg_out_cmp(s, c1, c2, c2const); + tcg_out_cmp(s, cond, c1, c2, c2const); if (cond == TCG_COND_LTU) { if (neg) { /* 0 - 0 - C = -C = (C ? -1 : 0) */ @@ -799,7 +800,7 @@ static void tcg_out_setcond_i64(TCGContext *s, TCGCond cond, TCGReg ret, c2 = c1, c2const = 0, c1 = TCG_REG_G0; /* FALLTHRU */ case TCG_COND_LTU: - tcg_out_cmp(s, c1, c2, c2const); + tcg_out_cmp(s, cond, c1, c2, c2const); tcg_out_arith(s, ret, TCG_REG_G0, TCG_REG_G0, ARITH_ADDXC); return; default: @@ -814,7 +815,7 @@ static void tcg_out_setcond_i64(TCGContext *s, TCGCond cond, TCGReg ret, tcg_out_movi_s13(s, ret, 0); tcg_out_movr(s, rcond, ret, c1, neg ? -1 : 1, 1); } else { - tcg_out_cmp(s, c1, c2, c2const); + tcg_out_cmp(s, cond, c1, c2, c2const); tcg_out_movi_s13(s, ret, 0); tcg_out_movcc(s, cond, MOVCC_XCC, ret, neg ? -1 : 1, 1); } @@ -1102,7 +1103,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h, tcg_out_movi_s32(s, TCG_REG_T3, compare_mask); tcg_out_arith(s, TCG_REG_T3, addr_reg, TCG_REG_T3, ARITH_AND); } - tcg_out_cmp(s, TCG_REG_T2, TCG_REG_T3, 0); + tcg_out_cmp(s, TCG_COND_NE, TCG_REG_T2, TCG_REG_T3, 0); ldst = new_ldst_label(s); ldst->is_ld = is_ld; From patchwork Sun Feb 4 21:40:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769860 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842324wrc; Sun, 4 Feb 2024 13:43:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IHgBiVziqWzOFeKPZbKY2IGCwb1R3Mc/wFm83sm3a7bmz6NiJ/2UfMMuofHPbLP8zjb9UTw X-Received: by 2002:a05:6214:501a:b0:68c:6bbe:eee9 with SMTP id jo26-20020a056214501a00b0068c6bbeeee9mr6672384qvb.28.1707082999931; Sun, 04 Feb 2024 13:43:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707082999; cv=none; d=google.com; s=arc-20160816; b=fsZVPmwMj5P8Y9jgnr5WVaoO4pr+hlTbdLyqFTPAz/OO9OfL0sCxGYlVL6zrKY6/rs ieAJZao7kmdmSLmB2ENy7XhQWGCC3yrlNhQIcqZGhaAIOoycdtv87NUIGOVeKTExjdfm QAMI8WbbZds7Blx4LI65DOUdYGCksJ/dg2hcpI8EDJatmoskDJmcFNGufTeW8Sf56IKm 83u5aRg9WjLQCDkPxzEpcLBH3+QMBXCort44QCSog0EtgOxEpps8LLL38xjaxFKK3he4 5TNndJl08bCFQ4XedY6eD5idmgqHn0oKpva5Dzzw9+ua8NJ4U86HBPXRhzd6WhbBU+d2 fssg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=J7nkcnvR7yCW819cN0Z1TIqZ24aA0LLfk5m6dHETDfI=; fh=dIDU9lKmXio/6yIOi93s4c+1r+8I1R+F2gK+nR1x42I=; b=GzlSybeIoo9zKh6+iZBRch5ojTdj3MzSrj/9XPjZYNnvXhs7vmYJO18hdCcNEOFdqA aWl8td/8tdkNW4TpYCPhrUrg0vKfW+iV0j7tBtlDL355i9WsvZaDUXJXRLphuw8jiL6Y +59pnpQlq6HXLg2mF/T6fTwdC1cejcEdh6ZPY0v2mQwB2T3rdBEqB0O6SuqhxvxWWajH +ftvSbM4S1E/A0BFcInLjTsAx88DPcQ030qa9nurD8qbmoBEhEneN8lgfRF7x+Ixf3Ff R/bww7uzlfl9tO9EwdfPji11WKiDZON57Xlj+ltsQVlBAwlrqha+cdjvaCwcLI4kM310 ig4A==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RTiER2ir; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCU/GZ8vC4CMNMB38UXyRzmQU+QtSqU91Ko42N+uHgAF1R1Q2H/FY4JRehNtKZ4jOh+2cc5dkN2edWeIobFqmp0+ Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g14-20020a0562140ace00b0068c8cfa2d1esi5628618qvi.132.2024.02.04.13.43.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:43:19 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RTiER2ir; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkFb-0003D7-Hc; Sun, 04 Feb 2024 16:42:07 -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 1rWkFW-0002wW-EW for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:42:03 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkFU-0003bK-OU for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:42:02 -0500 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1d746856d85so27600855ad.0 for ; Sun, 04 Feb 2024 13:42:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082919; x=1707687719; 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=RTiER2irWsuhsKh09aV9v3BPpwroJiR/cdyd0RhiVNMxeE4ELCf6lqz8h+y2ONOKLL MlxA/ilCbD5KGP0uxvVMFIE/mscik+PR/sdCjxqWoHCX0DbDhlSZzKVHgbO2fC8m0ujd zxffEkOfz7Db44+yQUR6u0Gh6d6Zbhe1AhVICefbaVeGvZz2cMVdGYcuLEV9hujC+c1w O8a4CaQhCJw2PA/la6FO157EU3jmcuZgnHLOiSGlb2taDk3u9NTlpX8MnzcCzahivrXs ScDxmyXRtDexj+46Q0nhiW6dp4zHSdK5GvGh7M+T74WEISkayl9gpeg8WjKHXpoY0g3C /Jdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082919; x=1707687719; 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=BGSWreQTR8fflKUIgJgPLS7OFOf64/WKgu0sZxda/I5EHMDjNdXNr7GVO9PgcYApL/ q5jcRYWPkUXDgRRAiFAsCPPdY6OzMM4d1XdUUD6kKOcOmAhhdw7plKRqkEX57D8YTVyb U4j0nFJYrOfMOYwTqG7FRJxnyEcO/q1emczsjF1oc+DxW6QIemFFRTZtmVlclr7lhhys 17c55MPb4MZLAG8I13l0dxdU+BjeZrSSasJ8cYXYWVO+I3/tHofyzZpU5M5gMvdELXAR xI2dktX7G4oREo3id1B+KM1qDIl9q113IvhXdqpZ/SG528Sgkwxux7gyUu+QeYqb2NtY fWEQ== X-Gm-Message-State: AOJu0YxKeG7bUdPWxDayIMy9fG1v0Bd4v+oCENF/Mbd/1+Odu7Npilax VvR/+wuzNYfp7HXl5Epxp0cIx2BHkdcjRhiINPORl34Ek3Z9g+nvaAwYIk5LdBoGmhW4U9lTxe6 su5U= X-Received: by 2002:a17:903:11d2:b0:1d9:451e:4365 with SMTP id q18-20020a17090311d200b001d9451e4365mr9577996plh.48.1707082919369; Sun, 04 Feb 2024 13:41:59 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:41:59 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 30/39] tcg/sparc64: Support TCG_COND_TST{EQ,NE} Date: Mon, 5 Feb 2024 07:40:43 +1000 Message-Id: <20240204214052.5639-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/sparc64/tcg-target.h | 2 +- tcg/sparc64/tcg-target.c.inc | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tcg/sparc64/tcg-target.h b/tcg/sparc64/tcg-target.h index ae2910c4ee..a18906a14e 100644 --- a/tcg/sparc64/tcg-target.h +++ b/tcg/sparc64/tcg-target.h @@ -149,7 +149,7 @@ extern bool use_vis3_instructions; #define TCG_TARGET_HAS_qemu_ldst_i128 0 -#define TCG_TARGET_HAS_tst 0 +#define TCG_TARGET_HAS_tst 1 #define TCG_AREG0 TCG_REG_I0 diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc index 10fb8a1a0d..176c98740b 100644 --- a/tcg/sparc64/tcg-target.c.inc +++ b/tcg/sparc64/tcg-target.c.inc @@ -607,9 +607,11 @@ static void tcg_out_div32(TCGContext *s, TCGReg rd, TCGReg rs1, uns ? ARITH_UDIV : ARITH_SDIV); } -static const uint8_t tcg_cond_to_bcond[] = { +static const uint8_t tcg_cond_to_bcond[16] = { [TCG_COND_EQ] = COND_E, [TCG_COND_NE] = COND_NE, + [TCG_COND_TSTEQ] = COND_E, + [TCG_COND_TSTNE] = COND_NE, [TCG_COND_LT] = COND_L, [TCG_COND_GE] = COND_GE, [TCG_COND_LE] = COND_LE, @@ -649,7 +651,8 @@ static void tcg_out_bpcc(TCGContext *s, int scond, int flags, TCGLabel *l) static void tcg_out_cmp(TCGContext *s, TCGCond cond, TCGReg c1, int32_t c2, int c2const) { - tcg_out_arithc(s, TCG_REG_G0, c1, c2, c2const, ARITH_SUBCC); + tcg_out_arithc(s, TCG_REG_G0, c1, c2, c2const, + is_tst_cond(cond) ? ARITH_ANDCC : ARITH_SUBCC); } static void tcg_out_brcond_i32(TCGContext *s, TCGCond cond, TCGReg arg1, @@ -744,6 +747,15 @@ static void tcg_out_setcond_i32(TCGContext *s, TCGCond cond, TCGReg ret, cond = (cond == TCG_COND_EQ ? TCG_COND_GEU : TCG_COND_LTU); break; + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + /* Transform to inequality vs zero. */ + tcg_out_arithc(s, TCG_REG_T1, c1, c2, c2const, ARITH_AND); + c1 = TCG_REG_G0; + c2 = TCG_REG_T1, c2const = 0; + cond = (cond == TCG_COND_TSTEQ ? TCG_COND_GEU : TCG_COND_LTU); + break; + case TCG_COND_GTU: case TCG_COND_LEU: /* If we don't need to load a constant into a register, we can From patchwork Sun Feb 4 21:40:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769869 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842504wrc; Sun, 4 Feb 2024 13:44:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IGMuXimpcX7++CdDBGMj2kPpP66hGRORmTOUjxCpWhT6559cs2B79PAn7EhpHx1hn+UGVPj X-Received: by 2002:ac8:734c:0:b0:42c:25fd:de75 with SMTP id q12-20020ac8734c000000b0042c25fdde75mr831574qtp.6.1707083066424; Sun, 04 Feb 2024 13:44:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083066; cv=none; d=google.com; s=arc-20160816; b=BTcBeb9Z+d0+Yltm6qgPriKgVgyO6kZE+uWh/KkbLHck9v60V59N9O210B780LsseF F8ET3CMmLjkI41j2soH/a+BcB5tYwogn75miREF9aOuIbv+iOKhq+yVoARQ1qAy8hsq3 Kw7SLU8P4J46F/kP0FklraYprs9mvmuzP+cEJ1NisBIX7Nn2wGbgTBofPrsiZn060ise Slty21XtyaL+tVTbxsom0MH92xdzXo25wXXU8bGTBaSnvVmMd+Z3WcyWwkRoPw+aEdlY JaxNdiaRvSqWpLLurbnw5WSGIB8Y8zKY0qGUBzOimoM2pX+1BEwAfaC7DTAQ23nPrtJf XtJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Njou8078FZIGaih/KmoVshAEm+KpvJ/TDJRnizv9npg=; fh=5Kgtv+1nOJLLru0DjBfvvgEeQbDKOIA590cjYXTkdhA=; b=AHnrCQQf+tYqsG6z/KhN994Gt3stjJQhiBlATi4zAWqRY40ksLfTkao6pYsXMRwfrD agGtkAnL6Y6vsAmVzSfhJjatGHhFIWU6ula0DYBXr02zCx/3j+Vy/N5RCDtfGDw0Laxd MYsABXBVKQE6aWZEP2BMifRszkNbd54ZglE4OwH7R6UTbo0WaJxt9lZzLuLV39u23FUC cJOnzYkvhN1MpNeHh8xEfwu8Lh8tgUss1YLVYWAbzdoH0qtJA01QeyaLb6ELyNV25F0e 2ZtYKQmtiUJY5fjLOUoLEs79xL3mREcTGs7AIp/w+piJubEJMQOrENRBKag6Is8YCGs3 gD4A==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mGOBDGLk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCXkq47yZYEBFFLIJ4vSkely9IsPQeX9105HVhaO34rHmTp3opR61omqm8wbMe8l1yqi3N3vY6a8sXCXShtNybGO Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bp31-20020a05622a1b9f00b0042a99face24si7133749qtb.795.2024.02.04.13.44.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:44:26 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mGOBDGLk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkFd-0003On-0W; Sun, 04 Feb 2024 16:42:09 -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 1rWkFY-00035R-Qo for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:42:06 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkFW-0003bW-Lo for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:42:04 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1d94323d547so29787715ad.3 for ; Sun, 04 Feb 2024 13:42:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082921; x=1707687721; 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=mGOBDGLka1XKGdc3MJgsMNDRaFXaVQxBL6kfRdYeD8Rtdks5aGeoLiKU0Vo/s7dik6 noq5ZPVlH7uATwV3RoTUTH7AkHJHQgL1uRU/vQuzOQIBClgIXfI/KYLJl8x1QmQYyTXo qoKs/66Qlb2T2weeoSRtJ2t0lUkVMRPr7uHcI7D+C+jyXK+U8H84LzyqhtfEoyRxR1R9 gGQQR4AQRP7nyGKkvUDJvi9ekYShUvEgzzMGFJvXnx9ZIiNEqMAThPCHNeNrqBoLYKWy 9aPOzG8GX+Yq+arP8CKw7j2CRTbTNlyYcDEacNOlimAQO5mgol3V66rh4sLrBedCtNOe snjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082921; x=1707687721; 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=uN3WHiwxJA0npAhF1u5oTkcCGiLj2wEDI/48RsQkMu2sB9BR1c6U6+QB7lJ6TWLNML /AmyJd7rvtXZM5bMZ7XrNE3+IBhtqlJVOtxdvVSPN4DFh5++g/6QoLCCICUyqnu1RC9g 0yOfj6enYZLWHrPcNNM3CiC2grlzsjWAnVjyn4AgFNLeX0AdFphm07bZ13/xdwvuwJym dMN8bw9WUBThMNkIvgLVOuEybZ1cAOQsxVVsPLvS2QZXV7l97M4xMZKoIRT96XheTZij RSXvcuumkbWm4Jf+LVnuvbTTh/H1ma5QRklmqyunJuhRRZsVF2PtMLVNsfuGkgMmhAbu BNuQ== X-Gm-Message-State: AOJu0YylKk8kQh/j2K/ozq6Ty26Q8GKgdcqCHvQyD3AN3ZrwLacIwJGI +ptw5cIx2VVawmYXyramCqDmpVKuXfQVUlnrqvY5Ky6pJ2jk/CmRh2WOKCQO/gm0TQ0IvXRIC3I F2+k= X-Received: by 2002:a17:902:f545:b0:1d9:a674:aa77 with SMTP id h5-20020a170902f54500b001d9a674aa77mr1951226plf.24.1707082921409; Sun, 04 Feb 2024 13:42:01 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:42:01 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 31/39] tcg/ppc: Sink tcg_to_bc usage into tcg_out_bc Date: Mon, 5 Feb 2024 07:40:44 +1000 Message-Id: <20240204214052.5639-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Rename the current tcg_out_bc function to tcg_out_bc_lab, and create a new function that takes an integer displacement + link. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 850ace98b2..830d2fe73a 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -1946,14 +1946,20 @@ static void tcg_out_setcond(TCGContext *s, TCGType type, TCGCond cond, } } -static void tcg_out_bc(TCGContext *s, int bc, TCGLabel *l) +static void tcg_out_bc(TCGContext *s, TCGCond cond, int bd) { + tcg_out32(s, tcg_to_bc[cond] | bd); +} + +static void tcg_out_bc_lab(TCGContext *s, TCGCond cond, TCGLabel *l) +{ + int bd = 0; if (l->has_value) { - bc |= reloc_pc14_val(tcg_splitwx_to_rx(s->code_ptr), l->u.value_ptr); + bd = reloc_pc14_val(tcg_splitwx_to_rx(s->code_ptr), l->u.value_ptr); } else { tcg_out_reloc(s, s->code_ptr, R_PPC_REL14, l, 0); } - tcg_out32(s, bc); + tcg_out_bc(s, cond, bd); } static void tcg_out_brcond(TCGContext *s, TCGCond cond, @@ -1961,7 +1967,7 @@ static void tcg_out_brcond(TCGContext *s, TCGCond cond, TCGLabel *l, TCGType type) { tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 7, type); - tcg_out_bc(s, tcg_to_bc[cond], l); + tcg_out_bc_lab(s, cond, l); } static void tcg_out_movcond(TCGContext *s, TCGType type, TCGCond cond, @@ -2003,7 +2009,7 @@ static void tcg_out_movcond(TCGContext *s, TCGType type, TCGCond cond, } } /* Branch forward over one insn */ - tcg_out32(s, tcg_to_bc[cond] | 8); + tcg_out_bc(s, cond, 8); if (v2 == 0) { tcg_out_movi(s, type, dest, 0); } else { @@ -2024,11 +2030,11 @@ static void tcg_out_cntxz(TCGContext *s, TCGType type, uint32_t opc, tcg_out32(s, opc | RA(TCG_REG_R0) | RS(a1)); tcg_out32(s, tcg_to_isel[TCG_COND_EQ] | TAB(a0, a2, TCG_REG_R0)); } else if (!const_a2 && a0 == a2) { - tcg_out32(s, tcg_to_bc[TCG_COND_EQ] | 8); + tcg_out_bc(s, TCG_COND_EQ, 8); tcg_out32(s, opc | RA(a0) | RS(a1)); } else { tcg_out32(s, opc | RA(a0) | RS(a1)); - tcg_out32(s, tcg_to_bc[TCG_COND_NE] | 8); + tcg_out_bc(s, TCG_COND_NE, 8); if (const_a2) { tcg_out_movi(s, type, a0, 0); } else { @@ -2108,11 +2114,11 @@ static void tcg_out_setcond2(TCGContext *s, const TCGArg *args, tcg_out_rlw(s, RLWINM, args[0], TCG_REG_R0, 31, 31, 31); } -static void tcg_out_brcond2 (TCGContext *s, const TCGArg *args, - const int *const_args) +static void tcg_out_brcond2(TCGContext *s, const TCGArg *args, + const int *const_args) { tcg_out_cmp2(s, args, const_args); - tcg_out_bc(s, BC | BI(7, CR_EQ) | BO_COND_TRUE, arg_label(args[5])); + tcg_out_bc_lab(s, TCG_COND_EQ, arg_label(args[5])); } static void tcg_out_mb(TCGContext *s, TCGArg a0) @@ -2446,7 +2452,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h, /* Load a pointer into the current opcode w/conditional branch-link. */ ldst->label_ptr[0] = s->code_ptr; - tcg_out32(s, BC | BI(7, CR_EQ) | BO_COND_FALSE | LK); + tcg_out_bc(s, TCG_COND_NE, LK); h->base = TCG_REG_TMP1; } else { From patchwork Sun Feb 4 21:40:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769873 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842586wrc; Sun, 4 Feb 2024 13:44:52 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUCSWZIQsHH8OBccT7llYYsqKbVVPa6Evvbrea2gu+ZxKqgGvzB4Uz443U8TP9XxOpucx54SRLAU1NumwfzRhgG X-Google-Smtp-Source: AGHT+IEJc1w373xskzJd/tDtLMMVkUvgUCTLQV2dQUGU5iecyaqzrQbuPqNzqPCLQxUP1urE9DmI X-Received: by 2002:ac8:668b:0:b0:42a:b844:2630 with SMTP id d11-20020ac8668b000000b0042ab8442630mr5257350qtp.13.1707083092500; Sun, 04 Feb 2024 13:44:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083092; cv=none; d=google.com; s=arc-20160816; b=oXUqT3TzwFcajbSq3Qzur8Tu8TlkUhyTvqwAMjNoKhYTvuRWRlR50vCpP5H1TybmaI M4uPJg5fUNOTr8T/q9NzPhT3ca2976EiJ895eKggi+vCOLeEXDToQ5LuWB0X3stlQQjX aMRX2JCThEr4JLcxW1IUgMznrKhY74CaKvJrJBwJplPA9jlgknLZ5UO257wXbhkGWHNZ 3xi9/ZpgvNJqY9vmh513vrx7JoZ2J1d8UDlAlxAQmmr6o/9bBDW7lQLecIwLVjPuypoE B7yvpvYE5q+H66h4RgHHAPUGvEnl7pYrmOa0UsKADM+8BQOJJzv97DcKSj7BvwyaDzyd j5yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fgCYLBH8uYmmefd9XnbslI9mkFGYtv19hEE6tS0wKb8=; fh=gRaXEP68m/lerCmhGgNscjahA3T+KO/a3j8A0mOsYEI=; b=T/MnsxtYTA7GGBFmwTwX2F6EBiBfJi471l0gnemcqrxzAleLE6Dy45f8s9O9cvOvv6 WSJbqWHCDfp/gcQH0puTjNiK1jtWsr3CCRk7waVTuP3rnb/d8+c+AS/qzhH1NquYvJId bSvEjA0KgDCjWTBr4nW3BZmwY+xTUlSP6ucskMOmfDnBAW1+icyUaXOYAyovb2Cm16lE B/gfHGsLGQWYJEqu37/fsubwHNsajFPYfR5lcJwgtxp2mpkuhB95CfGaF9IpP93U/o4z 2IQG9YaKojbj3UeeghzswDyxjouwdMgpm/B+9MDse/FVj9VeQf2uNKAeOr8ytNT0rCWT M7Nw==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tCZvKOSc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCW/7ZlNOPAEaRP/5GPRalT26JKc+D7COGM3/0FARJ2drsKkbd1Ty/j6TPKziSgGcUwpvZsQYFpTFFOwkfxH8LQB Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m12-20020a05622a054c00b0042ab0368b5csi7082555qtx.714.2024.02.04.13.44.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:44:52 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tCZvKOSc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkFg-0003n2-8Z; Sun, 04 Feb 2024 16:42:12 -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 1rWkFb-00039W-0E for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:42:07 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkFY-0003bp-QA for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:42:06 -0500 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1d93f2c3701so18200935ad.3 for ; Sun, 04 Feb 2024 13:42:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082923; x=1707687723; 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=fgCYLBH8uYmmefd9XnbslI9mkFGYtv19hEE6tS0wKb8=; b=tCZvKOSc6HSbp1LmLrm1SdRzpfhRfqcimvPhd/R3+36n4Bb0ynBh6K37btBW8dozuJ 0EDC5WVvxPy/HCfN8Ml3qJl5g3hW6yYZ7vhAxF3B0OPHmMGjLoxTH27XJAX5gZSqwie8 fh8vOcLIekxC+DFRbZvfDkwVoHAREJLSmBcSjFJ04tyovQgG4+wn56eJzITSiXPea01L vCJif13rae3nqxrUA1aw9vc7X7jLLcsNlmOF1QQM+Lv1rsAIVIypaLgMsY0lO0nOjK3L Y5nCAH9kHisd9zBjO2XqsRQwdwbXCPQq2nv5wWrW/QPNk4LlWRDnSAb2N9gTrLrx3SEw ih1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082923; x=1707687723; 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=fgCYLBH8uYmmefd9XnbslI9mkFGYtv19hEE6tS0wKb8=; b=rlyHqr3QlDv1Wnh/2ReMVQhaYZ9kX2dTSdFj5LtVHO7qwUG9/CDGStpSc/fNKgNPgT m/Be/1RgFAl0iXas4253A8YcyA6qVOc+/ihgYnkGdAevD31JNvJcxYSePNObxDeuAhAv hr/OYnziirS4ZLq45gmVk45NXk5t/Re2Vik1NT5DafsnfQeXvBBWSsbIvcQ0i0SYlwdr yXJA8ZQGx5JriGdIjUSVY1nQak6AidK/6hb2UBKrqzYrIvrndJvo5y2gmDvWMOaOnx/q XtA6srbJHIM+h0qrA7VSrJlIs7UMtBe2ZN754c9MdUiqqkfuYMyhM5BHiUsHMJuBLYJF nBCA== X-Gm-Message-State: AOJu0YyLdvfFxmqzrSDbKozen1Bew1sQdRbC34pLex0zIy7rdmn5bjAA nMMtSVuZzakdWHamNXoetRJl/sRQwj0LUbR7qSCzcoVVm77QQKM8jN3T/vDyJ8NpMqMWRK+EHsM hoQ4= X-Received: by 2002:a17:902:ba98:b0:1d9:620b:89cb with SMTP id k24-20020a170902ba9800b001d9620b89cbmr8309754pls.13.1707082923450; Sun, 04 Feb 2024 13:42:03 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.42.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:42:03 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 32/39] tcg/ppc: Use cr0 in tcg_to_bc and tcg_to_isel Date: Mon, 5 Feb 2024 07:40:45 +1000 Message-Id: <20240204214052.5639-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Using cr0 means we could choose to use rc=1 to compute the condition. Adjust the tables and tcg_out_cmp that feeds them. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 68 ++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 830d2fe73a..b9323baa86 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -671,30 +671,30 @@ enum { }; static const uint32_t tcg_to_bc[] = { - [TCG_COND_EQ] = BC | BI(7, CR_EQ) | BO_COND_TRUE, - [TCG_COND_NE] = BC | BI(7, CR_EQ) | BO_COND_FALSE, - [TCG_COND_LT] = BC | BI(7, CR_LT) | BO_COND_TRUE, - [TCG_COND_GE] = BC | BI(7, CR_LT) | BO_COND_FALSE, - [TCG_COND_LE] = BC | BI(7, CR_GT) | BO_COND_FALSE, - [TCG_COND_GT] = BC | BI(7, CR_GT) | BO_COND_TRUE, - [TCG_COND_LTU] = BC | BI(7, CR_LT) | BO_COND_TRUE, - [TCG_COND_GEU] = BC | BI(7, CR_LT) | BO_COND_FALSE, - [TCG_COND_LEU] = BC | BI(7, CR_GT) | BO_COND_FALSE, - [TCG_COND_GTU] = BC | BI(7, CR_GT) | BO_COND_TRUE, + [TCG_COND_EQ] = BC | BI(0, CR_EQ) | BO_COND_TRUE, + [TCG_COND_NE] = BC | BI(0, CR_EQ) | BO_COND_FALSE, + [TCG_COND_LT] = BC | BI(0, CR_LT) | BO_COND_TRUE, + [TCG_COND_GE] = BC | BI(0, CR_LT) | BO_COND_FALSE, + [TCG_COND_LE] = BC | BI(0, CR_GT) | BO_COND_FALSE, + [TCG_COND_GT] = BC | BI(0, CR_GT) | BO_COND_TRUE, + [TCG_COND_LTU] = BC | BI(0, CR_LT) | BO_COND_TRUE, + [TCG_COND_GEU] = BC | BI(0, CR_LT) | BO_COND_FALSE, + [TCG_COND_LEU] = BC | BI(0, CR_GT) | BO_COND_FALSE, + [TCG_COND_GTU] = BC | BI(0, CR_GT) | BO_COND_TRUE, }; /* The low bit here is set if the RA and RB fields must be inverted. */ static const uint32_t tcg_to_isel[] = { - [TCG_COND_EQ] = ISEL | BC_(7, CR_EQ), - [TCG_COND_NE] = ISEL | BC_(7, CR_EQ) | 1, - [TCG_COND_LT] = ISEL | BC_(7, CR_LT), - [TCG_COND_GE] = ISEL | BC_(7, CR_LT) | 1, - [TCG_COND_LE] = ISEL | BC_(7, CR_GT) | 1, - [TCG_COND_GT] = ISEL | BC_(7, CR_GT), - [TCG_COND_LTU] = ISEL | BC_(7, CR_LT), - [TCG_COND_GEU] = ISEL | BC_(7, CR_LT) | 1, - [TCG_COND_LEU] = ISEL | BC_(7, CR_GT) | 1, - [TCG_COND_GTU] = ISEL | BC_(7, CR_GT), + [TCG_COND_EQ] = ISEL | BC_(0, CR_EQ), + [TCG_COND_NE] = ISEL | BC_(0, CR_EQ) | 1, + [TCG_COND_LT] = ISEL | BC_(0, CR_LT), + [TCG_COND_GE] = ISEL | BC_(0, CR_LT) | 1, + [TCG_COND_LE] = ISEL | BC_(0, CR_GT) | 1, + [TCG_COND_GT] = ISEL | BC_(0, CR_GT), + [TCG_COND_LTU] = ISEL | BC_(0, CR_LT), + [TCG_COND_GEU] = ISEL | BC_(0, CR_LT) | 1, + [TCG_COND_LEU] = ISEL | BC_(0, CR_GT) | 1, + [TCG_COND_GTU] = ISEL | BC_(0, CR_GT), }; static bool patch_reloc(tcg_insn_unit *code_ptr, int type, @@ -1827,7 +1827,7 @@ static void tcg_out_setcond(TCGContext *s, TCGType type, TCGCond cond, if (have_isa_3_10) { tcg_insn_unit bi, opc; - tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 7, type); + tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 0, type); /* Re-use tcg_to_bc for BI and BO_COND_{TRUE,FALSE}. */ bi = tcg_to_bc[cond] & (0x1f << 16); @@ -1880,7 +1880,7 @@ static void tcg_out_setcond(TCGContext *s, TCGType type, TCGCond cond, if (have_isel) { int isel, tab; - tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 7, type); + tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 0, type); isel = tcg_to_isel[cond]; @@ -1966,7 +1966,7 @@ static void tcg_out_brcond(TCGContext *s, TCGCond cond, TCGArg arg1, TCGArg arg2, int const_arg2, TCGLabel *l, TCGType type) { - tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 7, type); + tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 0, type); tcg_out_bc_lab(s, cond, l); } @@ -1980,7 +1980,7 @@ static void tcg_out_movcond(TCGContext *s, TCGType type, TCGCond cond, return; } - tcg_out_cmp(s, cond, c1, c2, const_c2, 7, type); + tcg_out_cmp(s, cond, c1, c2, const_c2, 0, type); if (have_isel) { int isel = tcg_to_isel[cond]; @@ -2024,7 +2024,7 @@ static void tcg_out_cntxz(TCGContext *s, TCGType type, uint32_t opc, if (const_a2 && a2 == (type == TCG_TYPE_I32 ? 32 : 64)) { tcg_out32(s, opc | RA(a0) | RS(a1)); } else { - tcg_out_cmp(s, TCG_COND_EQ, a1, 0, 1, 7, type); + tcg_out_cmp(s, TCG_COND_EQ, a1, 0, 1, 0, type); /* Note that the only other valid constant for a2 is 0. */ if (have_isel) { tcg_out32(s, opc | RA(TCG_REG_R0) | RS(a1)); @@ -2079,7 +2079,7 @@ static void tcg_out_cmp2(TCGContext *s, const TCGArg *args, do_equality: tcg_out_cmp(s, cond, al, bl, blconst, 6, TCG_TYPE_I32); tcg_out_cmp(s, cond, ah, bh, bhconst, 7, TCG_TYPE_I32); - tcg_out32(s, op | BT(7, CR_EQ) | BA(6, CR_EQ) | BB(7, CR_EQ)); + tcg_out32(s, op | BT(0, CR_EQ) | BA(6, CR_EQ) | BB(7, CR_EQ)); break; case TCG_COND_LT: @@ -2097,8 +2097,8 @@ static void tcg_out_cmp2(TCGContext *s, const TCGArg *args, tcg_out_cmp(s, cond, ah, bh, bhconst, 6, TCG_TYPE_I32); tcg_out_cmp(s, cond2, al, bl, blconst, 7, TCG_TYPE_I32); - tcg_out32(s, op | BT(7, CR_EQ) | BA(6, CR_EQ) | BB(7, bit2)); - tcg_out32(s, CROR | BT(7, CR_EQ) | BA(6, bit1) | BB(7, CR_EQ)); + tcg_out32(s, op | BT(0, CR_EQ) | BA(6, CR_EQ) | BB(7, bit2)); + tcg_out32(s, CROR | BT(0, CR_EQ) | BA(6, bit1) | BB(0, CR_EQ)); break; default: @@ -2110,8 +2110,8 @@ static void tcg_out_setcond2(TCGContext *s, const TCGArg *args, const int *const_args) { tcg_out_cmp2(s, args + 1, const_args + 1); - tcg_out32(s, MFOCRF | RT(TCG_REG_R0) | FXM(7)); - tcg_out_rlw(s, RLWINM, args[0], TCG_REG_R0, 31, 31, 31); + tcg_out32(s, MFOCRF | RT(TCG_REG_R0) | FXM(0)); + tcg_out_rlw(s, RLWINM, args[0], TCG_REG_R0, CR_EQ + 0*4 + 1, 31, 31); } static void tcg_out_brcond2(TCGContext *s, const TCGArg *args, @@ -2442,12 +2442,12 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h, tcg_out_cmp(s, TCG_COND_EQ, addrhi, TCG_REG_TMP2, 0, 6, TCG_TYPE_I32); - /* Combine comparisons into cr7. */ - tcg_out32(s, CRAND | BT(7, CR_EQ) | BA(6, CR_EQ) | BB(7, CR_EQ)); + /* Combine comparisons into cr0. */ + tcg_out32(s, CRAND | BT(0, CR_EQ) | BA(6, CR_EQ) | BB(7, CR_EQ)); } else { - /* Full comparison into cr7. */ + /* Full comparison into cr0. */ tcg_out_cmp(s, TCG_COND_EQ, TCG_REG_R0, TCG_REG_TMP2, - 0, 7, addr_type); + 0, 0, addr_type); } /* Load a pointer into the current opcode w/conditional branch-link. */ From patchwork Sun Feb 4 21:40:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769874 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842594wrc; Sun, 4 Feb 2024 13:44:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IES/Gbv8XGAMUGfdIC8EU/Oqkp39yX9/tiAaoOdjkTkT/4ZeQpwMuxRCD8QQk29FmTAwf66 X-Received: by 2002:a05:622a:44c1:b0:42b:f088:14ce with SMTP id kc1-20020a05622a44c100b0042bf08814cemr4261348qtb.10.1707083095869; Sun, 04 Feb 2024 13:44:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083095; cv=none; d=google.com; s=arc-20160816; b=lEQfsW5yFkPgUtlADjm9uzPloBMcV9Vh1WBr3O1wTXcCljzokkHq1EyOQ6iDxWyeZo G6oyKAlY7h3esfFkUpLR76A9dzpKAoRzRf/j6zKS0Po1HCzGpuY489OEMFpLGx44gadw gBzUOKCEw6894o1iHMXs6UscoibNa/4DgQNSmm055NCbB9e6c8PUZjJA7zH4GE30DwIH +/0Xa/tRx6AeyhvpkN2ExpJFBrEfAHueKsVr3Hu4FzE20Mhf3bCU/NtqTcJbM3ET96oR +TAeu+jtqShcgKvow7th1mACgKTq3gqy4S/lK7zr2+N6cEaqoAIUZ7Wzr2u9aAWaBcka mIVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=l6wrsnSxRLOGGrrUU+5wUcOLIX0LsFSMqYGfjSPgVvg=; fh=V+isznNp1lO20/P+dO5fekqCsUHwX5iZ7KbPSPNLd8c=; b=Qh9tPpBkV5JCRCe6L0O9OLwyriDspbw11dS64roD2Ia6r2bkfFojrIVuHqTSSvUvCP IIL3olx/oiaF/+fd2M5oeDJPsmJ07CHnWb6802DGCB7Kk9NqyIxnLswEGaX27ebwBcRO 1XeMzl41twHXQQCQj35DUxBstQiSUAuq+RUHorDDZronSpdF791uuyKu1GO+jF7O/7Q+ kv3KqlmnUxcVFYjRWeyP+Mb29I4DEPeCZIYDcQoLiXg2A176nafAhGDHaeg3ulh5f9rQ e9naTw4SXW7JqfRT+9fQVyc8a6i0UnjHoJe1ikpJ8Bt5bYqd9rbM3ZFzyI/za7n88iQe XVPg==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T7trv3q4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCVxwYbOrxgn2PFQI7HPcPHt1lQ1gO8l5700NprS8GhbXIPrO26B/u7iJi3O9reJ+pTPkTiVazOzmBtLoCc3tCvU Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w11-20020ac857cb000000b0042c25feb7d8si831123qta.684.2024.02.04.13.44.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:44:55 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T7trv3q4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkFg-0003rv-LJ; Sun, 04 Feb 2024 16:42:12 -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 1rWkFc-0003Mg-Jf for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:42:08 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkFa-0003c8-TC for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:42:08 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1d51ba18e1bso35016875ad.0 for ; Sun, 04 Feb 2024 13:42:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082925; x=1707687725; 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=T7trv3q4VThoYjamj095ZkBsvmbVtTpuq9Cxv/TrAz8uOeBbN/E1bxixc+HvYfsArN AtctJrYFTYoy+ytlxqcr1416mvplLZoeYsAtCrxNH8/LavIhUeCroMZPp/lcNrS5uCBK mXLg74ExfL317bQj2OEflw9drz8byzpDW6AifjxiRFYES2Cyw7opsFuQLseQJXu5+5Kt COSSGbAtlM7bqkwCBlrsNcTQfPg94Ro6NyXiuEOtBxSXP1aB2d6pDKPTE1vtYVZ1lDLR jZqAHWY0L0Zkfiz+4p9GjRHth3CZ9xH4cZenjyW1xjsXTi4376woVPLMOJoptUpj8iUM GsKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082925; x=1707687725; 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=wclF0gU2TPbzyBfL8A5dI87JItCrIh4zLECjv9gSzw5MXTIwnlSHpx/shqQDDSGpPa MDIp4gG1/Sr5fR0+TtxRmZTpIMWjvmgNTCxt1kO1rQ3XapWtPbO+ClLXlkMId05GiRsR ueFCnIzJDNZ5IUxsPPIOarA6PJs8adV8mZr+MXZGWfY3qozZf9D0KNgdkCQAJNtGLx3d la/z1xOIiJ4lraeg49lAwgEe1A35U8aQl3GkCTLQXS237B7eaW6lB1F2ObYNW8N9G9Yt KrWl4fQQsME3iLoo6Ied/HMYcTM86asCAvrB+n6Oy3lRf2NYTaasgr1RRdw06FeruWSu Mrpg== X-Gm-Message-State: AOJu0YxSDgPUKcAk0KoRqIjli9dgDTlU1D3ASrFKRxqpU/PwlVd+ziAh HQGidCAx75440Cw/wMbY5tZd8HdbUqvJwzNbFsLzBInsvkUwEsnKyUw1C3leXSKiDa1aQnp2zhG LNow= X-Received: by 2002:a17:902:b190:b0:1d8:da2c:1014 with SMTP id s16-20020a170902b19000b001d8da2c1014mr8687954plr.9.1707082925513; Sun, 04 Feb 2024 13:42:05 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.42.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:42:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 33/39] tcg/ppc: Tidy up tcg_target_const_match Date: Mon, 5 Feb 2024 07:40:46 +1000 Message-Id: <20240204214052.5639-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index b9323baa86..26e0bc31d7 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -282,31 +282,36 @@ static bool reloc_pc34(tcg_insn_unit *src_rw, const tcg_insn_unit *target) } /* test if a constant matches the constraint */ -static bool tcg_target_const_match(int64_t val, int ct, +static bool tcg_target_const_match(int64_t sval, int ct, TCGType type, TCGCond cond, int vece) { + uint64_t uval = sval; + if (ct & TCG_CT_CONST) { return 1; } - /* The only 32-bit constraint we use aside from - TCG_CT_CONST is TCG_CT_CONST_S16. */ if (type == TCG_TYPE_I32) { - val = (int32_t)val; + uval = (uint32_t)sval; + sval = (int32_t)sval; } - if ((ct & TCG_CT_CONST_S16) && val == (int16_t)val) { + if ((ct & TCG_CT_CONST_S16) && sval == (int16_t)sval) { return 1; - } else if ((ct & TCG_CT_CONST_S32) && val == (int32_t)val) { + } + if ((ct & TCG_CT_CONST_S32) && sval == (int32_t)sval) { return 1; - } else if ((ct & TCG_CT_CONST_U32) && val == (uint32_t)val) { + } + if ((ct & TCG_CT_CONST_U32) && uval == (uint32_t)uval) { return 1; - } else if ((ct & TCG_CT_CONST_ZERO) && val == 0) { + } + if ((ct & TCG_CT_CONST_ZERO) && sval == 0) { return 1; - } else if ((ct & TCG_CT_CONST_MONE) && val == -1) { + } + if ((ct & TCG_CT_CONST_MONE) && sval == -1) { return 1; - } else if ((ct & TCG_CT_CONST_WSZ) - && val == (type == TCG_TYPE_I32 ? 32 : 64)) { + } + if ((ct & TCG_CT_CONST_WSZ) && sval == (type == TCG_TYPE_I32 ? 32 : 64)) { return 1; } return 0; From patchwork Sun Feb 4 21:40:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769879 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842814wrc; Sun, 4 Feb 2024 13:46:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IEtkByvgL+8P83/Qz8gb0y7jW8ZxGkizkws2JGIt4yGpJocOhaRlvRyWA+4jYSDX/g9z7ad X-Received: by 2002:a05:622a:309:b0:42c:2812:e848 with SMTP id q9-20020a05622a030900b0042c2812e848mr375134qtw.32.1707083166938; Sun, 04 Feb 2024 13:46:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083166; cv=none; d=google.com; s=arc-20160816; b=04OAMaUmVbLHoi2PeZuU8V7c4cyrAzowQ1Ng1e6A9K7+v0OLPvrQlCaMuhO3d2wZ+E t7dBs3jOcb1MdMhKMWECV+8nwVgKhqjWzVnAPeGB797bQbdoRdEMGa+vYH8fXZxSmotR DNkQeBB89YE8HRLBZmIqlgz5Egw6FrqEagE6oDMaZMzmlAXSDGgFCpE6CFXecR32QxOn 1UusWhyJHnlWu8OkZk9AQOXuARaYGg83YPjK1pV2hPEzdehwOSxbqmQ6oWok0CamUGog 6ZrNV/LSN951VgmHZeTfjfJpgA9mJc0XswPtvStmwuwIdSI0e22DaRdqyM4IxUe9La45 n3+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gLa7bF3d+J5rLIIpPnV3sWbEmYd7i3gQY65q07Ip5VY=; fh=fSR4n2RhJNgcfvnG+38s6L9sXFNCrwArFAC3k4phe0M=; b=vPQ5UVIoVE7V9NWnkNld4zMxGNIhiKfYHfO8Pl/Y4ATWcC54x0NAc0cB3VlIQRSfDx OsiImrMhMo0z1hDmORvzYarqb1MLS68lagQW1kkTRrr7uKGeY+38pXLrVuKD534YdsjU c2hNKD9YNeZVM2aMz0O2md/QQSxmlKzHu4hWItb4uW0mgqXaHpVHqWhIeV37YodUSlD3 ZPUIoFub4pDOPRS+IkC8H1tyBPiR6l+57iM4qu4JrBOsfRS06l4kI1pDM78Da/yf/QaH hAbGPS7EU39gzoBPYJcXiagpkXhtwnpDamuuaKlahYlUGBuGevd4gCviig5ODaMFRCRQ f7EQ==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="homsk3I/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCXskhhARIo91oYV/C+IMzqicd9Se8wV+eNzjqky0xx3wAZL5q5ODqpS72nQ7Jn2FW+RCC1sR8OXY7ru9gZxu7YA Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f8-20020a05622a104800b0042ae384231dsi7420843qte.334.2024.02.04.13.46.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:46:06 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="homsk3I/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkFh-00041V-W0; Sun, 04 Feb 2024 16:42: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 1rWkFe-0003ev-MJ for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:42:10 -0500 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkFc-0003cQ-QN for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:42:10 -0500 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1d93ddd76adso27171915ad.2 for ; Sun, 04 Feb 2024 13:42:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082927; x=1707687727; 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=gLa7bF3d+J5rLIIpPnV3sWbEmYd7i3gQY65q07Ip5VY=; b=homsk3I/hZRNShqn/JxyG6c+iDbyV+69rltbvWXTFElTEbobYXW0Xqxa1RXQI7vJOb nup76YDL0QsLncK/83bCVsXYMJTTlG0Dls0fpIG5l1ieoIF7EeFugaHSMdH1fdRxKx+e 3CCzaUihWmjjYLNUpfsJhSpA6Y+Nfw8T/6kqvC0f4BPk0qIM0tVuVkFBK6b0OPglr5sO 2trwbKmPc+wkwhqT9PULTVllzTSB8zQppJh+UIzP1zhA8kN8g+NIZKXS8OZ0TNFf0CIA BWhGU3Lwh3sY+5DPNSKkQxbQ28JAI/cpkfRZC6qPQbHSIA0fxGwi2vf3QKtDLSYIIe9e 9D0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082927; x=1707687727; 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=gLa7bF3d+J5rLIIpPnV3sWbEmYd7i3gQY65q07Ip5VY=; b=bcwUw2t8ME4S6c9FhUUfEAKPrvApnnrnKNcwU/HKPlk1uKQ0cGbu85f7Y6zfDZFJOr RN34d5v2VUjStSIbhucxJg1FEr3Nf9QTTJDoHNPpHNSIARz4D3Zq1gfpCysLWFN04x2I McgvXnpqT2vnqAxdd5KC6Wwqt3Oj0azfNpOVlBB3faS2SdXyfEHSai3xQl+ueU6pCQ2g LUJPHX9vzFh/b918EEEWYmOel0YYRW4VFpvDzLdCsyLsWjGiz0owrTKYMPd0QfdetLx3 kJO0/EhLwcAoqbvxI9aalKCgLJjx0eXHLKexsAKf48n1XvZVLaWO9Hk9Zwc2dPxcz4zK VSIw== X-Gm-Message-State: AOJu0Yw2ubqdtK59awDMagZYxK5agTyPwkeGco6IgqnPMwIRVNRM9OoI MSD1ssWHgOo4cMZLSAatB4ydS7JRrCcklQZDeBAqQQLvB39oimhAJtY/7bAUd/WuQXMCu1toSvJ JgY8= X-Received: by 2002:a17:902:6804:b0:1d8:b0d2:704 with SMTP id h4-20020a170902680400b001d8b0d20704mr13175366plk.62.1707082927540; Sun, 04 Feb 2024 13:42:07 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.42.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:42:07 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 34/39] tcg/ppc: Add TCG_CT_CONST_CMP Date: Mon, 5 Feb 2024 07:40:47 +1000 Message-Id: <20240204214052.5639-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Better constraint for tcg_out_cmp, based on the comparison. We can't yet remove the fallback to load constants into a scratch because of tcg_out_cmp2, but that path should not be as frequent. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target-con-set.h | 5 ++-- tcg/ppc/tcg-target-con-str.h | 1 + tcg/ppc/tcg-target.c.inc | 48 ++++++++++++++++++++++++++++++------ 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/tcg/ppc/tcg-target-con-set.h b/tcg/ppc/tcg-target-con-set.h index cb47b29452..9f99bde505 100644 --- a/tcg/ppc/tcg-target-con-set.h +++ b/tcg/ppc/tcg-target-con-set.h @@ -11,7 +11,7 @@ */ C_O0_I1(r) C_O0_I2(r, r) -C_O0_I2(r, ri) +C_O0_I2(r, rC) C_O0_I2(v, r) C_O0_I3(r, r, r) C_O0_I3(o, m, r) @@ -26,13 +26,14 @@ C_O1_I2(r, rI, ri) C_O1_I2(r, rI, rT) C_O1_I2(r, r, r) C_O1_I2(r, r, ri) +C_O1_I2(r, r, rC) C_O1_I2(r, r, rI) C_O1_I2(r, r, rT) C_O1_I2(r, r, rU) C_O1_I2(r, r, rZW) C_O1_I2(v, v, v) C_O1_I3(v, v, v, v) -C_O1_I4(r, r, ri, rZ, rZ) +C_O1_I4(r, r, rC, rZ, rZ) C_O1_I4(r, r, r, ri, ri) C_O2_I1(r, r, r) C_N1O1_I1(o, m, r) diff --git a/tcg/ppc/tcg-target-con-str.h b/tcg/ppc/tcg-target-con-str.h index 20846901de..16b687216e 100644 --- a/tcg/ppc/tcg-target-con-str.h +++ b/tcg/ppc/tcg-target-con-str.h @@ -16,6 +16,7 @@ REGS('v', ALL_VECTOR_REGS) * Define constraint letters for constants: * CONST(letter, TCG_CT_CONST_* bit set) */ +CONST('C', TCG_CT_CONST_CMP) CONST('I', TCG_CT_CONST_S16) CONST('M', TCG_CT_CONST_MONE) CONST('T', TCG_CT_CONST_S32) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 26e0bc31d7..535ef2cbe7 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -92,11 +92,13 @@ #define SZR (TCG_TARGET_REG_BITS / 8) #define TCG_CT_CONST_S16 0x100 +#define TCG_CT_CONST_U16 0x200 #define TCG_CT_CONST_S32 0x400 #define TCG_CT_CONST_U32 0x800 #define TCG_CT_CONST_ZERO 0x1000 #define TCG_CT_CONST_MONE 0x2000 #define TCG_CT_CONST_WSZ 0x4000 +#define TCG_CT_CONST_CMP 0x8000 #define ALL_GENERAL_REGS 0xffffffffu #define ALL_VECTOR_REGS 0xffffffff00000000ull @@ -296,9 +298,35 @@ static bool tcg_target_const_match(int64_t sval, int ct, sval = (int32_t)sval; } + if (ct & TCG_CT_CONST_CMP) { + switch (cond) { + case TCG_COND_EQ: + case TCG_COND_NE: + ct |= TCG_CT_CONST_S16 | TCG_CT_CONST_U16; + break; + case TCG_COND_LT: + case TCG_COND_GE: + case TCG_COND_LE: + case TCG_COND_GT: + ct |= TCG_CT_CONST_S16; + break; + case TCG_COND_LTU: + case TCG_COND_GEU: + case TCG_COND_LEU: + case TCG_COND_GTU: + ct |= TCG_CT_CONST_U16; + break; + default: + g_assert_not_reached(); + } + } + if ((ct & TCG_CT_CONST_S16) && sval == (int16_t)sval) { return 1; } + if ((ct & TCG_CT_CONST_U16) && uval == (uint16_t)uval) { + return 1; + } if ((ct & TCG_CT_CONST_S32) && sval == (int32_t)sval) { return 1; } @@ -1682,7 +1710,10 @@ static void tcg_out_cmp(TCGContext *s, int cond, TCGArg arg1, TCGArg arg2, tcg_debug_assert(TCG_TARGET_REG_BITS == 64 || type == TCG_TYPE_I32); - /* Simplify the comparisons below wrt CMPI. */ + /* + * Simplify the comparisons below wrt CMPI. + * All of the tests are 16-bit, so a 32-bit sign extend always works. + */ if (type == TCG_TYPE_I32) { arg2 = (int32_t)arg2; } @@ -3991,8 +4022,6 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_sar_i32: case INDEX_op_rotl_i32: case INDEX_op_rotr_i32: - case INDEX_op_setcond_i32: - case INDEX_op_negsetcond_i32: case INDEX_op_and_i64: case INDEX_op_andc_i64: case INDEX_op_shl_i64: @@ -4000,8 +4029,6 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_sar_i64: case INDEX_op_rotl_i64: case INDEX_op_rotr_i64: - case INDEX_op_setcond_i64: - case INDEX_op_negsetcond_i64: return C_O1_I2(r, r, ri); case INDEX_op_mul_i32: @@ -4045,11 +4072,16 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_brcond_i32: case INDEX_op_brcond_i64: - return C_O0_I2(r, ri); - + return C_O0_I2(r, rC); + case INDEX_op_setcond_i32: + case INDEX_op_setcond_i64: + case INDEX_op_negsetcond_i32: + case INDEX_op_negsetcond_i64: + return C_O1_I2(r, r, rC); case INDEX_op_movcond_i32: case INDEX_op_movcond_i64: - return C_O1_I4(r, r, ri, rZ, rZ); + return C_O1_I4(r, r, rC, rZ, rZ); + case INDEX_op_deposit_i32: case INDEX_op_deposit_i64: return C_O1_I2(r, 0, rZ); From patchwork Sun Feb 4 21:40:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769868 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842503wrc; Sun, 4 Feb 2024 13:44:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IEv+3Zpquxw/DIRGTtYYU2BJ99F8UmOUC7WreDdrzjgnZ4VRLJOu+QhB4RkdHAENYX4wuTm X-Received: by 2002:ac8:4404:0:b0:42a:8a48:89f0 with SMTP id j4-20020ac84404000000b0042a8a4889f0mr5075118qtn.15.1707083066285; Sun, 04 Feb 2024 13:44:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083066; cv=none; d=google.com; s=arc-20160816; b=DiAyw2JAJQ3a5ZeADp66vr4WlNZZzHbnJi7VMu0qrn9p3VMECBOJVPkkB0AKije7qt ta1hsoffWaDHEXM2ctfkSxXVOvYRoVSThL0LKryidWFzIHro/f9TduG0WYQBlUsW5+jm vrsY6P6HsbO0txoUrH0xNNlSgWqxDawlrnCcxCU1Hq7pqvGB/PG1EbeVK4uKfPsA5ACk lnE+8KtMtBflE7nRsMj9Fix6eZgOhm9EUHgoXUtx9TzVdoYgjs56EIAdMCuM1JPHwMfG HDOEfYAPzGOR8tKfqa+Kv0aBHtXXtcg7ELX8wp5nxpSMYBdcPrfPehvm2cAIl9Bp00i+ VHVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=j+fCUcqxhvgu1RQeAIaBsUghOSepyBvOWmxuutmNswA=; fh=l4xJiABoasclt2s0gG12S7E+FxejNUCiJaf8wlHCZKA=; b=tXsy29twbytsKB40giBkx4FmrDGhQ9CNMXuzxd5v1OdyWONh6EMhRDPbv949vpV0Ft k410tXVz8gUW3mZjX9FVmF86N76QUNc/kM08bExGqRTMgWrc3iUMKigex1wMx6GuCbiC VbKHD6c4m3CPU7uCbrultseNYysFYsCsDa3cWBQfeBarxvA8fUyTCoHrgn0ZJXvG2rKa 2tmdGStC+opgkn3b1BeZLz8wkBR6H2Jz/E9g9dNqGMe6FrbaX/RUkCwIwCUJF0cmn4dA qWcvd5tucd9Eh7HrBIJwY0qR1yCK28v+IO+kmszqRWkxUM4X8rWaOnZun+TUTtX59qQQ WSTA==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jG4xeeXt; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCXriVzSnjXTSQjSf0uXVKvfjbRzGW+/CloKgH2fxoLctaCjLas/q8+c4/Dv151EB5/b+bJfwOD7VWqrqwA3eCnt Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 16-20020ac84e90000000b0042c19c4968dsi2796283qtp.396.2024.02.04.13.44.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:44:26 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jG4xeeXt; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkFj-0004CO-Tg; Sun, 04 Feb 2024 16:42:16 -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 1rWkFh-0003wO-4X for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:42:13 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkFe-0003cg-Sn for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:42:12 -0500 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1d93f2c3701so18201145ad.3 for ; Sun, 04 Feb 2024 13:42:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082929; x=1707687729; 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=j+fCUcqxhvgu1RQeAIaBsUghOSepyBvOWmxuutmNswA=; b=jG4xeeXtwgjkap8i0kA7nbbV6NOQeQwCwiT5JmTvSSh828vQqlyzPBgOTAkfWpKTv/ VfuoS3lzRCIXuAtDjy7tyyHED9mYdLwMg4AXhIB1eIwDpR8b5w/+LYHpp7gTt0q3NAJq iEYkJkAqiYo6Z8dwa5kfIJRmNS9Q5BbKXmKenPnqVgDXGUEV5de9BGAi39MNd79NwtuM kX2+/fZx9t7xZI8hpHh+BBYIKX3PjPeNyl+p8SP8ME2UfEcZOvSTf5E23nP6s9fGACPz xStjw1l+pq0uUZ2Dt/+t6WqWpRi9BVzVK8q+Rqu+OKyUqJtPO2ZM9wcoqkwXYRmApCJS +SKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082929; x=1707687729; 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=j+fCUcqxhvgu1RQeAIaBsUghOSepyBvOWmxuutmNswA=; b=clnIVq+G62Uu57V2uTM4/32jQQQt68xO81GZR0FWjEmKc5ZVbObi8eo+yCSACyUg+K RlLzZvUuBdt9yGD6sKJepcM4Fra+m4v4dzjpgeYXIHLaHKuuWwp8IxpYknkqmBZENAmW a2oCHSugxrfpowoaEj0oL17ZzvJcdygmmxeptE3oJZWpsdjRR6uKZVZwg2FC+S/WUpcj CWprH4FHtVm5zfNq4mhLrbrJolPuIaRkv/5+Y19k9hOLiu8fToc4mwn/0WlOmsIjtZgB mjTS9BC1TE3+x/CsmV1Ryi8J1PEYy+HRn/hG83WBjwUsPnswjtWrIz7eVyxDOVO/uJ70 QM1A== X-Gm-Message-State: AOJu0Yz0CO5nr356WlfkZ5bqPdrmm4taUrS23RTaVIX1EwOqhfHKsJ4T V8l6h6XnHzwTsArf/IDUKMgKggvk6ptA0DXdMbDnk6z/YuKrAYx82JELBRj+NOtaW5EniFyW25j /a9A= X-Received: by 2002:a17:902:c94b:b0:1d9:8e37:56d6 with SMTP id i11-20020a170902c94b00b001d98e3756d6mr4077106pla.40.1707082929563; Sun, 04 Feb 2024 13:42:09 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.42.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:42:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 35/39] tcg/ppc: Support TCG_COND_TST{EQ,NE} Date: Mon, 5 Feb 2024 07:40:48 +1000 Message-Id: <20240204214052.5639-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.h | 2 +- tcg/ppc/tcg-target.c.inc | 122 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 115 insertions(+), 9 deletions(-) diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index 60ce49e672..04a7aba4d3 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -143,7 +143,7 @@ typedef enum { #define TCG_TARGET_HAS_qemu_ldst_i128 \ (TCG_TARGET_REG_BITS == 64 && have_isa_2_07) -#define TCG_TARGET_HAS_tst 0 +#define TCG_TARGET_HAS_tst 1 /* * While technically Altivec could support V64, it has no 64-bit store diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 535ef2cbe7..7f3829beeb 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -283,11 +283,15 @@ static bool reloc_pc34(tcg_insn_unit *src_rw, const tcg_insn_unit *target) return false; } +static bool mask_operand(uint32_t c, int *mb, int *me); +static bool mask64_operand(uint64_t c, int *mb, int *me); + /* test if a constant matches the constraint */ static bool tcg_target_const_match(int64_t sval, int ct, TCGType type, TCGCond cond, int vece) { uint64_t uval = sval; + int mb, me; if (ct & TCG_CT_CONST) { return 1; @@ -316,6 +320,17 @@ static bool tcg_target_const_match(int64_t sval, int ct, case TCG_COND_GTU: ct |= TCG_CT_CONST_U16; break; + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + if ((uval & ~0xffff) == 0 || (uval & ~0xffff0000ull) == 0) { + return 1; + } + if (TCG_TARGET_REG_BITS == 32 || type == TCG_TYPE_I32 + ? mask_operand(uval, &mb, &me) + : mask64_operand(uval << clz64(uval), &mb, &me)) { + return 1; + } + return 0; default: g_assert_not_reached(); } @@ -703,9 +718,11 @@ enum { CR_SO }; -static const uint32_t tcg_to_bc[] = { +static const uint32_t tcg_to_bc[16] = { [TCG_COND_EQ] = BC | BI(0, CR_EQ) | BO_COND_TRUE, [TCG_COND_NE] = BC | BI(0, CR_EQ) | BO_COND_FALSE, + [TCG_COND_TSTEQ] = BC | BI(0, CR_EQ) | BO_COND_TRUE, + [TCG_COND_TSTNE] = BC | BI(0, CR_EQ) | BO_COND_FALSE, [TCG_COND_LT] = BC | BI(0, CR_LT) | BO_COND_TRUE, [TCG_COND_GE] = BC | BI(0, CR_LT) | BO_COND_FALSE, [TCG_COND_LE] = BC | BI(0, CR_GT) | BO_COND_FALSE, @@ -717,9 +734,11 @@ static const uint32_t tcg_to_bc[] = { }; /* The low bit here is set if the RA and RB fields must be inverted. */ -static const uint32_t tcg_to_isel[] = { +static const uint32_t tcg_to_isel[16] = { [TCG_COND_EQ] = ISEL | BC_(0, CR_EQ), [TCG_COND_NE] = ISEL | BC_(0, CR_EQ) | 1, + [TCG_COND_TSTEQ] = ISEL | BC_(0, CR_EQ), + [TCG_COND_TSTNE] = ISEL | BC_(0, CR_EQ) | 1, [TCG_COND_LT] = ISEL | BC_(0, CR_LT), [TCG_COND_GE] = ISEL | BC_(0, CR_LT) | 1, [TCG_COND_LE] = ISEL | BC_(0, CR_GT) | 1, @@ -872,19 +891,31 @@ static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) return true; } -static inline void tcg_out_rld(TCGContext *s, int op, TCGReg ra, TCGReg rs, - int sh, int mb) +static void tcg_out_rld_rc(TCGContext *s, int op, TCGReg ra, TCGReg rs, + int sh, int mb, bool rc) { tcg_debug_assert(TCG_TARGET_REG_BITS == 64); sh = SH(sh & 0x1f) | (((sh >> 5) & 1) << 1); mb = MB64((mb >> 5) | ((mb << 1) & 0x3f)); - tcg_out32(s, op | RA(ra) | RS(rs) | sh | mb); + tcg_out32(s, op | RA(ra) | RS(rs) | sh | mb | rc); } -static inline void tcg_out_rlw(TCGContext *s, int op, TCGReg ra, TCGReg rs, - int sh, int mb, int me) +static void tcg_out_rld(TCGContext *s, int op, TCGReg ra, TCGReg rs, + int sh, int mb) { - tcg_out32(s, op | RA(ra) | RS(rs) | SH(sh) | MB(mb) | ME(me)); + tcg_out_rld_rc(s, op, ra, rs, sh, mb, false); +} + +static void tcg_out_rlw_rc(TCGContext *s, int op, TCGReg ra, TCGReg rs, + int sh, int mb, int me, bool rc) +{ + tcg_out32(s, op | RA(ra) | RS(rs) | SH(sh) | MB(mb) | ME(me) | rc); +} + +static void tcg_out_rlw(TCGContext *s, int op, TCGReg ra, TCGReg rs, + int sh, int mb, int me) +{ + tcg_out_rlw_rc(s, op, ra, rs, sh, mb, me, false); } static void tcg_out_ext8s(TCGContext *s, TCGType type, TCGReg dst, TCGReg src) @@ -1702,6 +1733,50 @@ static inline bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, return false; } +/* + * Set dest non-zero if and only if (arg1 & arg2) is non-zero. + * If RC, then also set RC0. + */ +static void tcg_out_test(TCGContext *s, TCGReg dest, TCGReg arg1, TCGArg arg2, + bool const_arg2, TCGType type, bool rc) +{ + int mb, me; + + if (!const_arg2) { + tcg_out32(s, AND | SAB(arg1, dest, arg2) | rc); + return; + } + + if (type == TCG_TYPE_I32) { + arg2 = (uint32_t)arg2; + } else if (arg2 == (uint32_t)arg2) { + type = TCG_TYPE_I32; + } + + if ((arg2 & ~0xffff) == 0) { + tcg_out32(s, ANDI | SAI(arg1, dest, arg2)); + return; + } + if ((arg2 & ~0xffff0000ull) == 0) { + tcg_out32(s, ANDIS | SAI(arg1, dest, arg2 >> 16)); + return; + } + if (TCG_TARGET_REG_BITS == 32 || type == TCG_TYPE_I32) { + if (mask_operand(arg2, &mb, &me)) { + tcg_out_rlw_rc(s, RLWINM, dest, arg1, 0, mb, me, rc); + return; + } + } else { + int sh = clz64(arg2); + if (mask64_operand(arg2 << sh, &mb, &me)) { + tcg_out_rld_rc(s, RLDICR, dest, arg1, sh, me, rc); + return; + } + } + /* Constraints should satisfy this. */ + g_assert_not_reached(); +} + static void tcg_out_cmp(TCGContext *s, int cond, TCGArg arg1, TCGArg arg2, int const_arg2, int cr, TCGType type) { @@ -1736,6 +1811,12 @@ static void tcg_out_cmp(TCGContext *s, int cond, TCGArg arg1, TCGArg arg2, imm = 0; break; + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + tcg_debug_assert(cr == 0); + tcg_out_test(s, TCG_REG_R0, arg1, arg2, const_arg2, type, true); + return; + case TCG_COND_LT: case TCG_COND_GE: case TCG_COND_LE: @@ -1946,6 +2027,16 @@ static void tcg_out_setcond(TCGContext *s, TCGType type, TCGCond cond, tcg_out_setcond_ne0(s, type, arg0, arg1, neg); break; + case TCG_COND_TSTEQ: + tcg_out_test(s, TCG_REG_R0, arg1, arg2, const_arg2, type, false); + tcg_out_setcond_eq0(s, type, arg0, TCG_REG_R0, neg); + break; + + case TCG_COND_TSTNE: + tcg_out_test(s, TCG_REG_R0, arg1, arg2, const_arg2, type, false); + tcg_out_setcond_ne0(s, type, arg0, TCG_REG_R0, neg); + break; + case TCG_COND_LE: case TCG_COND_LEU: inv = true; @@ -2118,6 +2209,21 @@ static void tcg_out_cmp2(TCGContext *s, const TCGArg *args, tcg_out32(s, op | BT(0, CR_EQ) | BA(6, CR_EQ) | BB(7, CR_EQ)); break; + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + if (blconst) { + tcg_out_andi32(s, TCG_REG_R0, al, bl); + } else { + tcg_out32(s, AND | SAB(al, TCG_REG_R0, bl)); + } + if (bhconst) { + tcg_out_andi32(s, TCG_REG_TMP1, ah, bh); + } else { + tcg_out32(s, AND | SAB(ah, TCG_REG_TMP1, bh)); + } + tcg_out32(s, OR | SAB(TCG_REG_R0, TCG_REG_R0, TCG_REG_TMP1) | 1); + break; + case TCG_COND_LT: case TCG_COND_LE: case TCG_COND_GT: From patchwork Sun Feb 4 21:40:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769871 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842542wrc; Sun, 4 Feb 2024 13:44:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IHW6XOqUcL94dhcjuPhmMSVLrrAWypKYvktzil+5xtB5u4DlhWukz0OInm/UuHz0LOqa7yN X-Received: by 2002:a05:622a:1a9d:b0:42c:2651:c2e6 with SMTP id s29-20020a05622a1a9d00b0042c2651c2e6mr1329399qtc.46.1707083079377; Sun, 04 Feb 2024 13:44:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083079; cv=none; d=google.com; s=arc-20160816; b=mIx0ounWVp7c1IJAd3FmUjI3XVQuj9OQCvuVDV/EoFkq/IaF/kCausrpwe3Bsbom4k 6WBauCrHSsmYuRJ3hhBYG5aIMC4+8iR3RX10TayFd7xWfYma4OgpuBRmV3Dd0Jh3mFFg 4Yb0/caitCwXD9VKQ9+ot6UlggMTL8JaRdnvnOZh3Bnf5nGHVskn3OafFh84NEHZcWTX 4INY+1qGGlWJjHVC2pV5dlC2ERoGwLgBitMi+NspZFtbFKNHME91RGNMQDEcE6bbgABF apNKTB2YVwmvEsAHSKyJHH3ozeb4pP5qJRcFHroSfaNUprqjs5QaCA8K2SkkjSeOB1e2 qIGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rLlFVC2Bn8RFXAnYZ0tdiIE38xNTKymQB0njuipjHgI=; fh=Sam3BCcQOjpDJf9cHvKFzFfaQNwRom1WceZHeKTkPCs=; b=JzvU2eqbBDII46PnmDR/G47UEsWo+KlJ1x9qOqupxdQ4cw7rByRBZuYaikfyvBfRYe f3p+u4XqEXsKW9TRzBatgGlgZZ0zWCvKsZJVuWjb8+d8xZHDjRkJNOW94Y8+Zyqqpe/B 9CcF/WC7lj2P1GJKpetFlqCVQeDHVXu5uF7YEF5nkuXyZWVd5DVRjrWsWNxKDCCjuA/N +Sn3kJdOnvTimkV9pTC9Z7YfhNjKR3hVfQ6+h773pMJ+GBMFrHBZ2P9aLbLfagpJt8tF jvZhRtLPGxzMv23/+sBuHWL5nxlaWbCQhCH8fpytvt+NzgHGKty7luD9JJjr2tn9V0ZB neMg==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eV9jXOpE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCWepJVWKw/9thsqwoF1y9qylMiTzvHJtga2FujjOP8N3GPaukTGwrELqZfxYz/C17W3UKDGPs6U6o/pgrCi96nI Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v7-20020a05622a130700b0042c078c3783si5795525qtk.627.2024.02.04.13.44.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:44:39 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eV9jXOpE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkFm-0004LW-1L; Sun, 04 Feb 2024 16:42: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 1rWkFi-00046t-Tk for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:42:15 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkFh-0003ct-0m for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:42:14 -0500 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1d94b222a3aso31083175ad.2 for ; Sun, 04 Feb 2024 13:42:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082931; x=1707687731; 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=rLlFVC2Bn8RFXAnYZ0tdiIE38xNTKymQB0njuipjHgI=; b=eV9jXOpEQrZql2VM6I+hfYndgmk7AgsS4uHBufCVIdw/rVKaz5vovulI1Bwwws/aWF 76CKr99vFkvFFuHx6MHbevFbk6Rl/zU61MolzB75NW0XhAgCc2L5ejvskNzSPMNT/i1K TLTECZp5fwPddQbinpgpIy5QeIajv4I4+cSMRKq8K+nc9dwu3PXlWxnIea+Ucr5EH3qc a8tTk3jtta1GSA++6x1AHveKag462pyfMTaTEb9jNFdTs8ywyQHU1a2BT/twz84igAHD OkvSG/KgUuy7uyiyGkFZwGftOIbSwlw4NoB53UnhTvjQO53AxKZM5EXKIXIhqpiNCcfp TXXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082931; x=1707687731; 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=rLlFVC2Bn8RFXAnYZ0tdiIE38xNTKymQB0njuipjHgI=; b=XweZGWaFcINMWHHM8gtXItzQyxdQw1lvRkXqnBDsSGCwfmFfsdEOzgr+uhA+8e3Pi7 Nza5ROWVUrdbyEU64knSPINyAduxSVYQiZX8N0OIkU7f0PHeBBq3DmSXQqIGH7nrs92e hY3HD5O7sWkeLd0Vc65GezBoTOvWrDerWm3IpuE4xJQxKKzUDBUnqfWW9IwUbFhAoczS P7GbuNMMO6K8dFpKVj9E8XHNFOGwQCox8FfhcPSnqIUQK8kvR5sEnh9bswfhTuZoqmsi szHqkyqPqw9230V+0Pef3xcUOFheGFu21LMlzmp+rmGovRVydbYtPu86vTKkE1oCAkxq UkxQ== X-Gm-Message-State: AOJu0YzAre/gnBoIFtudKHmtUJXOisFr8eQxwKB31M5eXlHDZ24uhOQu Iu5H6T/9yialeeby5FrLwLxRTuSziZAOOKvbU5P+2CUseZerDWtrU4CgGFiKMRS6eC8ZBUpgYy1 bqnQ= X-Received: by 2002:a17:902:d2c2:b0:1d9:b407:dd87 with SMTP id n2-20020a170902d2c200b001d9b407dd87mr1911951plc.21.1707082931599; Sun, 04 Feb 2024 13:42:11 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.42.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:42:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 36/39] tcg/s390x: Split constraint A into J+U Date: Mon, 5 Feb 2024 07:40:49 +1000 Message-Id: <20240204214052.5639-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed 33-bit == signed 32-bit + unsigned 32-bit. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- 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 54645d1f55..b2815ec648 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -30,7 +30,7 @@ #define TCG_CT_CONST_S16 (1 << 8) #define TCG_CT_CONST_S32 (1 << 9) -#define TCG_CT_CONST_S33 (1 << 10) +#define TCG_CT_CONST_U32 (1 << 10) #define TCG_CT_CONST_ZERO (1 << 11) #define TCG_CT_CONST_P32 (1 << 12) #define TCG_CT_CONST_INV (1 << 13) @@ -542,22 +542,23 @@ static bool tcg_target_const_match(int64_t val, int ct, TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { - return 1; + return true; } - if (type == TCG_TYPE_I32) { val = (int32_t)val; } - /* The following are mutually exclusive. */ - if (ct & TCG_CT_CONST_S16) { - return val == (int16_t)val; - } else if (ct & TCG_CT_CONST_S32) { - return val == (int32_t)val; - } else if (ct & TCG_CT_CONST_S33) { - return val >= -0xffffffffll && val <= 0xffffffffll; - } else if (ct & TCG_CT_CONST_ZERO) { - return val == 0; + if ((ct & TCG_CT_CONST_S32) && val == (int32_t)val) { + return true; + } + if ((ct & TCG_CT_CONST_U32) && val == (uint32_t)val) { + return true; + } + if ((ct & TCG_CT_CONST_S16) && val == (int16_t)val) { + return true; + } + if ((ct & TCG_CT_CONST_ZERO) && val == 0) { + return true; } if (ct & TCG_CT_CONST_INV) { @@ -573,8 +574,7 @@ static bool tcg_target_const_match(int64_t val, int ct, if ((ct & TCG_CT_CONST_INVRISBG) && risbg_mask(~val)) { return true; } - - return 0; + return false; } /* Emit instructions according to the given instruction format. */ @@ -3137,7 +3137,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) return C_O1_I2(r, r, ri); case INDEX_op_setcond_i64: case INDEX_op_negsetcond_i64: - return C_O1_I2(r, r, rA); + return C_O1_I2(r, r, rJU); case INDEX_op_clz_i64: return C_O1_I2(r, r, rI); @@ -3187,7 +3187,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_brcond_i32: return C_O0_I2(r, ri); case INDEX_op_brcond_i64: - return C_O0_I2(r, rA); + return C_O0_I2(r, rJU); case INDEX_op_bswap16_i32: case INDEX_op_bswap16_i64: @@ -3240,7 +3240,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_movcond_i32: return C_O1_I4(r, r, ri, rI, r); case INDEX_op_movcond_i64: - return C_O1_I4(r, r, rA, rI, r); + return C_O1_I4(r, r, rJU, rI, r); case INDEX_op_div2_i32: case INDEX_op_div2_i64: @@ -3259,7 +3259,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_add2_i64: case INDEX_op_sub2_i64: - return C_N1_O1_I4(r, r, 0, 1, rA, r); + return C_N1_O1_I4(r, r, 0, 1, rJU, r); case INDEX_op_st_vec: return C_O0_I2(v, r); From patchwork Sun Feb 4 21:40:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769855 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842159wrc; Sun, 4 Feb 2024 13:42:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IEOC6oUawGH/unEjigcwsiE5sWHeugHATqB58d5guCRhMxNxdXFqM0dlh4d7EYClqPQy7ej X-Received: by 2002:a05:6214:5c02:b0:68c:794c:652e with SMTP id ly2-20020a0562145c0200b0068c794c652emr6365285qvb.35.1707082959659; Sun, 04 Feb 2024 13:42:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707082959; cv=none; d=google.com; s=arc-20160816; b=WoDPWWXQuHisZY0C1LP0a4Vt8gJV4MxCwYlnSniZauyE5hAbh57kYYCGxC1HBBd4ir fGNhSSxRS2p3eGiq7LTKMWiT53VXYuBdGtpDiHTnBoxWCHInZbYAhyogll2kEUc49Oxj rKQ5CqDczuvE9zkxLWorhXK6X0WVBCgr6qSov7qSUIEJkYSU6kHlR0mF1xkoZZxUp12l 5P1XrR4HuAK27PLuyrVOt8j61dfCyUBjhBcZ42q/LEq/Stt+0OuStrfK7Y2rhGkOMotH bW2pzG5LSAmRPFWFl6poi/1fFBdX8ZsepW3SMUDnZwKESr3BtbvD+1kOjmRDQaMqRggE alYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tzAVTurY/MAys+s1+i1OQQjHsG3DvtN9WipSnI15uxA=; fh=0E9rSb2FcmBFcExB7/4/2QdA5NMSgKP1ZLqLvlnoSvU=; b=jfhUsNZEfsb7qMvDUigUtJ+IILdroZkKpPmnimO00RsMPaHumX4wfStT2Jl27ldeeW zypGQnR82hmtQlF3izWqwmNbLGUufqjLaJ7RfROLErs9NI+5WIa7rdN1PCNbaswaGFSl 54C5iXs7xO8VfSCXAt6x8iHw0zGGucJWKAcsVLOpeqJFAnPKHnmIAE99l9bASDXcA3HM K1QUSMfzVK6sHZ8kzZ4Xkx0RowUNpJEaCG0iXwLivTGHDdQg/kHfNDm3sRVxfi7Q4S0C Hrm8b0Xow3qsMcebPUcq7jR56xi6Uu6I4raIGWqeRZeozBYnRRMYvDfknzaSSsYueXp+ TsFA==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mnEW53uY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCVmVQxUZzvKdtpVMLT39P2fvFgXE6vf/zao04TS/JK8kJskE5F58ZHMMkWSaoc5geoM0SvPX9IDsAD+/05n/D/u Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h10-20020a05620a244a00b007854eb41542si7756909qkn.684.2024.02.04.13.42.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:42:39 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mnEW53uY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkFn-0004Uz-T7; Sun, 04 Feb 2024 16:42:19 -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 1rWkFl-0004Ie-3c for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:42:17 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkFi-0003d5-Tf for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:42:16 -0500 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1d93f2c3701so18201365ad.3 for ; Sun, 04 Feb 2024 13:42:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082933; x=1707687733; 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=tzAVTurY/MAys+s1+i1OQQjHsG3DvtN9WipSnI15uxA=; b=mnEW53uYd3yhr8mwY1Wqnd97orS0RDqJ+UX5kxutz1QcDtMszaeM2UFJZmuGqRgR+g 4Q3uTMqhjcgCn/eLp8Ucr++l5+oNY/OVo2+JGBG91/ZXy0GOfU6/DYzKcSWajXwsM54w 5bv02OSBGOgmK6LpUSrbjntE2GsnQGST7fofwxO05tBpLThIttbC/pGp6Vz52dWDv443 fA3BrsltyD2Xcn7uKkvHk6pMD5HKoCwaimyBMlf7B/Ep3vy/y1AsCXKQ9GbJdIRYuzxC YCntpE1RpTCQdI0flhyOtDOwjWcU8dTK8rCDYHDoTGIkHweQ47VJAbIUyNHnJJIgdpb6 SN6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082933; x=1707687733; 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=tzAVTurY/MAys+s1+i1OQQjHsG3DvtN9WipSnI15uxA=; b=cSw73UoqIuH27AQnFXtlVR11fDzYtZh966b1grnr0cyFIoIAgm5IfiOYoW24JjfMHe 75Z8aREjDGqDzLzY8lLYWV70UCLWbj3wE40sD+y6Xmhn6BAWbdcb9XEBpYpBId96ZULH Q8aQRkTrPl1yIUKER0AlSyKQwnuZwdEl+jkYRXMowbb5N2AnQ5hBVC44+cEEGcdypVdB xw7uB/4nAOu9mxUpv3Q8lvtSuxQMiw/8B/dm/8+rcm1AnwhhnKMJWqAhz1JTvbXePKfo 3p23fHyjY9mDbCKxJ4fP16XUI24x6dFXescLOI+rAbFLSSYWskdGp6w+KKO3h52HmZUN T98w== X-Gm-Message-State: AOJu0YwZDd4N1rXZ9aj9DZURZjg7mUTOIYd6+TcVYXKIhjv8v79frJf1 OmJ+mkszHRuBuB5D9bFYGSmyv5uq3C/AlQSl1V4LuYzCjJGaYDogOI+kUq8BjxQaDYEtah4AKCz BvgM= X-Received: by 2002:a17:902:708c:b0:1d9:63d1:e619 with SMTP id z12-20020a170902708c00b001d963d1e619mr7538410plk.29.1707082933639; Sun, 04 Feb 2024 13:42:13 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.42.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:42:13 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 37/39] tcg/s390x: Add TCG_CT_CONST_CMP Date: Mon, 5 Feb 2024 07:40:50 +1000 Message-Id: <20240204214052.5639-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Better constraint for tcg_out_cmp, based on the comparison. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- 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 b2815ec648..7f97080f52 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -35,6 +35,7 @@ #define TCG_CT_CONST_P32 (1 << 12) #define TCG_CT_CONST_INV (1 << 13) #define TCG_CT_CONST_INVRISBG (1 << 14) +#define TCG_CT_CONST_CMP (1 << 15) #define ALL_GENERAL_REGS MAKE_64BIT_MASK(0, 16) #define ALL_VECTOR_REGS MAKE_64BIT_MASK(32, 32) @@ -548,6 +549,29 @@ static bool tcg_target_const_match(int64_t val, int ct, val = (int32_t)val; } + if (ct & TCG_CT_CONST_CMP) { + switch (cond) { + case TCG_COND_EQ: + case TCG_COND_NE: + ct |= TCG_CT_CONST_S32 | TCG_CT_CONST_U32; /* CGFI or CLGFI */ + break; + case TCG_COND_LT: + case TCG_COND_GE: + case TCG_COND_LE: + case TCG_COND_GT: + ct |= TCG_CT_CONST_S32; /* CGFI */ + break; + case TCG_COND_LTU: + case TCG_COND_GEU: + case TCG_COND_LEU: + case TCG_COND_GTU: + ct |= TCG_CT_CONST_U32; /* CLGFI */ + break; + default: + g_assert_not_reached(); + } + } + if ((ct & TCG_CT_CONST_S32) && val == (int32_t)val) { return true; } @@ -1229,22 +1253,34 @@ static int tgen_cmp2(TCGContext *s, TCGType type, TCGCond c, TCGReg r1, goto exit; } - /* - * Constraints are for a signed 33-bit operand, which is a - * convenient superset of this signed/unsigned test. - */ - if (c2 == (is_unsigned ? (TCGArg)(uint32_t)c2 : (TCGArg)(int32_t)c2)) { - op = (is_unsigned ? RIL_CLGFI : RIL_CGFI); - tcg_out_insn_RIL(s, op, r1, c2); - goto exit; + /* Should match TCG_CT_CONST_CMP. */ + switch (c) { + case TCG_COND_LT: + case TCG_COND_GE: + case TCG_COND_LE: + case TCG_COND_GT: + tcg_debug_assert(c2 == (int32_t)c2); + op = RIL_CGFI; + break; + case TCG_COND_EQ: + case TCG_COND_NE: + if (c2 == (int32_t)c2) { + op = RIL_CGFI; + break; + } + /* fall through */ + case TCG_COND_LTU: + case TCG_COND_GEU: + case TCG_COND_LEU: + case TCG_COND_GTU: + tcg_debug_assert(c2 == (uint32_t)c2); + op = RIL_CLGFI; + break; + default: + g_assert_not_reached(); } - - /* Load everything else into a register. */ - tcg_out_movi(s, TCG_TYPE_I64, TCG_TMP0, c2); - c2 = TCG_TMP0; - } - - if (type == TCG_TYPE_I32) { + tcg_out_insn_RIL(s, op, r1, c2); + } else if (type == TCG_TYPE_I32) { op = (is_unsigned ? RR_CLR : RR_CR); tcg_out_insn_RR(s, op, r1, c2); } else { @@ -3137,7 +3173,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) return C_O1_I2(r, r, ri); case INDEX_op_setcond_i64: case INDEX_op_negsetcond_i64: - return C_O1_I2(r, r, rJU); + return C_O1_I2(r, r, rC); case INDEX_op_clz_i64: return C_O1_I2(r, r, rI); @@ -3187,7 +3223,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_brcond_i32: return C_O0_I2(r, ri); case INDEX_op_brcond_i64: - return C_O0_I2(r, rJU); + return C_O0_I2(r, rC); case INDEX_op_bswap16_i32: case INDEX_op_bswap16_i64: @@ -3240,7 +3276,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpcode op) case INDEX_op_movcond_i32: return C_O1_I4(r, r, ri, rI, r); case INDEX_op_movcond_i64: - return C_O1_I4(r, r, rJU, rI, r); + return C_O1_I4(r, r, rC, rI, r); case INDEX_op_div2_i32: case INDEX_op_div2_i64: From patchwork Sun Feb 4 21:40:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769883 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842867wrc; Sun, 4 Feb 2024 13:46:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IFOQYta+/TAjCFqHfIG9gjUsBpW4oRmi9HRTUf8qxberuot6oNIHLr0IOT7yt7m9/vwaOtC X-Received: by 2002:a0c:f294:0:b0:68c:8b5c:9d29 with SMTP id k20-20020a0cf294000000b0068c8b5c9d29mr4434822qvl.62.1707083181682; Sun, 04 Feb 2024 13:46:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083181; cv=none; d=google.com; s=arc-20160816; b=SRKOaw4VeI6tVvE7Xr0aI2I/Uko34m9YPZKfPa40aQoB6gW6D+7so6i9jVGcYc/X8W tBkt9bnFtcGXL8in+NuTf3L5lyDlm3+jihLii46NpIVJ/31X43x/AWDdMbMUn36m5WiK f0C/rKu/LHmPvLrkrmFRgbNpxhtaHF2DoeszekqOjAOoxRxKDXu6vfNuKt0n5UtCkM38 pcArwONQRVYmR96jCV8FPCXs2EB3XWnog6eaz948eiPxZAFZv7VX9PEIgBVhtJUW1fL3 D/QG7DPn9rd5vauDTThL8s7Sbn4r/amkrMMV7tq8TWD2GKuOZDLhbUliXvEYCi7Sr7Q+ 5LiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=diWYXbXbA8L+75njY+7GPUMLmiHt2XR0aqVQQ7E9HQ8=; fh=ekmZppb/3Ck/eLRe7WEvHqnuagTfeIxvJ80Mx+IGtXU=; b=CxsGAtzwIf4wKKVH84QwGJvxzwWEdhhKJ5TyMlCYdnivf6QLx3sGtMIRXUX8WhzfL/ RiFXqPfEZbjkbrJsn0gc1mfisX6QQ59Y1hArdpTb4lfqpP65z/j4ltxYsWFpA7XM69S5 kHXGBhBavht6ZMO44LiNLS71AZ/psbz5JSAQK/BlyjTX3rOaH06yj6FWaCKrJ8WX8qae ANKg1LHL6d1w1gMiaXqP3Y9Qjitz3seOAindvFcRanob8NhNY9j8WHKY2+E5oT7W2Bc8 LPdPbLx4yTCSqGp1/qku436Gvelw1GJK5bIoJTaQgTjFLlmI+gW0dPhRG6kUsdW+1Fs2 qkiw==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QbEurLrb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCXKZRwoa3TJHsKyeZR/iO8IEw9FRkfFQBZ1a8AiLCL9Y23ar+10ioCMt8u/67dsrH9pcrHtpmgJxzS06jlRcKQI Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l10-20020ad4408a000000b006817965d028si7298412qvp.301.2024.02.04.13.46.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:46:21 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QbEurLrb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkFo-0004cB-VS; Sun, 04 Feb 2024 16:42: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 1rWkFm-0004RN-Sj for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:42:18 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkFk-0003dJ-QZ for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:42:18 -0500 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1d74045c463so29336185ad.3 for ; Sun, 04 Feb 2024 13:42:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082935; x=1707687735; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=diWYXbXbA8L+75njY+7GPUMLmiHt2XR0aqVQQ7E9HQ8=; b=QbEurLrb119FPE3vPOpTZ9qDRungCBTP2b3HS4L1HjNgxB98WgpXfgMDkxH13DgcGC fH/Lf7h/uARCcHc9IOdTWGT0M9J16u9PNrOCX47tZwrzrkiun4qLURpHMYkn/7kn9qy9 QFjdkFNUkxKhq5XGfaOL31zagDv6FWq2l3ASTPUwlgmqTTrx/uMiSmFranX9zIRUDEZ3 I85so8XSnDvBW5BNqetOV4/k3dYZfgT5lFa0tUFyd8/XXHYALpVKlUB6byu9Rq0eQgnF QuExhnkullmda7r3s61h4qu32RVH0/JdhbHBCzb7hLLbOW1WiSD7pIJO7bU/VimeIdRP u0/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082935; x=1707687735; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=diWYXbXbA8L+75njY+7GPUMLmiHt2XR0aqVQQ7E9HQ8=; b=rjVlFvFpOjAs7HTlYKER6v5bMDLwNWeQVr9GXT0cWxSatdBgMfHj6B2IZQgmZmnFx6 CU1QqJv6tJo6bUtsTLgCxw+xuuJrSNx447OPLSIVq8JNv0E33Z5L9Iz1u6EeKnYABsaw 5Qc0GvAHSRFhn1Kmx8GMngprB68XKyqMGIejYPXW9dFyQtaBRMqbAyJg07sjDN3Ujf2A kwXrC3BMj/b+0zU3+gjT1PZiFkC2lYCBaKKyev1zz5wMKFuCp+QBZ+6M4MSbTTFy87xV wBOZITIVDH8GcVsG2yKTO89HMpA72EtJgKWZm1Ib67bu+zgjvkGFearVeqCmnAutKHAK yeTg== X-Gm-Message-State: AOJu0Yy2iOtkDzybhy0yYHqXXp7k9BjixNI/eJnEo2S55zUYmMvVOBoz PqUZQBUtiRo+KAWnFAzpnP9ewF71RV3qg3Uf69peRIvrC9JlGP1YE+1DMddgWalL+UEexux66fl yDIQ= X-Received: by 2002:a17:902:b182:b0:1d9:7782:316f with SMTP id s2-20020a170902b18200b001d97782316fmr5489247plr.39.1707082935458; Sun, 04 Feb 2024 13:42:15 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.42.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:42:15 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 38/39] tcg/s390x: Support TCG_COND_TST{EQ,NE} Date: Mon, 5 Feb 2024 07:40:51 +1000 Message-Id: <20240204214052.5639-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson --- tcg/s390x/tcg-target.h | 2 +- tcg/s390x/tcg-target.c.inc | 139 +++++++++++++++++++++++++------------ 2 files changed, 97 insertions(+), 44 deletions(-) diff --git a/tcg/s390x/tcg-target.h b/tcg/s390x/tcg-target.h index 53bed8c8d2..ae448c3a3a 100644 --- a/tcg/s390x/tcg-target.h +++ b/tcg/s390x/tcg-target.h @@ -138,7 +138,7 @@ extern uint64_t s390_facilities[3]; #define TCG_TARGET_HAS_qemu_ldst_i128 1 -#define TCG_TARGET_HAS_tst 0 +#define TCG_TARGET_HAS_tst 1 #define TCG_TARGET_HAS_v64 HAVE_FACILITY(VECTOR) #define TCG_TARGET_HAS_v128 HAVE_FACILITY(VECTOR) diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc index 7f97080f52..41f693ebbc 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -112,6 +112,9 @@ typedef enum S390Opcode { RI_OILH = 0xa50a, RI_OILL = 0xa50b, RI_TMLL = 0xa701, + RI_TMLH = 0xa700, + RI_TMHL = 0xa703, + RI_TMHH = 0xa702, RIEb_CGRJ = 0xec64, RIEb_CLGRJ = 0xec65, @@ -404,10 +407,15 @@ static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) #define S390_CC_NEVER 0 #define S390_CC_ALWAYS 15 +#define S390_TM_EQ 8 /* CC == 0 */ +#define S390_TM_NE 7 /* CC in {1,2,3} */ + /* Condition codes that result from a COMPARE and COMPARE LOGICAL. */ -static const uint8_t tcg_cond_to_s390_cond[] = { +static const uint8_t tcg_cond_to_s390_cond[16] = { [TCG_COND_EQ] = S390_CC_EQ, [TCG_COND_NE] = S390_CC_NE, + [TCG_COND_TSTEQ] = S390_CC_EQ, + [TCG_COND_TSTNE] = S390_CC_NE, [TCG_COND_LT] = S390_CC_LT, [TCG_COND_LE] = S390_CC_LE, [TCG_COND_GT] = S390_CC_GT, @@ -421,9 +429,11 @@ static const uint8_t tcg_cond_to_s390_cond[] = { /* Condition codes that result from a LOAD AND TEST. Here, we have no unsigned instruction variation, however since the test is vs zero we can re-map the outcomes appropriately. */ -static const uint8_t tcg_cond_to_ltr_cond[] = { +static const uint8_t tcg_cond_to_ltr_cond[16] = { [TCG_COND_EQ] = S390_CC_EQ, [TCG_COND_NE] = S390_CC_NE, + [TCG_COND_TSTEQ] = S390_CC_ALWAYS, + [TCG_COND_TSTNE] = S390_CC_NEVER, [TCG_COND_LT] = S390_CC_LT, [TCG_COND_LE] = S390_CC_LE, [TCG_COND_GT] = S390_CC_GT, @@ -542,10 +552,13 @@ static bool risbg_mask(uint64_t c) static bool tcg_target_const_match(int64_t val, int ct, TCGType type, TCGCond cond, int vece) { + uint64_t uval = val; + if (ct & TCG_CT_CONST) { return true; } if (type == TCG_TYPE_I32) { + uval = (uint32_t)val; val = (int32_t)val; } @@ -567,6 +580,15 @@ static bool tcg_target_const_match(int64_t val, int ct, case TCG_COND_GTU: ct |= TCG_CT_CONST_U32; /* CLGFI */ break; + case TCG_COND_TSTNE: + case TCG_COND_TSTEQ: + if (is_const_p16(uval) >= 0) { + return true; /* TMxx */ + } + if (risbg_mask(uval)) { + return true; /* RISBG */ + } + break; default: g_assert_not_reached(); } @@ -588,10 +610,6 @@ static bool tcg_target_const_match(int64_t val, int ct, if (ct & TCG_CT_CONST_INV) { val = ~val; } - /* - * Note that is_const_p16 is a subset of is_const_p32, - * so we don't need both constraints. - */ if ((ct & TCG_CT_CONST_P32) && is_const_p32(val) >= 0) { return true; } @@ -868,6 +886,9 @@ static const S390Opcode oi_insns[4] = { static const S390Opcode lif_insns[2] = { RIL_LLILF, RIL_LLIHF, }; +static const S390Opcode tm_insns[4] = { + RI_TMLL, RI_TMLH, RI_TMHL, RI_TMHH +}; /* load a register with an immediate value */ static void tcg_out_movi(TCGContext *s, TCGType type, @@ -1228,6 +1249,36 @@ static int tgen_cmp2(TCGContext *s, TCGType type, TCGCond c, TCGReg r1, TCGCond inv_c = tcg_invert_cond(c); S390Opcode op; + if (is_tst_cond(c)) { + tcg_debug_assert(!need_carry); + + if (!c2const) { + if (type == TCG_TYPE_I32) { + tcg_out_insn(s, RRFa, NRK, TCG_REG_R0, r1, c2); + } else { + tcg_out_insn(s, RRFa, NGRK, TCG_REG_R0, r1, c2); + } + goto exit; + } + + if (type == TCG_TYPE_I32) { + c2 = (uint32_t)c2; + } + + int i = is_const_p16(c2); + if (i >= 0) { + tcg_out_insn_RI(s, tm_insns[i], r1, c2 >> (i * 16)); + *inv_cc = TCG_COND_TSTEQ ? S390_TM_NE : S390_TM_EQ; + return *inv_cc ^ 15; + } + + if (risbg_mask(c2)) { + tgen_andi_risbg(s, TCG_REG_R0, r1, c2); + goto exit; + } + g_assert_not_reached(); + } + if (c2const) { if (c2 == 0) { if (!(is_unsigned && need_carry)) { @@ -1553,46 +1604,49 @@ static void tgen_brcond(TCGContext *s, TCGType type, TCGCond c, TCGReg r1, TCGArg c2, int c2const, TCGLabel *l) { int cc; - bool is_unsigned = is_unsigned_cond(c); - bool in_range; - S390Opcode opc; - cc = tcg_cond_to_s390_cond[c]; + if (!is_tst_cond(c)) { + bool is_unsigned = is_unsigned_cond(c); + bool in_range; + S390Opcode opc; - if (!c2const) { - opc = (type == TCG_TYPE_I32 - ? (is_unsigned ? RIEb_CLRJ : RIEb_CRJ) - : (is_unsigned ? RIEb_CLGRJ : RIEb_CGRJ)); - tgen_compare_branch(s, opc, cc, r1, c2, l); - return; - } + cc = tcg_cond_to_s390_cond[c]; - /* - * COMPARE IMMEDIATE AND BRANCH RELATIVE has an 8-bit immediate field. - * If the immediate we've been given does not fit that range, we'll - * fall back to separate compare and branch instructions using the - * larger comparison range afforded by COMPARE IMMEDIATE. - */ - if (type == TCG_TYPE_I32) { - if (is_unsigned) { - opc = RIEc_CLIJ; - in_range = (uint32_t)c2 == (uint8_t)c2; - } else { - opc = RIEc_CIJ; - in_range = (int32_t)c2 == (int8_t)c2; + if (!c2const) { + opc = (type == TCG_TYPE_I32 + ? (is_unsigned ? RIEb_CLRJ : RIEb_CRJ) + : (is_unsigned ? RIEb_CLGRJ : RIEb_CGRJ)); + tgen_compare_branch(s, opc, cc, r1, c2, l); + return; } - } else { - if (is_unsigned) { - opc = RIEc_CLGIJ; - in_range = (uint64_t)c2 == (uint8_t)c2; + + /* + * COMPARE IMMEDIATE AND BRANCH RELATIVE has an 8-bit immediate field. + * If the immediate we've been given does not fit that range, we'll + * fall back to separate compare and branch instructions using the + * larger comparison range afforded by COMPARE IMMEDIATE. + */ + if (type == TCG_TYPE_I32) { + if (is_unsigned) { + opc = RIEc_CLIJ; + in_range = (uint32_t)c2 == (uint8_t)c2; + } else { + opc = RIEc_CIJ; + in_range = (int32_t)c2 == (int8_t)c2; + } } else { - opc = RIEc_CGIJ; - in_range = (int64_t)c2 == (int8_t)c2; + if (is_unsigned) { + opc = RIEc_CLGIJ; + in_range = (uint64_t)c2 == (uint8_t)c2; + } else { + opc = RIEc_CGIJ; + in_range = (int64_t)c2 == (int8_t)c2; + } + } + if (in_range) { + tgen_compare_imm_branch(s, opc, cc, r1, c2, l); + return; } - } - if (in_range) { - tgen_compare_imm_branch(s, opc, cc, r1, c2, l); - return; } cc = tgen_cmp(s, type, c, r1, c2, c2const, false); @@ -1871,11 +1925,10 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h, ldst->oi = oi; ldst->addrlo_reg = addr_reg; - /* We are expecting a_bits to max out at 7, much lower than TMLL. */ tcg_debug_assert(a_mask <= 0xffff); tcg_out_insn(s, RI, TMLL, addr_reg, a_mask); - tcg_out16(s, RI_BRC | (7 << 4)); /* CC in {1,2,3} */ + tcg_out16(s, RI_BRC | (S390_TM_NE << 4)); ldst->label_ptr[0] = s->code_ptr++; } @@ -1956,7 +2009,7 @@ static void tcg_out_qemu_ldst_i128(TCGContext *s, TCGReg datalo, TCGReg datahi, l2 = gen_new_label(); tcg_out_insn(s, RI, TMLL, addr_reg, 15); - tgen_branch(s, 7, l1); /* CC in {1,2,3} */ + tgen_branch(s, S390_TM_NE, l1); } tcg_debug_assert(!need_bswap); From patchwork Sun Feb 4 21:40:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 769875 Delivered-To: patch@linaro.org Received: by 2002:adf:9bca:0:b0:33a:e5bd:fedd with SMTP id e10csp1842644wrc; Sun, 4 Feb 2024 13:45:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IGxB3crt3xj/LYl797p/QUb++36P+lx6+1lNI+PjQxnkmEyYQwLaQviR+vHdw903oImufXq X-Received: by 2002:a05:622a:1703:b0:42c:272f:d3b1 with SMTP id h3-20020a05622a170300b0042c272fd3b1mr515060qtk.61.1707083112247; Sun, 04 Feb 2024 13:45:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707083112; cv=none; d=google.com; s=arc-20160816; b=xOechf4gzyQWTvy4nr9LfOe/oLQ0KMxdXsZWzheptmANSjqIPbefp18cTmmlXdKz7B x/oBffyVNYYlVhVh5hPjD5wofbLDwvilrun038cpCmzYvF8/P8wMCzf3p1DIm4r0M5Di timpaX18o3m7L6jbBVzIvHRpoiIgLiZ0RwG6XvZ75UCR5Qd3CP1muqDcfBjI6S8dFLyF MShi3dGPl6c9XMb0+uPVjFGieXQtPWpyDgNeiwP3e/D4Wrt+yvVDeCQgUqMYYkhlcEMt 9GuSB+di8SSUV0JjqHOQEVjlXHoK/hR8n4hdpBEmLyTwfcCZSdH+NQ0xyiT/t5eIWcgn wb2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qTBa5jnTmGPw5Fiyw2n1vRD4BYHoTuI+qXkHnySYH1Q=; fh=wz0W27+THpVczR5L3D9KlFX2LeRCu8cJA2r85myz1P4=; b=kToocYaMXQHwkr+1MLQpx0r+i5t+lkAbHWL+2I0ceSdE9finOdyMcgnrJHzqMLv6ka wrgPfz+0L42qFLO//l0l2q6rMvu8ZPijUjullw9QUUfElctiiDUmlvpfjln1g/G2i+Mr bGNsq6MbDUoIl0GvqXfdJOqwP7BTpcio1hQBOWzwZ3OVJgLHOCSQxfHmPjiHntVkE8LZ 20miN0zMaB6paRXr+6N0Ku39y8eCLn4eQhp3lbZZbg7X7GkOEhAL9QyKgUHtojxdg01x qeRme2sYou81SKy6T709wck69KrCEeSmC5PH0pdIxtKIWHj7+HQ0c4dKCnI+YcfMeTnT L7cQ==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B1lPYf4n; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=0; AJvYcCUZwmrUqDggiS+B8i/nWx3N1oMv+oArFw1wNUTiBDE9K/rsNamDlxtqsqNSPMwwt+HUWqZzJ0tQ7AqCHbLjooYy Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w13-20020a05622a190d00b0042a7092c7fesi7275644qtc.477.2024.02.04.13.45.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 04 Feb 2024 13:45:12 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B1lPYf4n; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWkFr-0004kf-5i; Sun, 04 Feb 2024 16:42:23 -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 1rWkFo-0004YK-99 for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:42:20 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWkFm-0003dU-MJ for qemu-devel@nongnu.org; Sun, 04 Feb 2024 16:42:19 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d76671e5a4so30524755ad.0 for ; Sun, 04 Feb 2024 13:42:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707082937; x=1707687737; 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=B1lPYf4nLcp48lDb7pCulObNTwUm7Kq00BW2XFzRB8aM93q99gp1CPvK9IId9Yv3UM ePTxo4x6WJSY3B47T46q/htumRlsZkT7jemXYXD/6QuD7jMhwTpeQc7a4PBddJEyx60e cnVrv6VQjY42rIcxvs/Duql35tcWSfOT0oWIYLOL2l/p10j+3zCOle/YPzgNZ309H0kT jFfF2vMf0d3riQ7O8BffXMvIvgMnN8m8F8PwLq6C9urHfAYig21RM+uTcHU1vLl4UHR2 Mb/PkOIrsxrO9rDiOf+hxGZq8OjzpAMp7h5u82Nh/rzdQ7MZIluibqkLtKcu2ieLWF46 Nm4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707082937; x=1707687737; 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=GrGU1Pd4NgCfBD/xurfr5dF2VhnDRhZA8DpfmAHYiEBmkn/Wjsv7JdeFTJMyyljle4 gNGn2iSwpeAAZjO9iHXSNHfRFrujjjUJLkgogJzdWsiK1SMMMi9b3Vsc/hbiGJ5ciFNr w7jGXVi24Ug9WgX64aQXVbkPeYH8prwN/6ut2juVMyqETlITE99C4bNPq+jHIC80sYsM QGiIC8nRwgs8izVGLRPbJ8TyAxLdB+Ng/um8l2hTbDlrzOgqB/4MUrkPa7zOCyPH3SPo AyemWWsg8RjOjrqcEdrOMWWhkxZj+DXuu+i/ZelhNhdZSgcZYhqzWFuW7pl+U/d313Kz rfJw== X-Gm-Message-State: AOJu0YyjmUBYtKmBB/ux7+BRT87RjUR8ekgxQulqmWMY0XS4gkD1hk7S kWq9/jNUok3zaiq5UJbU87igAdM9VLUyRmLiFDi3Qaz+f/Rjm7bFj3R/ZD/f0TcJQCjuAQpgnvj jSTs= X-Received: by 2002:a17:903:2d1:b0:1d9:6895:81c3 with SMTP id s17-20020a17090302d100b001d9689581c3mr12848060plk.22.1707082937445; Sun, 04 Feb 2024 13:42:17 -0800 (PST) Received: from stoup.. ([43.252.112.156]) by smtp.gmail.com with ESMTPSA id mf11-20020a170902fc8b00b001d8f5560503sm4953670plb.222.2024.02.04.13.42.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 13:42:17 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 39/39] tcg/tci: Support TCG_COND_TST{EQ,NE} Date: Mon, 5 Feb 2024 07:40:52 +1000 Message-Id: <20240204214052.5639-40-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240204214052.5639-1-richard.henderson@linaro.org> References: <20240204214052.5639-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/tci/tcg-target.h | 2 +- tcg/tci.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index 609b2f4e4a..a076f401d2 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -117,7 +117,7 @@ #define TCG_TARGET_HAS_qemu_ldst_i128 0 -#define TCG_TARGET_HAS_tst 0 +#define TCG_TARGET_HAS_tst 1 /* Number of registers available. */ #define TCG_TARGET_NB_REGS 16 diff --git a/tcg/tci.c b/tcg/tci.c index 3cc851b7bd..39adcb7d82 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -228,6 +228,12 @@ static bool tci_compare32(uint32_t u0, uint32_t u1, TCGCond condition) case TCG_COND_GTU: result = (u0 > u1); break; + case TCG_COND_TSTEQ: + result = (u0 & u1) == 0; + break; + case TCG_COND_TSTNE: + result = (u0 & u1) != 0; + break; default: g_assert_not_reached(); } @@ -270,6 +276,12 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TCGCond condition) case TCG_COND_GTU: result = (u0 > u1); break; + case TCG_COND_TSTEQ: + result = (u0 & u1) == 0; + break; + case TCG_COND_TSTNE: + result = (u0 & u1) != 0; + break; default: g_assert_not_reached(); } @@ -1041,6 +1053,8 @@ static const char *str_c(TCGCond c) [TCG_COND_GEU] = "geu", [TCG_COND_LEU] = "leu", [TCG_COND_GTU] = "gtu", + [TCG_COND_TSTEQ] = "tsteq", + [TCG_COND_TSTNE] = "tstne", }; assert((unsigned)c < ARRAY_SIZE(cond));