From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522411; cv=none; d=zohomail.com; s=zohoarc; b=CZGXiGSEnypeX69VkvseR5OTzF/DTIoFYru9DamYn51XENHo2Go/dBTlHeI2NBA2js++niGAyr/VP9inPGBS1IeqwVaZe6iEoWku3e2gswn/GyN/6sjoWm0bOH4f2dzAGwnoNmuSJLSZQSJgcOgoBJUvCco0qxXh/wouQm9Vc+4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522411; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LsrfUb0AmZ7c8AfnEr9wziF3Zzy/kyouo9+mBfFHQpI=; b=iqekSM7hGFtJ+gmJ2ZzCkWMHDu822UTJ96/UCYvsOANL3mEGxLDpscCNZdiTlrUBb/cYS3Emi92J45qQda5kNlkzntQbaqbAt4MufL/Fe89zOitdwrV6T80mPpfzxgk3EIle/V4ITH1R6gLYklLD+Fy2pQrPTmtRdgH0O9iOJyU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522411640864.4529642155097; Sat, 28 Oct 2023 12:46:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpFS-0004gt-BK; Sat, 28 Oct 2023 15:45:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFQ-0004g7-Qy for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:28 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFP-00045m-6J for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:28 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6b3c2607d9bso2910924b3a.1 for ; Sat, 28 Oct 2023 12:45:26 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522325; x=1699127125; 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=LsrfUb0AmZ7c8AfnEr9wziF3Zzy/kyouo9+mBfFHQpI=; b=mHxTpO3gb2TDtbHPjP6E/p81ArA3SebUAjvLmDYc3tjRTd3U/slwklgQ5nGp8+jgnB a2jSfXMKQ3z3ueVMHGfVrJKwb73zhsczYU5eSa+KcrAvZJAeZQVMIKhtZvtQtTrf1cxC tsZNtMUq8exXB+m+n9snEeJEXmsQWOlUG1WO5lps7MKZYw/2QNrwBCEmF4eZYJ2f8OyI gvMrvS/2xLZwxvtu8MqR2QkQJsfyvW9tkJpajhSQFG3+lAWZUIXTc44FyKOvM2ZsyfZv 1DmFueg9FUDzZm47yLELRB5tqwWYCX3JmTRFaM2VqBnrFVOjulHxuLFxlZdzhqCjT779 KdxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522325; x=1699127125; 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=LsrfUb0AmZ7c8AfnEr9wziF3Zzy/kyouo9+mBfFHQpI=; b=lq+8LKvYldWhseVo1zCjXN5zbqlvz0RKisS83H/NLpda9NznoxdRaTadYyq1yggs7y JiARFaqAQ/3KTHP8Y3ofEWTuD0W8kQ2xUhT+1sthWlS807sPCefCMQKHrNLszQuIXJ/0 ZUswTaZVRtXJfqnxJYAKV+f7dbCZa0aqdKks8bkSpY89y/BxCCb55Jon3m1Sn34F9Yc2 X11VzfhhTUgUtagboWz/b4MyMWCPHFPIdbuHGhrdg397ILHlf/ZzzfWWORCfA++nwYzW p59kigwIEoWjPFTJvIEAmYrb0nr6gFw2PYzepbaeuIr6woT7bKhHCqPkKfEF0ZzTIUPv x6kg== X-Gm-Message-State: AOJu0YxpXR1JVygr6LWAc0gKxFzSc2GyqZ7I0erpkX6IB/NJuVEMUBnj RLcbk/SnA8pgLXc+Jg6EJCenDU4270DspOKkCsw= X-Google-Smtp-Source: AGHT+IF0yQKwFlXHyImr6rdxCGqA8SlLMbD9KLZzxjJMnwEYiw4NQ9WSoNKxD+aXwhE541VjX6mQQw== X-Received: by 2002:a05:6a20:54a3:b0:13d:17cc:5bca with SMTP id i35-20020a056a2054a300b0013d17cc5bcamr6563145pzk.18.1698522325375; Sat, 28 Oct 2023 12:45:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 01/35] tcg: Introduce TCG_COND_TST{EQ,NE} Date: Sat, 28 Oct 2023 12:44:48 -0700 Message-Id: <20231028194522.245170-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522412205100005 Content-Type: text/plain; charset="utf-8" Add the enumerators, adjust the helpers to match, and dump. Not supported anywhere else just yet. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- docs/devel/tcg-ops.rst | 2 ++ include/tcg/tcg-cond.h | 49 ++++++++++++++++++++++++++++++++---------- tcg/tcg.c | 4 +++- 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/docs/devel/tcg-ops.rst b/docs/devel/tcg-ops.rst index 8ae59ea02b..d46b625e0e 100644 --- a/docs/devel/tcg-ops.rst +++ b/docs/devel/tcg-ops.rst @@ -253,6 +253,8 @@ Jumps/Labels | ``TCG_COND_GEU /* unsigned */`` | ``TCG_COND_LEU /* unsigned */`` | ``TCG_COND_GTU /* unsigned */`` + | ``TCG_COND_TSTEQ /* t1 & t2 =3D=3D 0 */`` + | ``TCG_COND_TSTNE /* t1 & t2 !=3D 0 */`` =20 Arithmetic ---------- diff --git a/include/tcg/tcg-cond.h b/include/tcg/tcg-cond.h index 2a38a386d4..bf3fcf5968 100644 --- a/include/tcg/tcg-cond.h +++ b/include/tcg/tcg-cond.h @@ -49,6 +49,9 @@ typedef enum { TCG_COND_GEU =3D 0 | 4 | 0 | 1, TCG_COND_LEU =3D 8 | 4 | 0 | 0, TCG_COND_GTU =3D 8 | 4 | 0 | 1, + /* "test" i.e. and then compare vs 0 */ + TCG_COND_TSTEQ =3D 8 | 4 | 2 | 0, + TCG_COND_TSTNE =3D 8 | 4 | 2 | 1, } TCGCond; =20 /* Invert the sense of the comparison. */ @@ -60,25 +63,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 (c + 2) & 4 ? (TCGCond)(c ^ 9) : c; } =20 -/* Create an "unsigned" version of a "signed" comparison. */ -static inline TCGCond tcg_unsigned_cond(TCGCond c) +/* Must a comparison be considered signed? */ +static inline bool is_signed_cond(TCGCond c) { - return c & 2 ? (TCGCond)(c ^ 6) : c; -} - -/* Create a "signed" version of an "unsigned" comparison. */ -static inline TCGCond tcg_signed_cond(TCGCond c) -{ - return c & 4 ? (TCGCond)(c ^ 6) : c; + return (c & 6) =3D=3D 2; } =20 /* Must a comparison be considered unsigned? */ static inline bool is_unsigned_cond(TCGCond c) { - return (c & 4) !=3D 0; + return (c & 6) =3D=3D 4; +} + +/* Must a comparison be considered a test? */ +static inline bool is_tst_cond(TCGCond c) +{ + return (c | 1) =3D=3D 0xf; +} + +/* Create an "unsigned" version of a "signed" comparison. */ +static inline TCGCond tcg_unsigned_cond(TCGCond c) +{ + return is_signed_cond(c) ? (TCGCond)(c ^ 6) : c; +} + +/* Create a "signed" version of an "unsigned" comparison. */ +static inline TCGCond tcg_signed_cond(TCGCond c) +{ + return is_unsigned_cond(c) ? (TCGCond)(c ^ 6) : 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 ^ 6) : 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 ^ (8 | 4 | 1)) : c; } =20 /* diff --git a/tcg/tcg.c b/tcg/tcg.c index 35158a0846..57d0583fe7 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2378,7 +2378,9 @@ static const char * const cond_name[] =3D [TCG_COND_LTU] =3D "ltu", [TCG_COND_GEU] =3D "geu", [TCG_COND_LEU] =3D "leu", - [TCG_COND_GTU] =3D "gtu" + [TCG_COND_GTU] =3D "gtu", + [TCG_COND_TSTEQ] =3D "tsteq", + [TCG_COND_TSTNE] =3D "tstne", }; =20 static const char * const ldst_name[(MO_BSWAP | MO_SSIZE) + 1] =3D --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522390; cv=none; d=zohomail.com; s=zohoarc; b=PLYv9dfv+zIXT8BRL0scJM2n/ahJMKPj9u62X4R4j+cXVcHQ4WLwE7TLGeWdYzgPrmZvcpBIKaXP3W307cMYX8flXmOzUDe5gbTtKsmNtLX7rLOc4xWe3ZY0M7cFw9KfZzp7aUr4YyHb9rUB40nCI1QWcIAgVV6S0kybKP1ksQw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522390; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Zh61DK1PDe6VrwXTSbb5OfrsTdylybfZGSWnmMjbkM0=; b=UnYca26Qny14RVqb0BIFGWtavjUZbhwPZ5T5YpMpUu7Zd+bTWjAdMrk+msEvi0vTfMyRYmcHoc+t4eTenJYdsVGpIWyksQyF53Doc4orgoD2z624EFh7o7seYkrr+Gm22+swzFldWvwD14qShrmw0ugo8z3e+ofWi/WhseLRKvU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16985223900351021.3533052635811; Sat, 28 Oct 2023 12:46:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpFT-0004h6-Ny; Sat, 28 Oct 2023 15:45:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFR-0004gG-Hu for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:29 -0400 Received: from mail-il1-x12d.google.com ([2607:f8b0:4864:20::12d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFP-00045p-Gc for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:29 -0400 Received: by mail-il1-x12d.google.com with SMTP id e9e14a558f8ab-3573fa82923so11404445ab.1 for ; Sat, 28 Oct 2023 12:45:27 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522326; x=1699127126; 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=Zh61DK1PDe6VrwXTSbb5OfrsTdylybfZGSWnmMjbkM0=; b=sh1IIEQSYSZwlu9XypfslMUdTWqB91iPeO38RFhTEubAaa6862sDZ/qSuLnAxXEM9i /0dsLX1Y/LpeiJvcm6ufdjpSrMRwCca7+XdaJsLvHedo4cQax7s4y7rG/sOIVNXyCQHg Der6CCawFVzmIScLbK2QqxazTycs7Vf71luUd8y/06DifC39MhzvnB24xXMZYx8UAjsj Yz9rEiildMix1/HViA8yG4MxIcNKN1vMDZmvQwHxNF9EH8JFKTTHUyFEVRyVnxkaOLZo YoV5SdHzJ6nGesbLGrGOaE5HnX9/0JkrGyRQ2ZvcladPrmMSmr8sW/t7/q4DVH59vGe8 amBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522326; x=1699127126; 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=Zh61DK1PDe6VrwXTSbb5OfrsTdylybfZGSWnmMjbkM0=; b=ernf/J4YcEr33PrsFDaQmmo1bhO1NEIN3y3/9U8OsB0VMPyy6FvcQxFayhypmb1EDx QYoHhOYI2uzORv+eli48qD2mqPuDxJcc02IdJqaRSCj21Oky3nEBgxMd+IBiABPPLBbO kYS79+HKLEJAU4HK5kZYpNZCH4nqKZHdK9babOMYdEVfCpkb4tKY3T02UxcvBRk8nGyM oZQj/2g5lvvyDeWhYfy9BmZEyyeuC/bSf+zSaSFfia10JH6eSBi/hYjERh6QZb/RxwvK 3Gt7JBCppdLkITKkP3vbsOqaU2j36paRdw1Xzf7t8/kBKXqffzMpdJVBj4HyDjItI9O5 N+dw== X-Gm-Message-State: AOJu0YwywOPf5ickakpQnOIo/8jF5J3SLO8opOdxutRitI3R60wSEQOV vlue9kY21rGPnwveb9nNrG2agIilOHBSh42T1JU= X-Google-Smtp-Source: AGHT+IGL5WrE0TRiMjl+P2ffVVuDHAFG/EIBuL8f0Q1ido0QjjmrImnRMrDPqUsz1TCEPa+zWQZm0w== X-Received: by 2002:a92:c26f:0:b0:357:a01f:35f0 with SMTP id h15-20020a92c26f000000b00357a01f35f0mr8837116ild.19.1698522326232; Sat, 28 Oct 2023 12:45:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 02/35] tcg/optimize: Split out arg_is_const_val Date: Sat, 28 Oct 2023 12:44:49 -0700 Message-Id: <20231028194522.245170-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::12d; envelope-from=richard.henderson@linaro.org; helo=mail-il1-x12d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522391865100019 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/optimize.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 2db5177c32..e8a13fedb5 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -112,11 +112,22 @@ static inline bool ts_is_const(TCGTemp *ts) return ts_info(ts)->is_const; } =20 +static inline bool ts_is_const_val(TCGTemp *ts, uint64_t val) +{ + TempOptInfo *ti =3D ts_info(ts); + return ti->is_const && ti->val =3D=3D val; +} + static inline bool arg_is_const(TCGArg arg) { return ts_is_const(arg_temp(arg)); } =20 +static inline bool arg_is_const_val(TCGArg arg, uint64_t val) +{ + return ts_is_const_val(arg_temp(arg), val); +} + static inline bool ts_is_copy(TCGTemp *ts) { return ts_info(ts)->next_copy !=3D ts; @@ -565,7 +576,7 @@ static int do_constant_folding_cond(TCGType type, TCGAr= g x, } } else if (args_are_copies(x, y)) { return do_constant_folding_cond_eq(c); - } else if (arg_is_const(y) && arg_info(y)->val =3D=3D 0) { + } else if (arg_is_const_val(y, 0)) { switch (c) { case TCG_COND_LTU: return 0; @@ -831,7 +842,7 @@ static bool fold_to_not(OptContext *ctx, TCGOp *op, int= idx) /* If the binary operation has first argument @i, fold to @i. */ static bool fold_ix_to_i(OptContext *ctx, TCGOp *op, uint64_t i) { - if (arg_is_const(op->args[1]) && arg_info(op->args[1])->val =3D=3D i) { + if (arg_is_const_val(op->args[1], i)) { return tcg_opt_gen_movi(ctx, op, op->args[0], i); } return false; @@ -840,7 +851,7 @@ static bool fold_ix_to_i(OptContext *ctx, TCGOp *op, ui= nt64_t i) /* If the binary operation has first argument @i, fold to NOT. */ static bool fold_ix_to_not(OptContext *ctx, TCGOp *op, uint64_t i) { - if (arg_is_const(op->args[1]) && arg_info(op->args[1])->val =3D=3D i) { + if (arg_is_const_val(op->args[1], i)) { return fold_to_not(ctx, op, 2); } return false; @@ -849,7 +860,7 @@ static bool fold_ix_to_not(OptContext *ctx, TCGOp *op, = uint64_t i) /* If the binary operation has second argument @i, fold to @i. */ static bool fold_xi_to_i(OptContext *ctx, TCGOp *op, uint64_t i) { - if (arg_is_const(op->args[2]) && arg_info(op->args[2])->val =3D=3D i) { + if (arg_is_const_val(op->args[2], i)) { return tcg_opt_gen_movi(ctx, op, op->args[0], i); } return false; @@ -858,7 +869,7 @@ static bool fold_xi_to_i(OptContext *ctx, TCGOp *op, ui= nt64_t i) /* If the binary operation has second argument @i, fold to identity. */ static bool fold_xi_to_x(OptContext *ctx, TCGOp *op, uint64_t i) { - if (arg_is_const(op->args[2]) && arg_info(op->args[2])->val =3D=3D i) { + if (arg_is_const_val(op->args[2], i)) { return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[1]); } return false; @@ -867,7 +878,7 @@ static bool fold_xi_to_x(OptContext *ctx, TCGOp *op, ui= nt64_t i) /* If the binary operation has second argument @i, fold to NOT. */ static bool fold_xi_to_not(OptContext *ctx, TCGOp *op, uint64_t i) { - if (arg_is_const(op->args[2]) && arg_info(op->args[2])->val =3D=3D i) { + if (arg_is_const_val(op->args[2], i)) { return fold_to_not(ctx, op, 1); } return false; @@ -1083,8 +1094,8 @@ static bool fold_brcond2(OptContext *ctx, TCGOp *op) * Simplify LT/GE comparisons vs zero to a single compare * vs the high word of the input. */ - if (arg_is_const(op->args[2]) && arg_info(op->args[2])->val =3D=3D= 0 && - arg_is_const(op->args[3]) && arg_info(op->args[3])->val =3D=3D= 0) { + if (arg_is_const_val(op->args[2], 0) && + arg_is_const_val(op->args[3], 0)) { goto do_brcond_high; } break; @@ -1303,9 +1314,7 @@ static bool fold_deposit(OptContext *ctx, TCGOp *op) } =20 /* Inserting a value into zero at offset 0. */ - if (arg_is_const(op->args[1]) - && arg_info(op->args[1])->val =3D=3D 0 - && op->args[3] =3D=3D 0) { + if (arg_is_const_val(op->args[1], 0) && op->args[3] =3D=3D 0) { uint64_t mask =3D MAKE_64BIT_MASK(0, op->args[4]); =20 op->opc =3D and_opc; @@ -1316,8 +1325,7 @@ static bool fold_deposit(OptContext *ctx, TCGOp *op) } =20 /* Inserting zero into a value. */ - if (arg_is_const(op->args[2]) - && arg_info(op->args[2])->val =3D=3D 0) { + if (arg_is_const_val(op->args[2], 0)) { uint64_t mask =3D deposit64(-1, op->args[3], op->args[4], 0); =20 op->opc =3D and_opc; @@ -1855,8 +1863,8 @@ static bool fold_setcond2(OptContext *ctx, TCGOp *op) * Simplify LT/GE comparisons vs zero to a single compare * vs the high word of the input. */ - if (arg_is_const(op->args[3]) && arg_info(op->args[3])->val =3D=3D= 0 && - arg_is_const(op->args[4]) && arg_info(op->args[4])->val =3D=3D= 0) { + if (arg_is_const_val(op->args[3], 0) && + arg_is_const_val(op->args[4], 0)) { goto do_setcond_high; } break; --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522519; cv=none; d=zohomail.com; s=zohoarc; b=Ht4SYU1g0uFcINz/bhsdCKbIgsA0kcZZQHJ+3ly/LdYHjqfQHjBb7pa6nVjMKtdzX0IdP080DdJNy1OC20AYFbXMsZmH8FsCrBXZBV/L1Jo1TVyg5MiBJi7p9Y/SOuqCvYY6RzSUNV98KSayk2iHTsmZb4z0SLuHarLlCnbOvzE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522519; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9eXocbu34bghBLrSPFKvIsugn7thygfTREC245booiE=; b=D9sn4Q4NxBlHVGpBuN2dxxXJFnaxFgU16R5Hm7G3bOY/2dHrZjJQ1DvnFRChPVn0yQI0qEfkkow/NffD2PI9iDSiFnDhinfxbOJ/6XuRwxzHEL0BDIyU6nry7cD9FHRpf5pSTsSHv1gtAif7Rs1Mqm5USaNDwlOaZ/WHIUTOGos= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522519846975.2798650031018; Sat, 28 Oct 2023 12:48:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpFV-0004iF-Re; Sat, 28 Oct 2023 15:45:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFU-0004hQ-2n for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:32 -0400 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 1qwpFR-00045u-Do for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:31 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1cc329ce84cso5535385ad.2 for ; Sat, 28 Oct 2023 12:45:28 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522327; x=1699127127; 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=9eXocbu34bghBLrSPFKvIsugn7thygfTREC245booiE=; b=rBhhkWQxpF2oT1zxDz5F8C4hPHo14o7GLjmOrhyne6qJvLQ9gFlJPrQsO4tSowAFCS rCmZaWM1Adn6xpjoQO8YE7K0eDGkkK9K1ZZS6g1lUReWCnxvfVhtAXaOsJl3+VADMYZo d11HQOHqaMtOoigW2sV8CFrXdHTEykdpAvaODVUvBNrIkj94J/vnHbyT1Z/U4es0Elq3 qEmX0+zBNa0hdGFISiqqaQucpiG7yEeiznzcG5vzMp9Z8WbImbi950xYzG/B5Q5BPHLx TXeBvbKhHg/Fl38VPAx8w3BzWrsDFVBajoZVuy0vdClYrbfpZ/PuRoQumi+B5mR1tf/z enVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522327; x=1699127127; 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=9eXocbu34bghBLrSPFKvIsugn7thygfTREC245booiE=; b=klhcRdtZXppz4v+HgvZp5gxPmIeW+AS12PEDz4YSK0fNYzJ5lw5JQVtBTrIf44Z/eE auo7P6BXovNOxSBtFMYOxd0y7Gw5gzV3riVuvhfIBxhHL/oYIwhSPB1P9iC1RQX30BE+ v1LM8E6Diy4WNMm1lPxxSgOL4nvsbsykk20QiTP2H6ZGm1qt5NmdFvTJwx0H7665GmeO lnvwjX6K46h4U8fRHewEKw9gqEJa6jIyKeVsEOfA2dBAQOUFzm5UQZzR55QBJAc6kFrW r4oDwh+33W61ARMg2HLKI8T62wDIY7z+dsFdCKLEgc/Q3OBvxUlvgM/ZVre9cI/3armv dDXQ== X-Gm-Message-State: AOJu0YwF3XeX6o145zQfn6McG7rAuJbEmhBLFEdDT5Fo6F6EEHv06n3n /AB+T/9I8aM2E9g3kJfd9SK2LkDOArY9o06W8XY= X-Google-Smtp-Source: AGHT+IErm9bRzlS9SU4a8GvEQOlWDnORwYyUOQbS91PuWs9WFbhLq8NonqrEqN4vpNtDt4eKloOgqw== X-Received: by 2002:a17:902:e5c2:b0:1cc:3fc9:7d09 with SMTP id u2-20020a170902e5c200b001cc3fc97d09mr523622plf.15.1698522327098; Sat, 28 Oct 2023 12:45:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 03/35] tcg/optimize: Split out do_constant_folding_cond1 Date: Sat, 28 Oct 2023 12:44:50 -0700 Message-Id: <20231028194522.245170-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522520201100001 Content-Type: text/plain; charset="utf-8" Handle modifications to the arguments and condition in a single place. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/optimize.c | 57 ++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index e8a13fedb5..89cc794d24 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -672,6 +672,23 @@ static bool swap_commutative2(TCGArg *p1, TCGArg *p2) return false; } =20 +static int do_constant_folding_cond1(OptContext *ctx, TCGArg dest, + TCGArg *p1, TCGArg *p2, TCGArg *pcond) +{ + TCGCond cond; + bool swap; + int r; + + swap =3D swap_commutative(dest, p1, p2); + cond =3D *pcond; + if (swap) { + *pcond =3D cond =3D tcg_swap_cond(cond); + } + + r =3D do_constant_folding_cond(ctx->type, *p1, *p2, cond); + return r; +} + static void init_arguments(OptContext *ctx, TCGOp *op, int nb_args) { for (int i =3D 0; i < nb_args; i++) { @@ -1053,14 +1070,8 @@ static bool fold_andc(OptContext *ctx, TCGOp *op) =20 static bool fold_brcond(OptContext *ctx, TCGOp *op) { - TCGCond cond =3D op->args[2]; - int i; - - if (swap_commutative(NO_DEST, &op->args[0], &op->args[1])) { - op->args[2] =3D cond =3D tcg_swap_cond(cond); - } - - i =3D do_constant_folding_cond(ctx->type, op->args[0], op->args[1], co= nd); + int i =3D do_constant_folding_cond1(ctx, NO_DEST, &op->args[0], + &op->args[1], &op->args[2]); if (i =3D=3D 0) { tcg_op_remove(ctx->tcg, op); return true; @@ -1550,21 +1561,18 @@ static bool fold_mov(OptContext *ctx, TCGOp *op) =20 static bool fold_movcond(OptContext *ctx, TCGOp *op) { - TCGCond cond =3D op->args[5]; int i; =20 - if (swap_commutative(NO_DEST, &op->args[1], &op->args[2])) { - op->args[5] =3D cond =3D tcg_swap_cond(cond); - } /* * Canonicalize the "false" input reg to match the destination reg so * that the tcg backend can implement a "move if true" operation. */ if (swap_commutative(op->args[0], &op->args[4], &op->args[3])) { - op->args[5] =3D cond =3D tcg_invert_cond(cond); + op->args[5] =3D tcg_invert_cond(op->args[5]); } =20 - i =3D do_constant_folding_cond(ctx->type, op->args[1], op->args[2], co= nd); + i =3D do_constant_folding_cond1(ctx, NO_DEST, &op->args[1], + &op->args[2], &op->args[5]); if (i >=3D 0) { return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[4 - i]); } @@ -1578,6 +1586,7 @@ static bool fold_movcond(OptContext *ctx, TCGOp *op) uint64_t tv =3D arg_info(op->args[3])->val; uint64_t fv =3D arg_info(op->args[4])->val; TCGOpcode opc, negopc =3D 0; + TCGCond cond =3D op->args[5]; =20 switch (ctx->type) { case TCG_TYPE_I32: @@ -1805,14 +1814,8 @@ static bool fold_remainder(OptContext *ctx, TCGOp *o= p) =20 static bool fold_setcond(OptContext *ctx, TCGOp *op) { - TCGCond cond =3D op->args[3]; - int i; - - if (swap_commutative(op->args[0], &op->args[1], &op->args[2])) { - op->args[3] =3D cond =3D tcg_swap_cond(cond); - } - - i =3D do_constant_folding_cond(ctx->type, op->args[1], op->args[2], co= nd); + int i =3D do_constant_folding_cond1(ctx, op->args[0], &op->args[1], + &op->args[2], &op->args[3]); if (i >=3D 0) { return tcg_opt_gen_movi(ctx, op, op->args[0], i); } @@ -1824,14 +1827,8 @@ static bool fold_setcond(OptContext *ctx, TCGOp *op) =20 static bool fold_negsetcond(OptContext *ctx, TCGOp *op) { - TCGCond cond =3D op->args[3]; - int i; - - if (swap_commutative(op->args[0], &op->args[1], &op->args[2])) { - op->args[3] =3D cond =3D tcg_swap_cond(cond); - } - - i =3D do_constant_folding_cond(ctx->type, op->args[1], op->args[2], co= nd); + int i =3D do_constant_folding_cond1(ctx, op->args[0], &op->args[1], + &op->args[2], &op->args[3]); if (i >=3D 0) { return tcg_opt_gen_movi(ctx, op, op->args[0], -i); } --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522493; cv=none; d=zohomail.com; s=zohoarc; b=Xa162g+cmmIp6B6hFe42/EHScC8D6W002wO90QJXM051e9dV8S4+VEP9BD7Iz3k3MOTCcRygMR8F+P524G7tVpa5AC1rfii4mKUf70OMwq+hOIrKkj2t9DM6zAac2EGh1YptJcgwlIZuU0Q6GqCP78zl5UYY6g442j8KbLaaLIw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522493; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xFOV1ZTpKlHV2EkIZjqhQOIe3ZbiCQ+tGnrYqmSw9YI=; b=FiZv+JpneFhkKteNuzqZjdc2RcpP9xogk+WOQ68N+gEzq7azlLfki6BJVicY/wJRtOwxhfmP+k1KqOOPHQ+pT4z/pWcPXmSynKplzlFG7hvbN3I3YUwQXamHOZ29MC2L+PNJf9b9Pzbz36AbEFHIXfZ+bWsFksnr7dPVLeOpHJQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522493745789.9799002375765; Sat, 28 Oct 2023 12:48:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpFU-0004ho-N0; Sat, 28 Oct 2023 15:45:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFT-0004gv-2A for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:31 -0400 Received: from mail-oo1-xc29.google.com ([2607:f8b0:4864:20::c29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFR-000464-Av for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:30 -0400 Received: by mail-oo1-xc29.google.com with SMTP id 006d021491bc7-57f0f81b2aeso1764654eaf.3 for ; Sat, 28 Oct 2023 12:45:28 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522328; x=1699127128; 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=xFOV1ZTpKlHV2EkIZjqhQOIe3ZbiCQ+tGnrYqmSw9YI=; b=VWWOxOM50lFaRMYTGpBOXrwPaHUiJhkGjPaC6rBXlRmWU+Ho9B/Xw9SvQooCoysGnW 3I9LPbpKx8XTL8C0B9fL2DL0zTCvd7ZdFZ7GbM5s29ubYVInLhlLPoMd1wHbqE6aDSb9 MWWOPf9VZS/3xXu2KOcon4xhVhkUiLwSpHiJ3VfE/UMCIo8sx0eHi4vLzchXsORuB41r nzYYrvPPVCPtJdjO2Ph5LJnIS4DT1j6deNjKrUnZOjy+k7fmA8N6U2O9NMAjWF1cHBVc W2sKeGFxUFA2s0P3llLdLUEJLzXHcRsZuiRYmPaIC1q4XFPWNtBrMPWAKi58Yg3mtkIt 1E9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522328; x=1699127128; 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=xFOV1ZTpKlHV2EkIZjqhQOIe3ZbiCQ+tGnrYqmSw9YI=; b=PxHTvDiryqrdqWl0mkKBovsK5r8wWjfD4gEj5vJ7PDgiWF0RdBUE2Ewc0nzPSKfgoH n2cIyOVPgof6H5r0w7obyjq3Xvz1qRgYWiwiOV7FG6fTzDrZFTCCHEJ9dCfAUOqR+gOT qu9kmX6fWiDNl0XBCp0/8T9oQo8NZP99TDflgaz3MJNil65zpE6XfiJeqt00ClIJ+uW+ Am/g5YtLW8czY8wQPurotE1+2m/UbF+9Kw0o1txOEsT8CyjUKCFjbbm2/m5bKScjBDKH bavF4cw1QoBIpjjGx0UAStwTxtnMzQVpVuz/n7wTldem7vq00k9dNzBIPNcan0qAyo3p iMFg== X-Gm-Message-State: AOJu0YxtvPMpGDxK7W+W9s8JR7vqa2F7YkQzOQkE2tdVp+yWQ5p61fbU uvOZtjq6+g8SoOsF6oL0kBLad7bkbnzNigkf+38= X-Google-Smtp-Source: AGHT+IF/GIOD1aNT2KJGZKLZC7WXujy3118AIqpzRDB/TUcqh33pIGEpQVGht2NsS0z66fQAkSIvtg== X-Received: by 2002:a05:6358:7f0e:b0:168:e4c1:eb9c with SMTP id p14-20020a0563587f0e00b00168e4c1eb9cmr8296887rwn.20.1698522328145; Sat, 28 Oct 2023 12:45:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 04/35] tcg/optimize: Do swap_commutative2 in do_constant_folding_cond2 Date: Sat, 28 Oct 2023 12:44:51 -0700 Message-Id: <20231028194522.245170-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::c29; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc29.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522495803100005 Content-Type: text/plain; charset="utf-8" Mirror the new do_constant_folding_cond1 by doing all argument and condition adjustment within one helper. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/optimize.c | 107 ++++++++++++++++++++++++++----------------------- 1 file changed, 57 insertions(+), 50 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 89cc794d24..76be0fc337 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -589,43 +589,6 @@ static int do_constant_folding_cond(TCGType type, TCGA= rg x, return -1; } =20 -/* - * Return -1 if the condition can't be simplified, - * and the result of the condition (0 or 1) if it can. - */ -static int do_constant_folding_cond2(TCGArg *p1, TCGArg *p2, TCGCond c) -{ - TCGArg al =3D p1[0], ah =3D p1[1]; - TCGArg bl =3D p2[0], bh =3D p2[1]; - - if (arg_is_const(bl) && arg_is_const(bh)) { - tcg_target_ulong blv =3D arg_info(bl)->val; - tcg_target_ulong bhv =3D arg_info(bh)->val; - uint64_t b =3D deposit64(blv, 32, 32, bhv); - - if (arg_is_const(al) && arg_is_const(ah)) { - tcg_target_ulong alv =3D arg_info(al)->val; - tcg_target_ulong ahv =3D arg_info(ah)->val; - uint64_t a =3D deposit64(alv, 32, 32, ahv); - return do_constant_folding_cond_64(a, b, c); - } - if (b =3D=3D 0) { - switch (c) { - case TCG_COND_LTU: - return 0; - case TCG_COND_GEU: - return 1; - default: - break; - } - } - } - if (args_are_copies(al, bl) && args_are_copies(ah, bh)) { - return do_constant_folding_cond_eq(c); - } - return -1; -} - /** * swap_commutative: * @dest: TCGArg of the destination argument, or NO_DEST. @@ -672,6 +635,10 @@ static bool swap_commutative2(TCGArg *p1, TCGArg *p2) return false; } =20 +/* + * Return -1 if the condition can't be simplified, + * and the result of the condition (0 or 1) if it can. + */ static int do_constant_folding_cond1(OptContext *ctx, TCGArg dest, TCGArg *p1, TCGArg *p2, TCGArg *pcond) { @@ -689,6 +656,51 @@ static int do_constant_folding_cond1(OptContext *ctx, = TCGArg dest, return r; } =20 +static int do_constant_folding_cond2(OptContext *ctx, TCGArg *args) +{ + TCGArg al, ah, bl, bh; + TCGCond c; + bool swap; + + swap =3D swap_commutative2(args, args + 2); + c =3D args[4]; + if (swap) { + args[4] =3D c =3D tcg_swap_cond(c); + } + + al =3D args[0]; + ah =3D args[1]; + bl =3D args[2]; + bh =3D args[3]; + + if (arg_is_const(bl) && arg_is_const(bh)) { + tcg_target_ulong blv =3D arg_info(bl)->val; + tcg_target_ulong bhv =3D arg_info(bh)->val; + uint64_t b =3D deposit64(blv, 32, 32, bhv); + + if (arg_is_const(al) && arg_is_const(ah)) { + tcg_target_ulong alv =3D arg_info(al)->val; + tcg_target_ulong ahv =3D arg_info(ah)->val; + uint64_t a =3D deposit64(alv, 32, 32, ahv); + return do_constant_folding_cond_64(a, b, c); + } + if (b =3D=3D 0) { + switch (c) { + case TCG_COND_LTU: + return 0; + case TCG_COND_GEU: + return 1; + default: + break; + } + } + } + if (args_are_copies(al, bl) && args_are_copies(ah, bh)) { + return do_constant_folding_cond_eq(c); + } + return -1; +} + static void init_arguments(OptContext *ctx, TCGOp *op, int nb_args) { for (int i =3D 0; i < nb_args; i++) { @@ -1085,15 +1097,13 @@ static bool fold_brcond(OptContext *ctx, TCGOp *op) =20 static bool fold_brcond2(OptContext *ctx, TCGOp *op) { - TCGCond cond =3D op->args[4]; - TCGArg label =3D op->args[5]; + TCGCond cond; + TCGArg label; int i, inv =3D 0; =20 - if (swap_commutative2(&op->args[0], &op->args[2])) { - op->args[4] =3D cond =3D tcg_swap_cond(cond); - } - - i =3D do_constant_folding_cond2(&op->args[0], &op->args[2], cond); + i =3D do_constant_folding_cond2(ctx, &op->args[0]); + cond =3D op->args[4]; + label =3D op->args[5]; if (i >=3D 0) { goto do_brcond_const; } @@ -1841,14 +1851,11 @@ static bool fold_negsetcond(OptContext *ctx, TCGOp = *op) =20 static bool fold_setcond2(OptContext *ctx, TCGOp *op) { - TCGCond cond =3D op->args[5]; + TCGCond cond; int i, inv =3D 0; =20 - if (swap_commutative2(&op->args[1], &op->args[3])) { - op->args[5] =3D cond =3D tcg_swap_cond(cond); - } - - i =3D do_constant_folding_cond2(&op->args[1], &op->args[3], cond); + i =3D do_constant_folding_cond2(ctx, &op->args[1]); + cond =3D op->args[5]; if (i >=3D 0) { goto do_setcond_const; } --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522435; cv=none; d=zohomail.com; s=zohoarc; b=I4sMAyLSKWmYMuoKdAvFxewEuAe/8dKsdpzFsRl3cu2mLDn8ckg8SNV7MLwmfFGRaO1bGb4qusijXONFLhpc3aWR/sKt7yhkqzgD85Qbkw+6s2JTh7Lpjmrq0vhUHidW7zpt5M5qclSZYdn8C4yAuYkshqPF6AJtzRyrjm+DVl0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522435; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=D1jMbpp1weXZkSHBUh0Jn0kijypmzVFb4f/5Y0tU+kg=; b=jmYtdjmD3Y/+G4cIAuCkDbWsfYqoXsgkO1o+Om2FewUQXZNvY/8U6NY9CD0/EKo8b3aLqVMzcX3YYOsZgtBxjEYQGvvD+fA1j5KGFoobLf+q2f6jgzfaUtlsNSYhlSf25xTryeyuSHtcSCC2MBpL7d47DHCOizTSuB0rEtwipp4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522435404897.9826784431829; Sat, 28 Oct 2023 12:47:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpFW-0004iG-Aq; Sat, 28 Oct 2023 15:45:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFV-0004hp-52 for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:33 -0400 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 1qwpFS-00046J-FW for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:32 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1c77449a6daso27557555ad.0 for ; Sat, 28 Oct 2023 12:45:30 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522329; x=1699127129; 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=D1jMbpp1weXZkSHBUh0Jn0kijypmzVFb4f/5Y0tU+kg=; b=B+qqh9KzbJAmk7ijJi0JUQ0IY60X79ZG6rtnWdP6+1BXP8I4N4M+6SuympYvucNc96 NoR+VnZS2ISjSmhQ9D6NMaQ2ey1gZTRH6kMibpaj9/s8rLFzjOcY5zVZrT1Wjd0ZSD4C hKrjRSkwCEjVrq4TgMWPxB6NNmeM7wNh1lwfHHoUndBGH1FU6QFB8nZWvFteQifCxpdh qx0ixuAHHi1M0vHp4bhdbe3Rd6lTagwDVdvbkgNRIqaTsyo6251ND8uDCXksrE/4coiO LUOqL9g3jBgyC9n11/rIreWow0emxLI4T6uO4J4i2tcTnm7Xl+z7NdKzUVJb+GVzXNex DJlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522329; x=1699127129; 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=D1jMbpp1weXZkSHBUh0Jn0kijypmzVFb4f/5Y0tU+kg=; b=pX/sRnD62rO9RISneRazu6vWnojWzCnJNem9+t2oryn6dqIm/aVDNOEMk8vb1cpbsN ySBAk/VGxuYvFlVsmdh74UOz9650Ht1n16yWD3CtF3R0jQKliB38VK9TKbVbB0p4kTTS RFtSgk50hFbWRHTCjRIII859qBGqFrekKFy27yzBXQUPGbEFzHLJdSCYMId7ZgDjg8k0 l9DyjXQvsIuRK7AgWG0fxTQZI59BCBjYHEsGq244X+Yhx58913KvVY6Er8Mk8ljE4GC4 qsXzwXQNOgbyNZUTEPty3IcTF4gMuzAcFSzhvawHWMzZH5GuQ/rEuqiljgUwVbTqSvCQ 4xLg== X-Gm-Message-State: AOJu0YyFMVNnqf31PEaQ6UR+xp3lS8iZO20jD5zXpappv6HIIxL/6ZhT GD3XpYA26ZA9EMAeArGJ/l8WtblG3OAcnCkHb6o= X-Google-Smtp-Source: AGHT+IG8p/VYtEuYXEqfyf92qLk1u3ilKXfNk1bocvUmbDg/qP5JSDhh3w71/U6oHYh+e/blNmVl1w== X-Received: by 2002:a17:902:ce84:b0:1c2:218c:3754 with SMTP id f4-20020a170902ce8400b001c2218c3754mr7209083plg.53.1698522329018; Sat, 28 Oct 2023 12:45:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 05/35] tcg/optimize: Split out arg_new_constant Date: Sat, 28 Oct 2023 12:44:52 -0700 Message-Id: <20231028194522.245170-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522436398100003 Content-Type: text/plain; charset="utf-8" Fixes a bug wherein raw uses of tcg_constant_internal do not have their TempOptInfo initialized. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/optimize.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 76be0fc337..2f2d1c3001 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -237,6 +237,21 @@ static bool args_are_copies(TCGArg arg1, TCGArg arg2) return ts_are_copies(arg_temp(arg1), arg_temp(arg2)); } =20 +static TCGArg arg_new_constant(OptContext *ctx, uint64_t val) +{ + TCGType type =3D ctx->type; + TCGTemp *ts; + + if (type =3D=3D TCG_TYPE_I32) { + val =3D (int32_t)val; + } + + ts =3D tcg_constant_internal(type, val); + init_ts_info(ctx, ts); + + return temp_arg(ts); +} + static bool tcg_opt_gen_mov(OptContext *ctx, TCGOp *op, TCGArg dst, TCGArg= src) { TCGTemp *dst_ts =3D arg_temp(dst); @@ -293,16 +308,8 @@ static bool tcg_opt_gen_mov(OptContext *ctx, TCGOp *op= , TCGArg dst, TCGArg src) static bool tcg_opt_gen_movi(OptContext *ctx, TCGOp *op, TCGArg dst, uint64_t val) { - TCGTemp *tv; - - if (ctx->type =3D=3D TCG_TYPE_I32) { - val =3D (int32_t)val; - } - /* Convert movi to mov with constant temp. */ - tv =3D tcg_constant_internal(ctx->type, val); - init_ts_info(ctx, tv); - return tcg_opt_gen_mov(ctx, op, dst, temp_arg(tv)); + return tcg_opt_gen_mov(ctx, op, dst, arg_new_constant(ctx, val)); } =20 static uint64_t do_constant_folding_2(TCGOpcode op, uint64_t x, uint64_t y) @@ -1340,7 +1347,7 @@ static bool fold_deposit(OptContext *ctx, TCGOp *op) =20 op->opc =3D and_opc; op->args[1] =3D op->args[2]; - op->args[2] =3D temp_arg(tcg_constant_internal(ctx->type, mask)); + op->args[2] =3D arg_new_constant(ctx, mask); ctx->z_mask =3D mask & arg_info(op->args[1])->z_mask; return false; } @@ -1350,7 +1357,7 @@ static bool fold_deposit(OptContext *ctx, TCGOp *op) uint64_t mask =3D deposit64(-1, op->args[3], op->args[4], 0); =20 op->opc =3D and_opc; - op->args[2] =3D temp_arg(tcg_constant_internal(ctx->type, mask)); + op->args[2] =3D arg_new_constant(ctx, mask); ctx->z_mask =3D mask & arg_info(op->args[1])->z_mask; return false; } --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522453; cv=none; d=zohomail.com; s=zohoarc; b=W7lAYJAscBvPdLexCO2tBnHIeUv86n7bMqAmL2NJ1UAZKd1Xk9VgOkk942Zds/zZmf2Uc4L4+ixGqINBhPVrswmYnTWqHneZZEA0rXcfSOzKJiHQ8rhsPUyNP1YtSi0THQ+Ikqe2MtyfPncSolI85nQWZ9NPgNYsR+DrTh2jnoY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522453; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=k5lsHDsasK4zIrruyQZlXl4wlS973HJoMzMc8iwOmM4=; b=nLfStLCc2Jla4w9IGgK2RynpcM2uf8dcKArSCwsZdnYa4pi+CZ4CegesMpyZ1wbLGKYRvDDE0jmMSkdKt91JcD9hF2Z4HSEVO1GxBcJGVNCQnCiP29DoftUJoLCnl+1thvOvbkfrypLmrYwDEoYkwaQH/CuKGpHOD9/suvS5tNc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522453582803.0534305164147; Sat, 28 Oct 2023 12:47:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpFr-0004nz-PD; Sat, 28 Oct 2023 15:45:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFX-0004ie-J7 for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:35 -0400 Received: from mail-io1-xd30.google.com ([2607:f8b0:4864:20::d30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFU-00046S-Ir for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:35 -0400 Received: by mail-io1-xd30.google.com with SMTP id ca18e2360f4ac-7a68b87b265so97169139f.2 for ; Sat, 28 Oct 2023 12:45:32 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522330; x=1699127130; 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=k5lsHDsasK4zIrruyQZlXl4wlS973HJoMzMc8iwOmM4=; b=yzpQrP4wpnU9pgkOoqER6fXyN3hbtTHTtczyGf/R0X/XF4KWYJo8y1QeJPm92d4F/8 oGcspEW9Q9MKqPW/6EGG8u1MgJqaw/GIlvCtaN3CM0HNyDewVYJoSDZidmbpPfNJIGMb sfU1vgB6J66ToQGnXVfFJRwNxcICTc+rpxJxhZ0rc1UoAvTIITgUP6eT4H2Wqh4OVjlb T7j1ZDoHTodeS0FrUwjnKizgkoIhO7kqiUaEe4sFLFwy2HQbA32m/gyNsOr2h4BU68ry ZaTrOPJIj/z8ShXI03lp/1Z5I5xYT3wD5HLOsXCFSpxMV+mYt83F6x0q41W/Md+COocT 6meA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522330; x=1699127130; 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=k5lsHDsasK4zIrruyQZlXl4wlS973HJoMzMc8iwOmM4=; b=sAegQKBwVxcXkAaldvoPK+MH8tLUpR+6/NBM8O3qFsDB7K5RapVbkMTo3XkBIpXhln wy2Xg1ASxxYJ6/UUpyQo/GQ+3pejqS5i520an3KcLK+33MRVFVYNcBTE+uFKQI+LGHEZ a+RPdC1BPna25TFQoTrnMooSYh+NCKdg33dAYovxnccUrKFomnnDLUZozUoux/PySRu3 OBhHwnldcNgUvqw9hm/PMIXyv7Bjjmd9Q204rxCkiY6Aydb33NWUPVmt4M9POKeC5lMV n5BYfG7ckV66YX83ozK8vB3u1522ngUnSJzQiKqCSbdl0fI0/DL7azg/iWcvgWJTW4Ha GjIQ== X-Gm-Message-State: AOJu0YxTXjp5wdkV1wDwwtQCaOT7FdwoUw6MFWfqruyEHHQRNVQuZ/s+ vTZeNc8tLciVPSSGkLMP4eEs3MqthrqQH2cTXaM= X-Google-Smtp-Source: AGHT+IGY/WpQVHw0Ya+CVSbs96C4B7wXcWmYdOdGNhUu6oTyE3DXpwSwQanwZFdg/Cl9Hm/wZcagGg== X-Received: by 2002:a05:6e02:1be7:b0:357:a25a:572a with SMTP id y7-20020a056e021be700b00357a25a572amr9930623ilv.21.1698522330043; Sat, 28 Oct 2023 12:45:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 06/35] tcg/optimize: Handle TCG_COND_TST{EQ,NE} Date: Sat, 28 Oct 2023 12:44:53 -0700 Message-Id: <20231028194522.245170-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::d30; envelope-from=richard.henderson@linaro.org; helo=mail-io1-xd30.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522454790100003 Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/optimize.c | 245 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 223 insertions(+), 22 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 2f2d1c3001..891c28acef 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -508,9 +508,15 @@ static bool do_constant_folding_cond_32(uint32_t x, ui= nt32_t y, TCGCond c) return x <=3D y; case TCG_COND_GTU: return x > y; - default: - g_assert_not_reached(); + case TCG_COND_TSTEQ: + return (x & y) =3D=3D 0; + case TCG_COND_TSTNE: + return (x & y) !=3D 0; + case TCG_COND_ALWAYS: + case TCG_COND_NEVER: + break; } + g_assert_not_reached(); } =20 static bool do_constant_folding_cond_64(uint64_t x, uint64_t y, TCGCond c) @@ -536,12 +542,18 @@ static bool do_constant_folding_cond_64(uint64_t x, u= int64_t y, TCGCond c) return x <=3D y; case TCG_COND_GTU: return x > y; - default: - g_assert_not_reached(); + case TCG_COND_TSTEQ: + return (x & y) =3D=3D 0; + case TCG_COND_TSTNE: + return (x & y) !=3D 0; + case TCG_COND_ALWAYS: + case TCG_COND_NEVER: + break; } + g_assert_not_reached(); } =20 -static bool do_constant_folding_cond_eq(TCGCond c) +static int do_constant_folding_cond_eq(TCGCond c) { switch (c) { case TCG_COND_GT: @@ -556,9 +568,14 @@ static bool do_constant_folding_cond_eq(TCGCond c) case TCG_COND_LEU: case TCG_COND_EQ: return 1; - default: - g_assert_not_reached(); + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + return -1; + case TCG_COND_ALWAYS: + case TCG_COND_NEVER: + break; } + g_assert_not_reached(); } =20 /* @@ -586,8 +603,10 @@ static int do_constant_folding_cond(TCGType type, TCGA= rg x, } else if (arg_is_const_val(y, 0)) { switch (c) { case TCG_COND_LTU: + case TCG_COND_TSTNE: return 0; case TCG_COND_GEU: + case TCG_COND_TSTEQ: return 1; default: return -1; @@ -660,7 +679,30 @@ static int do_constant_folding_cond1(OptContext *ctx, = TCGArg dest, } =20 r =3D do_constant_folding_cond(ctx->type, *p1, *p2, cond); - return r; + if (r >=3D 0) { + return r; + } + if (!is_tst_cond(cond)) { + return -1; + } + + /* + * TSTNE x,x -> NE x,0 + * TSTNE x,-1 -> NE x,0 + */ + if (args_are_copies(*p1, *p2) || arg_is_const_val(*p2, -1)) { + *p2 =3D arg_new_constant(ctx, 0); + *pcond =3D tcg_tst_eqne_cond(cond); + return -1; + } + + /* TSTNE x,sign -> LT x,0 */ + if (arg_is_const_val(*p2, (ctx->type =3D=3D TCG_TYPE_I32 + ? INT32_MIN : INT64_MIN))) { + *p2 =3D arg_new_constant(ctx, 0); + *pcond =3D tcg_tst_ltge_cond(cond); + } + return -1; } =20 static int do_constant_folding_cond2(OptContext *ctx, TCGArg *args) @@ -668,6 +710,7 @@ static int do_constant_folding_cond2(OptContext *ctx, T= CGArg *args) TCGArg al, ah, bl, bh; TCGCond c; bool swap; + int r; =20 swap =3D swap_commutative2(args, args + 2); c =3D args[4]; @@ -689,21 +732,54 @@ static int do_constant_folding_cond2(OptContext *ctx,= TCGArg *args) tcg_target_ulong alv =3D arg_info(al)->val; tcg_target_ulong ahv =3D arg_info(ah)->val; uint64_t a =3D deposit64(alv, 32, 32, ahv); - return do_constant_folding_cond_64(a, b, c); + + r =3D do_constant_folding_cond_64(a, b, c); + if (r >=3D 0) { + return r; + } } + if (b =3D=3D 0) { switch (c) { case TCG_COND_LTU: + case TCG_COND_TSTNE: return 0; case TCG_COND_GEU: + case TCG_COND_TSTEQ: return 1; default: break; } } + + /* TSTNE x,-1 -> NE x,0 */ + if (b =3D=3D -1 && is_tst_cond(c)) { + args[3] =3D args[2] =3D arg_new_constant(ctx, 0); + args[4] =3D tcg_tst_eqne_cond(c); + return -1; + } + + /* TSTNE x,sign -> LT x,0 */ + if (b =3D=3D INT64_MIN && is_tst_cond(c)) { + /* bl must be 0, so copy that to bh */ + args[3] =3D bl; + args[4] =3D tcg_tst_ltge_cond(c); + return -1; + } } + if (args_are_copies(al, bl) && args_are_copies(ah, bh)) { - return do_constant_folding_cond_eq(c); + r =3D do_constant_folding_cond_eq(c); + if (r >=3D 0) { + return r; + } + + /* TSTNE x,x -> NE x,0 */ + if (is_tst_cond(c)) { + args[3] =3D args[2] =3D arg_new_constant(ctx, 0); + args[4] =3D tcg_tst_eqne_cond(c); + return -1; + } } return -1; } @@ -1151,24 +1227,37 @@ static bool fold_brcond2(OptContext *ctx, TCGOp *op) case 0: goto do_brcond_const; case 1: - op->opc =3D INDEX_op_brcond_i32; - op->args[1] =3D op->args[2]; - op->args[2] =3D cond; - op->args[3] =3D label; - break; + goto do_brcond_low; + } + break; + + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + if (arg_is_const_val(op->args[2], 0)) { + goto do_brcond_high; + } + if (arg_is_const_val(op->args[3], 0)) { + goto do_brcond_low; } break; =20 default: break; =20 + do_brcond_low: + op->opc =3D INDEX_op_brcond_i32; + op->args[1] =3D op->args[2]; + op->args[2] =3D cond; + op->args[3] =3D label; + return fold_brcond(ctx, op); + do_brcond_high: op->opc =3D INDEX_op_brcond_i32; op->args[0] =3D op->args[1]; op->args[1] =3D op->args[3]; op->args[2] =3D cond; op->args[3] =3D label; - break; + return fold_brcond(ctx, op); =20 do_brcond_const: if (i =3D=3D 0) { @@ -1829,6 +1918,104 @@ static bool fold_remainder(OptContext *ctx, TCGOp *= op) return false; } =20 +static void fold_setcond_tst_pow2(OptContext *ctx, TCGOp *op, bool neg) +{ + TCGOpcode and_opc, sub_opc, xor_opc, neg_opc, shr_opc, uext_opc, sext_= opc; + TCGCond cond =3D op->args[3]; + TCGArg ret, src1, src2; + TCGOp *op2; + uint64_t val; + int sh; + bool inv; + + if (!is_tst_cond(cond) || !arg_is_const(op->args[2])) { + return; + } + + src2 =3D op->args[2]; + val =3D arg_info(src2)->val; + if (!is_power_of_2(val)) { + return; + } + sh =3D ctz64(val); + + switch (ctx->type) { + case TCG_TYPE_I32: + and_opc =3D INDEX_op_and_i32; + sub_opc =3D INDEX_op_sub_i32; + xor_opc =3D INDEX_op_xor_i32; + shr_opc =3D INDEX_op_shr_i32; + neg_opc =3D TCG_TARGET_HAS_neg_i32 ? INDEX_op_neg_i32 : 0; + if (TCG_TARGET_extract_i32_valid(sh, 1)) { + uext_opc =3D TCG_TARGET_HAS_extract_i32 ? INDEX_op_extract_i32= : 0; + sext_opc =3D TCG_TARGET_HAS_sextract_i32 ? INDEX_op_sextract_i= 32 : 0; + } + break; + case TCG_TYPE_I64: + and_opc =3D INDEX_op_and_i64; + sub_opc =3D INDEX_op_sub_i64; + xor_opc =3D INDEX_op_xor_i64; + shr_opc =3D INDEX_op_shr_i64; + neg_opc =3D TCG_TARGET_HAS_neg_i64 ? INDEX_op_neg_i64 : 0; + if (TCG_TARGET_extract_i64_valid(sh, 1)) { + uext_opc =3D TCG_TARGET_HAS_extract_i64 ? INDEX_op_extract_i64= : 0; + sext_opc =3D TCG_TARGET_HAS_sextract_i64 ? INDEX_op_sextract_i= 64 : 0; + } + break; + default: + g_assert_not_reached(); + } + + ret =3D op->args[0]; + src1 =3D op->args[1]; + inv =3D cond =3D=3D TCG_COND_TSTEQ; + + if (sh && sext_opc && neg && !inv) { + op->opc =3D sext_opc; + op->args[1] =3D src1; + op->args[2] =3D sh; + op->args[3] =3D 1; + return; + } else if (sh && uext_opc) { + op->opc =3D uext_opc; + op->args[1] =3D src1; + op->args[2] =3D sh; + op->args[3] =3D 1; + } else { + if (sh) { + op2 =3D tcg_op_insert_before(ctx->tcg, op, shr_opc, 3); + op2->args[0] =3D ret; + op2->args[1] =3D src1; + op2->args[2] =3D arg_new_constant(ctx, sh); + src1 =3D ret; + } + op->opc =3D and_opc; + op->args[1] =3D src1; + op->args[2] =3D arg_new_constant(ctx, 1); + } + + if (neg && inv) { + op2 =3D tcg_op_insert_after(ctx->tcg, op, sub_opc, 3); + op2->args[0] =3D ret; + op2->args[1] =3D ret; + op2->args[2] =3D arg_new_constant(ctx, 1); + } else if (inv) { + op2 =3D tcg_op_insert_after(ctx->tcg, op, xor_opc, 3); + op2->args[0] =3D ret; + op2->args[1] =3D ret; + op2->args[2] =3D arg_new_constant(ctx, 1); + } else if (neg && neg_opc) { + op2 =3D tcg_op_insert_after(ctx->tcg, op, neg_opc, 2); + op2->args[0] =3D ret; + op2->args[1] =3D ret; + } else if (neg) { + op2 =3D tcg_op_insert_after(ctx->tcg, op, sub_opc, 3); + op2->args[0] =3D ret; + op2->args[1] =3D arg_new_constant(ctx, 0); + op2->args[2] =3D ret; + } +} + static bool fold_setcond(OptContext *ctx, TCGOp *op) { int i =3D do_constant_folding_cond1(ctx, op->args[0], &op->args[1], @@ -1836,6 +2023,7 @@ static bool fold_setcond(OptContext *ctx, TCGOp *op) if (i >=3D 0) { return tcg_opt_gen_movi(ctx, op, op->args[0], i); } + fold_setcond_tst_pow2(ctx, op, false); =20 ctx->z_mask =3D 1; ctx->s_mask =3D smask_from_zmask(1); @@ -1849,13 +2037,13 @@ static bool fold_negsetcond(OptContext *ctx, TCGOp = *op) if (i >=3D 0) { return tcg_opt_gen_movi(ctx, op, op->args[0], -i); } + fold_setcond_tst_pow2(ctx, op, true); =20 /* Value is {0,-1} so all bits are repetitions of the sign. */ ctx->s_mask =3D -1; return false; } =20 - static bool fold_setcond2(OptContext *ctx, TCGOp *op) { TCGCond cond; @@ -1903,22 +2091,35 @@ static bool fold_setcond2(OptContext *ctx, TCGOp *o= p) case 0: goto do_setcond_const; case 1: - op->args[2] =3D op->args[3]; - op->args[3] =3D cond; - op->opc =3D INDEX_op_setcond_i32; - break; + goto do_setcond_low; + } + break; + + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + if (arg_is_const_val(op->args[2], 0)) { + goto do_setcond_high; + } + if (arg_is_const_val(op->args[4], 0)) { + goto do_setcond_low; } break; =20 default: break; =20 + do_setcond_low: + op->args[2] =3D op->args[3]; + op->args[3] =3D cond; + op->opc =3D INDEX_op_setcond_i32; + return fold_setcond(ctx, op); + do_setcond_high: op->args[1] =3D op->args[2]; op->args[2] =3D op->args[4]; op->args[3] =3D cond; op->opc =3D INDEX_op_setcond_i32; - break; + return fold_setcond(ctx, op); } =20 ctx->z_mask =3D 1; --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522389; cv=none; d=zohomail.com; s=zohoarc; b=QQAmDI7UIxH+9cWN4us1qWoRNAI2SiCstSrsQlJhas/MbM/BytrFRBL474HqU3G3p5wQDnNoF3nCsi2t4oOE++1wacPp+WlgkwxIb8W53jaDVM+J+2x3/XTCLQ0qUpdFqj/JZtl6QDVr6mYnD+nbG5xlbgLk4Vzj1bfrKZo0wXw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522389; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SCkSZfcN8VkWWjgSJsiqANAyZlfoh+Pc4PDDAjEe7LU=; b=AyrGpMrAUbQCNRAbelhNwgTM0a6yXUCoBwyZTVtA9CSKCqTa+723HLcOz3a4NaLXhnN1xeyhbNezLWjOylz1FOXf/4sm777CkSisIAaGc+UTRQa+aqOV+JuN05CX3buOvjWhrqbKNHgwJUz42w/b/eTEnabNjONcGHJWWuRRyTE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522389564205.5873785437285; Sat, 28 Oct 2023 12:46:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpFa-0004jG-Nn; Sat, 28 Oct 2023 15:45:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFW-0004iH-N8 for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:34 -0400 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 1qwpFU-00046b-OI for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:34 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1c5cd27b1acso28590415ad.2 for ; Sat, 28 Oct 2023 12:45:32 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522331; x=1699127131; 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=SCkSZfcN8VkWWjgSJsiqANAyZlfoh+Pc4PDDAjEe7LU=; b=L7qiQeQKD54f0wf6gGaDyDzLccfvqm69M2ZA8zfVWy75yte4j6SLNrsJ7tInamOagm wfWYsXXwISYramCFYFbtxeRp2MvSllzYy8QUpsOpRpfXWhwg5XNOOSGcYieXJNH6G/ns 0qLtJvVaeP+bWKUI6tT9LW2D1mFr567HpQSJYK1vtrvuZsiftOgzPqyZqbRAhCfB+P6z U81MKbSoVGEgbV8ADp687MijPE0eGZmaTnxqeeeneSBmqZ7cLHYZayOt+pEuOWfyIyOd mYl+b5Dm1ygfrT+FSsovrTPJ+pzE2YjlV0dS2M2uwxNn7kCmB6OtSwExjSRLjAmsZ03+ AjZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522331; x=1699127131; 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=SCkSZfcN8VkWWjgSJsiqANAyZlfoh+Pc4PDDAjEe7LU=; b=NicIIQXD0OhZ9KXQQH7HowEmkofu6EVCPhY5l3r2kT/DudE39KSDtbjka3/64UHd0X iG/B1txZTUESDeAhlgmFxOt2kwjmNnWhOpExMBmyaS4DIW9AoWcYPvQDobhGy5q8h4Rd SP6ZoOcIuKNKRP+857aEe6jXbLEmr/qOr8b2GZ/WIOBtaGjbqdiecdygIpi+WtQYRFHz cgBq+F2/wRkFhsWRzK2ZV2pBsM5uFJEzr4Xd/nhirB55sFgsiKWvFa2i3x2mpAkHSqcy Ho3hz+0QDuvs5sLwpYWN274huGT/4LKf9FYmXgtaSmJDagVu9qSoRXHzV+nqMnMtU8C7 4CIA== X-Gm-Message-State: AOJu0YyLzn/etCInJwKvYeKVBM0LRKYLKO7kq/JZdvbQrBmGyRzA8vlX ROnwC46QnqFU8jUJdUnl2nQh4vyzrwjydahfaZo= X-Google-Smtp-Source: AGHT+IFa0HONHNNMETJJtBLKRvgh9gZAfqFCxE9RoKKCyxsrV0d/Sk2Fs4Cp7GCexd3+c2U2XQXH2Q== X-Received: by 2002:a17:903:60e:b0:1bb:c06e:647a with SMTP id kg14-20020a170903060e00b001bbc06e647amr5469819plb.53.1698522330916; Sat, 28 Oct 2023 12:45:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 07/35] tcg: Add TCGConst argument to tcg_target_const_match Date: Sat, 28 Oct 2023 12:44:54 -0700 Message-Id: <20231028194522.245170-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522390094100005 Content-Type: text/plain; charset="utf-8" Fill the new argument from any condition within the opcode. Not yet used within any backend. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 57d0583fe7..58b431b579 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -173,7 +173,8 @@ static bool tcg_out_sti(TCGContext *s, TCGType type, TC= GArg val, static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target, const TCGHelperInfo *info); static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot); -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int = vece); +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece); #ifdef TCG_TARGET_NEED_LDST_LABELS static int tcg_out_ldst_finalize(TCGContext *s); #endif @@ -4680,6 +4681,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCG= Op *op) TCGTemp *ts; TCGArg new_args[TCG_MAX_OP_ARGS]; int const_args[TCG_MAX_OP_ARGS]; + TCGCond op_cond; =20 nb_oargs =3D def->nb_oargs; nb_iargs =3D def->nb_iargs; @@ -4692,6 +4694,33 @@ static void tcg_reg_alloc_op(TCGContext *s, const TC= GOp *op) i_allocated_regs =3D s->reserved_regs; o_allocated_regs =3D s->reserved_regs; =20 + switch (op->opc) { + case INDEX_op_brcond_i32: + case INDEX_op_brcond_i64: + op_cond =3D op->args[2]; + break; + case INDEX_op_setcond_i32: + case INDEX_op_setcond_i64: + case INDEX_op_negsetcond_i32: + case INDEX_op_negsetcond_i64: + case INDEX_op_cmp_vec: + op_cond =3D op->args[3]; + break; + case INDEX_op_brcond2_i32: + op_cond =3D op->args[4]; + break; + case INDEX_op_movcond_i32: + case INDEX_op_movcond_i64: + case INDEX_op_setcond2_i32: + case INDEX_op_cmpsel_vec: + op_cond =3D op->args[5]; + break; + default: + /* No condition within opcode. */ + op_cond =3D TCG_COND_ALWAYS; + break; + } + /* satisfy input constraints */ for (k =3D 0; k < nb_iargs; k++) { TCGRegSet i_preferred_regs, i_required_regs; @@ -4705,7 +4734,8 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCG= Op *op) ts =3D arg_temp(arg); =20 if (ts->val_type =3D=3D TEMP_VAL_CONST - && tcg_target_const_match(ts->val, ts->type, arg_ct->ct, TCGOP= _VECE(op))) { + && tcg_target_const_match(ts->val, arg_ct->ct, ts->type, + op_cond, TCGOP_VECE(op))) { /* constant is OK for instruction */ const_args[i] =3D 1; new_args[i] =3D ts->val; diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index a3efa1e67a..420e4a35ea 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -270,7 +270,8 @@ static bool is_shimm1632(uint32_t v32, int *cmode, int = *imm8) } } =20 -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int = vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index fc78566494..0c29a3929b 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -501,7 +501,8 @@ static bool is_shimm1632(uint32_t v32, int *cmode, int = *imm8) * mov operand2: values represented with x << (2 * y), x < 0x100 * add, sub, eor...: ditto */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int = vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index a83f8aab30..eeb23d3fca 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -195,7 +195,8 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int ty= pe, } =20 /* test if a constant matches the constraint */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int = vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.= c.inc index ccf133db4b..384d2ba342 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -185,7 +185,8 @@ static inline tcg_target_long sextreg(tcg_target_long v= al, int pos, int len) } =20 /* test if a constant matches the constraint */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int = vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return true; diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 328984ccff..35eff82bb3 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -188,7 +188,8 @@ static bool is_p2m1(tcg_target_long val) } =20 /* test if a constant matches the constraint */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int = vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 856c3b18f5..a5871f55b1 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -282,7 +282,8 @@ static bool reloc_pc34(tcg_insn_unit *src_rw, const tcg= _insn_unit *target) } =20 /* test if a constant matches the constraint */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int = vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 34e10e77d9..639363039b 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -145,7 +145,8 @@ static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKin= d kind, int slot) #define sextreg sextract64 =20 /* test if a constant matches the constraint */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int = vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc index fbee43d3b0..08fe00a392 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -538,7 +538,8 @@ static bool risbg_mask(uint64_t c) } =20 /* Test if a constant matches the constraint. */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int = vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc index 19d9df4a09..386f51f29e 100644 --- a/tcg/sparc64/tcg-target.c.inc +++ b/tcg/sparc64/tcg-target.c.inc @@ -322,7 +322,8 @@ static bool patch_reloc(tcg_insn_unit *src_rw, int type, } =20 /* test if a constant matches the constraint */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int = vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { return 1; diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc index 461f4b47ff..c740864b96 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -913,7 +913,8 @@ static inline bool tcg_out_sti(TCGContext *s, TCGType t= ype, TCGArg val, } =20 /* Test if a constant matches the constraint. */ -static bool tcg_target_const_match(int64_t val, TCGType type, int ct, int = vece) +static bool tcg_target_const_match(int64_t val, int ct, + TCGType type, TCGCond cond, int vece) { return ct & TCG_CT_CONST; } --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522581; cv=none; d=zohomail.com; s=zohoarc; b=Is6jA3bVBmI0QDn6RODs1xk8P05GtPCPRGrFSAG3crXv0/cuNYQYSiXHFhavy3m3eysFNa9FdfZN/gBgpXy3rBNefGkxOmVA4+KNt6yZtDV9K4E772711XQDz2EMLOVkj9uVK+PSRHugMuimAYhHGURxP3dTChFU1Z6ndKXofbM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522581; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/2ygD5i+6wL7HEXCM8bQfaa1hBE0P2O4Q3y82rtx6wg=; b=F+OtUNQR262qbDckgNYXOahfBVfccMNQTeJKwV81WB1UC4eT6wxGekPTEndyKG99B+XaUabXJzw12A7ybre1jNealstycadN6ruRdD36OVXgc8+t7IDxS6OCN65RiOv0UOowBEJRYywYKvwhwaNAY93w3LbTzg8fLhxeKRJipt4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522581944733.865765865136; Sat, 28 Oct 2023 12:49:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpFr-0004mt-5z; Sat, 28 Oct 2023 15:45:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFY-0004io-Bu for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:36 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFW-00046n-47 for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:36 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6b36e1fcee9so2858419b3a.3 for ; Sat, 28 Oct 2023 12:45:33 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522332; x=1699127132; 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=/2ygD5i+6wL7HEXCM8bQfaa1hBE0P2O4Q3y82rtx6wg=; b=b+o1ZD3PVb+N2DIV8T0OYPcD7NS7TDTc4urmEwzlieuedNkGQMAjc1GvG+S7P57lGI a5amVo1oxbgTF9TQo0flFIbpx8ATKezTuX801joUzBtreZaD4SltSe5Tg7mpAUMdiLbH pEG2Sl/2y3AiBtDJmDb4wY9Ac1ZU9CSTzF+x3pI+HHay+LGG+epxZl8K+tFU0kQQmUoP 35RT4qQMy1Kb83UJIrYPR/AS2tAUzhUz3P9bJJbzuGeJendRwt1DeX3vXimcSGhWuzQx M62MhIHpPRoKhV/10f3KLFHDytIR1Kns8Nb+pjZlE3fsIvgQXhMpQvAIjReMFFstL4b4 vtZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522332; x=1699127132; 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=/2ygD5i+6wL7HEXCM8bQfaa1hBE0P2O4Q3y82rtx6wg=; b=Y6aWAPK9fe5wv0Cmt/8YNOpUyYygJ1DQsjXl1I6TisvaiTIBmhgJJwwSNcaggJxSI4 ZUKE9nURCf+f32iJnw1R82KPrOMCP5zJiOmvXsdUMHvpw5rPCCf8xOY136jejbsoay5r /DkEcb2qp53M4QjhU+PRowKeiMad435KyVolrMVQ/YUfY76NlaiD3g4CHH3FEFCeGr99 usUTNezAsXR/62raWok+L1nqBgTBWF9bdAcMfMAPFKXFUm2ntRDXgbgcOg5tyZSY1Vef u8OFfoURLa5TES+DBcKkZmV4oL5+KHnFyjyTkq/GH6WUbMgW/P/UaBzuhlZrviUE9bwf 8VNg== X-Gm-Message-State: AOJu0Ywbcm8Ih7E9jd41hYP2pe/6OxO3Xy4DjmXr6SqChkC5cjNyDYkG g2s9C+Ys4aKBDGnWcQAYnzIDVisE0HuoT/zAQ9g= X-Google-Smtp-Source: AGHT+IEcNy7UIaasPLIk5DlHDbv257Ije2n/izRn/YrUjhQ+6mOuB9MlCSnCJbbjt/ZzvIBfGSU4TQ== X-Received: by 2002:a05:6a20:8e24:b0:17f:f8f3:ea51 with SMTP id y36-20020a056a208e2400b0017ff8f3ea51mr1993364pzj.20.1698522331825; Sat, 28 Oct 2023 12:45:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 08/35] tcg/aarch64: Support TCG_COND_TST{EQ,NE} Date: Sat, 28 Oct 2023 12:44:55 -0700 Message-Id: <20231028194522.245170-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522583601100005 Content-Type: text/plain; charset="utf-8" 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.c.inc | 56 ++++++++++++++++++++++---------- 3 files changed, 43 insertions(+), 19 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.c.inc b/tcg/aarch64/tcg-target.c.inc index 420e4a35ea..70df250c04 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -126,6 +126,7 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int ty= pe, #define TCG_CT_CONST_MONE 0x800 #define TCG_CT_CONST_ORRI 0x1000 #define TCG_CT_CONST_ANDI 0x2000 +#define TCG_CT_CONST_CMP 0x4000 =20 #define ALL_GENERAL_REGS 0xffffffffu #define ALL_VECTOR_REGS 0xffffffff00000000ull @@ -279,6 +280,15 @@ static bool tcg_target_const_match(int64_t val, int ct, if (type =3D=3D TCG_TYPE_I32) { val =3D (int32_t)val; } + + if (ct & TCG_CT_CONST_CMP) { + if (is_tst_cond(cond)) { + ct |=3D TCG_CT_CONST_LIMM; + } else { + ct |=3D TCG_CT_CONST_AIMM; + } + } + if ((ct & TCG_CT_CONST_AIMM) && (is_aimm(val) || is_aimm(-val))) { return 1; } @@ -345,6 +355,9 @@ static const enum aarch64_cond_code tcg_cond_to_aarch64= [] =3D { [TCG_COND_GTU] =3D COND_HI, [TCG_COND_GEU] =3D COND_HS, [TCG_COND_LEU] =3D COND_LS, + /* bit test */ + [TCG_COND_TSTEQ] =3D COND_EQ, + [TCG_COND_TSTNE] =3D COND_NE, }; =20 typedef enum { @@ -1342,19 +1355,26 @@ static inline void tcg_out_dep(TCGContext *s, TCGTy= pe ext, TCGReg rd, tcg_out_bfm(s, ext, rd, rn, a, b); } =20 -static void tcg_out_cmp(TCGContext *s, TCGType ext, TCGReg a, +static void tcg_out_cmp(TCGContext *s, TCGType ext, TCGCond cond, TCGReg a, tcg_target_long b, bool const_b) { - if (const_b) { - /* Using CMP or CMN aliases. */ - if (b >=3D 0) { - tcg_out_insn(s, 3401, SUBSI, ext, TCG_REG_XZR, a, b); + if (is_tst_cond(cond)) { + if (!const_b) { + tcg_out_insn(s, 3510, ANDS, ext, TCG_REG_XZR, a, b); } else { - tcg_out_insn(s, 3401, ADDSI, ext, TCG_REG_XZR, a, -b); + tcg_debug_assert(is_limm(b)); + tcg_out_logicali(s, I3404_ANDSI, 0, TCG_REG_XZR, a, b); } } else { - /* Using CMP alias SUBS wzr, Wn, Wm */ - tcg_out_insn(s, 3502, SUBS, ext, TCG_REG_XZR, a, b); + if (!const_b) { + tcg_out_insn(s, 3502, SUBS, ext, TCG_REG_XZR, a, b); + } else if (b >=3D 0) { + tcg_debug_assert(is_aimm(b)); + tcg_out_insn(s, 3401, SUBSI, ext, TCG_REG_XZR, a, b); + } else { + tcg_debug_assert(is_aimm(-b)); + tcg_out_insn(s, 3401, ADDSI, ext, TCG_REG_XZR, a, -b); + } } } =20 @@ -1402,7 +1422,7 @@ static void tcg_out_brcond(TCGContext *s, TCGType ext= , TCGCond c, TCGArg a, need_cmp =3D false; } else { need_cmp =3D true; - tcg_out_cmp(s, ext, a, b, b_const); + tcg_out_cmp(s, ext, c, a, b, b_const); } =20 if (!l->has_value) { @@ -1575,7 +1595,7 @@ static void tcg_out_cltz(TCGContext *s, TCGType ext, = TCGReg d, } else { AArch64Insn sel =3D I3506_CSEL; =20 - tcg_out_cmp(s, ext, a0, 0, 1); + tcg_out_cmp(s, ext, TCG_COND_NE, a0, 0, 1); tcg_out_insn(s, 3507, CLZ, ext, TCG_REG_TMP0, a1); =20 if (const_b) { @@ -1720,7 +1740,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext= *s, HostAddress *h, addr_adj, compare_mask); =20 /* Perform the address comparison. */ - tcg_out_cmp(s, addr_type, TCG_REG_TMP0, TCG_REG_TMP2, 0); + tcg_out_cmp(s, addr_type, TCG_COND_NE, TCG_REG_TMP0, TCG_REG_TMP2,= 0); =20 /* If not equal, we jump to the slow path. */ ldst->label_ptr[0] =3D s->code_ptr; @@ -2276,7 +2296,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, a2 =3D (int32_t)a2; /* FALLTHRU */ case INDEX_op_setcond_i64: - tcg_out_cmp(s, ext, a1, a2, c2); + tcg_out_cmp(s, ext, args[3], a1, a2, c2); /* Use CSET alias of CSINC Wd, WZR, WZR, invert(cond). */ tcg_out_insn(s, 3506, CSINC, TCG_TYPE_I32, a0, TCG_REG_XZR, TCG_REG_XZR, tcg_invert_cond(args[3])); @@ -2286,7 +2306,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, a2 =3D (int32_t)a2; /* FALLTHRU */ case INDEX_op_negsetcond_i64: - tcg_out_cmp(s, ext, a1, a2, c2); + tcg_out_cmp(s, ext, args[3], a1, a2, c2); /* Use CSETM alias of CSINV Wd, WZR, WZR, invert(cond). */ tcg_out_insn(s, 3506, CSINV, ext, a0, TCG_REG_XZR, TCG_REG_XZR, tcg_invert_cond(args[3])); @@ -2296,7 +2316,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, a2 =3D (int32_t)a2; /* FALLTHRU */ case INDEX_op_movcond_i64: - tcg_out_cmp(s, ext, a1, a2, c2); + tcg_out_cmp(s, ext, args[5], a1, a2, c2); tcg_out_insn(s, 3506, CSEL, ext, a0, REG0(3), REG0(4), args[5]); break; =20 @@ -2896,11 +2916,13 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGO= pcode op) case INDEX_op_add_i64: case INDEX_op_sub_i32: case INDEX_op_sub_i64: + return C_O1_I2(r, r, rA); + case INDEX_op_setcond_i32: case INDEX_op_setcond_i64: case INDEX_op_negsetcond_i32: case INDEX_op_negsetcond_i64: - return C_O1_I2(r, r, rA); + return C_O1_I2(r, r, rC); =20 case INDEX_op_mul_i32: case INDEX_op_mul_i64: @@ -2950,11 +2972,11 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGO= pcode op) =20 case INDEX_op_brcond_i32: case INDEX_op_brcond_i64: - return C_O0_I2(r, rA); + return C_O0_I2(r, rC); =20 case INDEX_op_movcond_i32: case INDEX_op_movcond_i64: - return C_O1_I4(r, r, rA, rZ, rZ); + return C_O1_I4(r, r, rC, rZ, rZ); =20 case INDEX_op_qemu_ld_a32_i32: case INDEX_op_qemu_ld_a64_i32: --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522508; cv=none; d=zohomail.com; s=zohoarc; b=EVYwZ6a1asULKFSLdm9lvgQGq/yhVa20a2f33d/4/Q2vYRaFiPv4WI/p1bjnpFAsPV/M9q9x1KtTCUoVoli3m8EnJorQ7XjbOXqiQ8F4it/p7nORTgsZ1u/98I7OdMNc7VRrL+A9Z5mKTiVpVdfu0q+Cv7cgezIEZFGX1SmAUY4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522508; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=h+gt0CjYg4HfuULsURoNWzr2njchZ3xEe5eZdBzd0U4=; b=T7SJMACyg3DlpbaxyLLRx4N7mZNI09HeWBCO0gPw0IYW2G/ASy+nFH+2oUftswbLynKry/kNPCmX/wM5dIOpfgITvRRM0Wd2CVhl28APNbFdAx6Vc+YNyTBdN5J+99tRXhLSIaGvjQ0ufjJDFBhVxl0+cPCiJZD0hbLW3N+TYnE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522508247475.84296265509454; Sat, 28 Oct 2023 12:48:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpFs-0004ok-F3; Sat, 28 Oct 2023 15:45:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFY-0004in-BT for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:36 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFW-00046s-3x for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:36 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1c77449a6daso27557855ad.0 for ; Sat, 28 Oct 2023 12:45:33 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522332; x=1699127132; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=h+gt0CjYg4HfuULsURoNWzr2njchZ3xEe5eZdBzd0U4=; b=SKojQMpetIQroFyANyAose+wX9fYIlrUvheJ5gxZs18GdUky9al8JSUF8KijCtar41 jmRdiWSYDUwK0tH/0xbrfuaYu2g8Ss8O4xubcesPWQgjaM9XqCirgBIlPgeU219a8UNz Bqh2HGCq0P4Y6TEnZbWpq+X0CTye+6Vcdqvmo5KgVQjgxPXYC3G3PIoP6BHXKvTom/DD QorBPmOhTC6Dk9xdEg1lgwJe1A2r06xIsIpsQNt02Hs/0782dN6sLiRngAGADYzXo00X ouL26TZ4WjevjUSTgJQd+Z1nkE1PqdF4WFarIVxF7Dj/s7Z5Y3opssVJwmu5GGVioyNY drWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522332; x=1699127132; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h+gt0CjYg4HfuULsURoNWzr2njchZ3xEe5eZdBzd0U4=; b=TzG1eMR/r+Imy9sm/Vzc0gNJ8UrvgkJnFTUYxY7uCcJyFBilvNmaXy/DMgD4mFEp7z 9fKy+ukmUUJ2TaJv+yoymca7lV3N1vcfKlf6YZXsIiU1BYkTPKBJpiJUKZykPfUdfrXQ 1T3EQtDn7IB72JIsg58J/pYZ5BfJsb6dRRpnZ5Zgi6moMmbIb5I2vzoYJu/Id5vxxOZj ohjF95rYRmZTCX1S0ef7O9/wtNGpZmFgdMD8HeA8iF/svxJVNbuCCOsjZ88IPBerFmUS OJ2VudYzjilLmqGu5fCbC044yAaGERFmfFEaidj5F+FVsOgeSrTGB5LYMxC64qokVUy5 j4Xw== X-Gm-Message-State: AOJu0YxHThB+mL8YjRkHAkkmpMp0epV66kA3SGMeZ5VS8aipMhAfwiAz i60nd+d1OLSkjdhqsZaOQ+9p4uEHofYhmHSYP3s= X-Google-Smtp-Source: AGHT+IHs+vXLlm48V53MSv21N1wltJ9jdZu0Ea5C4spLoPj/uNOtAUte03Eugpf3Lov4e6XJU7+LFA== X-Received: by 2002:a17:902:d401:b0:1cc:2f90:6291 with SMTP id b1-20020a170902d40100b001cc2f906291mr2818017ple.54.1698522332518; Sat, 28 Oct 2023 12:45:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 09/35] tcg/aarch64: Generate TBZ, TBNZ Date: Sat, 28 Oct 2023 12:44:56 -0700 Message-Id: <20231028194522.245170-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522510067100003 Content-Type: text/plain; charset="utf-8" Test the sign bit for LT/GE vs 0, and TSTNE/EQ vs a power of 2. Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.c.inc | 100 ++++++++++++++++++++++++++++------- 1 file changed, 81 insertions(+), 19 deletions(-) diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 70df250c04..55225313ad 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -105,6 +105,18 @@ static bool reloc_pc19(tcg_insn_unit *src_rw, const tc= g_insn_unit *target) return false; } =20 +static bool reloc_pc14(tcg_insn_unit *src_rw, const tcg_insn_unit *target) +{ + const tcg_insn_unit *src_rx =3D tcg_splitwx_to_rx(src_rw); + ptrdiff_t offset =3D target - src_rx; + + if (offset =3D=3D sextract64(offset, 0, 14)) { + *src_rw =3D deposit32(*src_rw, 5, 14, offset); + return true; + } + return false; +} + static bool patch_reloc(tcg_insn_unit *code_ptr, int type, intptr_t value, intptr_t addend) { @@ -115,6 +127,8 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int ty= pe, return reloc_pc26(code_ptr, (const tcg_insn_unit *)value); case R_AARCH64_CONDBR19: return reloc_pc19(code_ptr, (const tcg_insn_unit *)value); + case R_AARCH64_TSTBR14: + return reloc_pc14(code_ptr, (const tcg_insn_unit *)value); default: g_assert_not_reached(); } @@ -380,6 +394,10 @@ typedef enum { /* Conditional branch (immediate). */ I3202_B_C =3D 0x54000000, =20 + /* Test and branch (immediate). */ + I3205_TBZ =3D 0x36000000, + I3205_TBNZ =3D 0x37000000, + /* Unconditional branch (immediate). */ I3206_B =3D 0x14000000, I3206_BL =3D 0x94000000, @@ -660,6 +678,14 @@ static void tcg_out_insn_3202(TCGContext *s, AArch64In= sn insn, tcg_out32(s, insn | tcg_cond_to_aarch64[c] | (imm19 & 0x7ffff) << 5); } =20 +static void tcg_out_insn_3205(TCGContext *s, AArch64Insn insn, + TCGReg rt, int imm6, int imm14) +{ + insn |=3D (imm6 & 0x20) << (31 - 5); + insn |=3D (imm6 & 0x1f) << 19; + tcg_out32(s, insn | (imm14 & 0x3fff) << 5 | rt); +} + static void tcg_out_insn_3206(TCGContext *s, AArch64Insn insn, int imm26) { tcg_out32(s, insn | (imm26 & 0x03ffffff)); @@ -1415,30 +1441,66 @@ static inline void tcg_out_goto_label(TCGContext *s= , TCGLabel *l) static void tcg_out_brcond(TCGContext *s, TCGType ext, TCGCond c, TCGArg a, TCGArg b, bool b_const, TCGLabel *l) { - intptr_t offset; - bool need_cmp; + int tbit =3D -1; + bool need_cmp =3D true; =20 - if (b_const && b =3D=3D 0 && (c =3D=3D TCG_COND_EQ || c =3D=3D TCG_CON= D_NE)) { - need_cmp =3D false; - } else { - need_cmp =3D true; - tcg_out_cmp(s, ext, c, a, b, b_const); - } - - if (!l->has_value) { - tcg_out_reloc(s, s->code_ptr, R_AARCH64_CONDBR19, l, 0); - offset =3D tcg_in32(s) >> 5; - } else { - offset =3D tcg_pcrel_diff(s, l->u.value_ptr) >> 2; - tcg_debug_assert(offset =3D=3D sextract64(offset, 0, 19)); + switch (c) { + case TCG_COND_EQ: + case TCG_COND_NE: + if (b_const && b =3D=3D 0) { + need_cmp =3D false; + } + break; + case TCG_COND_LT: + case TCG_COND_GE: + if (b_const && b =3D=3D 0) { + c =3D (c =3D=3D TCG_COND_LT ? TCG_COND_TSTNE : TCG_COND_TSTEQ); + tbit =3D ext ? 63 : 31; + need_cmp =3D false; + } + break; + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + if (b_const && is_power_of_2(b)) { + tbit =3D ctz64(b); + need_cmp =3D false; + } + break; + default: + break; } =20 if (need_cmp) { - tcg_out_insn(s, 3202, B_C, c, offset); - } else if (c =3D=3D TCG_COND_EQ) { - tcg_out_insn(s, 3201, CBZ, ext, a, offset); + tcg_out_cmp(s, ext, c, a, b, b_const); + tcg_out_reloc(s, s->code_ptr, R_AARCH64_CONDBR19, l, 0); + tcg_out_insn(s, 3202, B_C, c, 0); + return; + } + + if (tbit >=3D 0) { + tcg_out_reloc(s, s->code_ptr, R_AARCH64_TSTBR14, l, 0); + switch (c) { + case TCG_COND_TSTEQ: + tcg_out_insn(s, 3205, TBZ, a, tbit, 0); + break; + case TCG_COND_TSTNE: + tcg_out_insn(s, 3205, TBNZ, a, tbit, 0); + break; + default: + g_assert_not_reached(); + } } else { - tcg_out_insn(s, 3201, CBNZ, ext, a, offset); + tcg_out_reloc(s, s->code_ptr, R_AARCH64_CONDBR19, l, 0); + switch (c) { + case TCG_COND_EQ: + tcg_out_insn(s, 3201, CBZ, ext, a, 0); + break; + case TCG_COND_NE: + tcg_out_insn(s, 3201, CBNZ, ext, a, 0); + break; + default: + g_assert_not_reached(); + } } } =20 --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522389; cv=none; d=zohomail.com; s=zohoarc; b=YFfHtOxzTCay8+8iaAb8ttN/5ALhECTtjpAVwRMcKeSE1ZNTZ1z2ZPzzMhBo3wVom847TnWVVn/IQAEfzVG6eDjt2zMQHEBGJuK9x1lYUhf3G1WtezsORE2v3j+W4OGmagjKJUUXsOvpp5m6qj3fGIDgwEx9D094szu6SM23K6c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522389; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9zCJMFAqdf2iFGNb4zrA/FuyIMECuUh8qss+ekAKVh8=; b=chr3AEHlZrFVUegRnTAhpsMWiD8kVbDx616ipwz0RtTr6kkEal2Ul5iGj5m+7hPfmG0iHfyVDu8bysOKTA2+aB8ta9R7o97jhXulK/VkEyrnIzdudcvUzTqwtwxujifXmZ3kLgzUcCoLQlvNRFNKl8fGbSsZMduWERr5i+dy5O4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522389382153.54355151941309; Sat, 28 Oct 2023 12:46:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpFd-0004jv-43; Sat, 28 Oct 2023 15:45:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFY-0004im-Af for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:36 -0400 Received: from mail-il1-x136.google.com ([2607:f8b0:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFW-000471-Js for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:35 -0400 Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-357ccaf982eso10907545ab.0 for ; Sat, 28 Oct 2023 12:45:34 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522333; x=1699127133; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9zCJMFAqdf2iFGNb4zrA/FuyIMECuUh8qss+ekAKVh8=; b=rHWgRTTNOOV3IwTl//jMU/IzPx1vH8gSFQ64l2x0NR32KamLOx6CU+X54rtfp53b4+ /Opk+Z9Bh8izUlP+aQ2aORxZqtdmt4Y6GXDYQ3NW+dVsonRoM4YDyXHyNZNs0grkXaHw sRMIQcLO7Vcz8jsMgPMx8YTR048Qghk5oZfXc8pxn7TZFjwiqe21KOQG+x20HKxFEHT8 E678PNwJTkLRvaCCyp+60eX3tTxw1/iwjxM5n1ErXDhw6T4mqMu7YRA1W5spU+1k2xHr Gea64ykywyA8QLa2fOWrmUOJYNvGU4Pz187l4bChMrlquJwu914bnjX8jK4SFpl25SED dEZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522333; x=1699127133; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9zCJMFAqdf2iFGNb4zrA/FuyIMECuUh8qss+ekAKVh8=; b=b9Klhq36ykYDG8POXdawyoPhozXIgAi20R6rNavP2buhrO6tqq+JIuxBq2BwPb9cse ml5DiGnl0eU3nnJsJXHO3D4ApOZHEgm9NaRrNK7a5f1WZFmkHAlpJKdYwuyzMu+pY3K9 pmOulEg+g99KkMc3zKqjSnuvaHAcBqFgfAuJWt+bThcqncFeXZDaupW5dICKUYNECM35 z+13Zsn7dozQejqop5/coVw08s2fFsg2Abz5tZS7iXClbkLsu7EDQf6Jj3NZ4o65zaYp O2Yd+uvxvGI4FwR4H7KVAmqLbjImA8mIwWs4qEAXDI04NAg8kMsSNgd0YXa7kGvf9eaa SjDg== X-Gm-Message-State: AOJu0YwvDnqujlFKEHSe3QJTXeKFLndqpWmTe8KGVcDGI2qNbStRaOsK RVU382q4+gMawec5MX+vMAI2DDfWNqU9Uj1bAjg= X-Google-Smtp-Source: AGHT+IEzBD2f8WGNP2BB2Wx+hsgKqSVrBVVLwrRF7oMW7RCSDn6Y2Y/K8jARFtDp4dLAZHZ6pwg2Ow== X-Received: by 2002:a05:6e02:1e07:b0:357:43a5:acf8 with SMTP id g7-20020a056e021e0700b0035743a5acf8mr8466783ila.17.1698522333376; Sat, 28 Oct 2023 12:45:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 10/35] tcg/aarch64: Generate CBNZ for TSTNE of UINT32_MAX Date: Sat, 28 Oct 2023 12:44:57 -0700 Message-Id: <20231028194522.245170-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::136; envelope-from=richard.henderson@linaro.org; helo=mail-il1-x136.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522390052100001 Content-Type: text/plain; charset="utf-8" ... and the inverse, CBZ for TSTEQ. Suggested-by: Paolo Bonzini Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.c.inc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index 55225313ad..0c98c48f68 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -1453,6 +1453,7 @@ static void tcg_out_brcond(TCGContext *s, TCGType ext= , TCGCond c, TCGArg a, break; case TCG_COND_LT: case TCG_COND_GE: + /* cmp xN,0; b.mi L -> tbnz xN,63,L */ if (b_const && b =3D=3D 0) { c =3D (c =3D=3D TCG_COND_LT ? TCG_COND_TSTNE : TCG_COND_TSTEQ); tbit =3D ext ? 63 : 31; @@ -1461,6 +1462,13 @@ static void tcg_out_brcond(TCGContext *s, TCGType ex= t, TCGCond c, TCGArg a, break; case TCG_COND_TSTEQ: case TCG_COND_TSTNE: + /* tst xN,0xffffffff; b.ne L -> cbnz wN,L */ + if (b_const && b =3D=3D UINT32_MAX) { + ext =3D TCG_TYPE_I32; + need_cmp =3D false; + break; + } + /* tst xN,1< tbnz xN,B,L */ if (b_const && is_power_of_2(b)) { tbit =3D ctz64(b); need_cmp =3D false; --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522640; cv=none; d=zohomail.com; s=zohoarc; b=LuBLIG4rkwix6GXb1vJe0ouW3uL/koI8yl205fSaX9IVBw/Eeowe9YyzTtVqt8z4WYibTc+jdKDoewc6NWUit/qGmnBJGAMHCEkNe6IxmvMkV67kH72/YDAlieAuQEzGydAU2GuyPTcb6gKz8E8/vWMxLQlsMLPD+GsFVPkV604= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522640; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+X+7ARY9SpSCXVHzvXgsobDyxq2/hmAeX0xNgjlPdBc=; b=bRG3XerYUkdOvtfJYllXFUrSefCIYiCtkPibuzSLvQQXCgXcd2UAShdXb4bKmn0/lnR3/pLiatoodo6W9YpzTJgM3Hl12qPi7wOG2HC8xvxD6HmabhKEz46vECp7VPP2OJuAPhiso5RYfeUJglkWUoPMJckgnKr3V9DqNC7QyIg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522640573764.6836130499745; Sat, 28 Oct 2023 12:50:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpFv-0004q1-KZ; Sat, 28 Oct 2023 15:45:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFZ-0004jW-PW for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:38 -0400 Received: from mail-oo1-xc2d.google.com ([2607:f8b0:4864:20::c2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFX-00047J-Fa for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:36 -0400 Received: by mail-oo1-xc2d.google.com with SMTP id 006d021491bc7-5869914484fso1837349eaf.0 for ; Sat, 28 Oct 2023 12:45:35 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522334; x=1699127134; 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=+X+7ARY9SpSCXVHzvXgsobDyxq2/hmAeX0xNgjlPdBc=; b=ZZLDrppBtDL6WGy9L2p3qtEEM3uT+RE646bgScGbXXIbZHHl161NrAlZLlTeava1L4 +g2LDD8xUuf9BXWYfAI2p7iTIV2qNz1gZMFUEOpIujyB67QzU+6LSnUTo6NN8MYPkuLl 1uUUlF7aVN3vEWU30wKj0qn12Nttyo9EpcvzcLragG9afGzeLJUNzgCI3b0e0mc9cnb5 rrmW/TmjSMDiKLdh5lgBkcZ0UzbzZ1ujiSO+Sm0gzP/lUYidxFRhOXFXQebmlp0tTcLp E6b8WrWlTx8c5nh7EPhyBNZ1S9Q6ls9julz71wnz9e3BjpAneCVziI/H9G5YK7Bo2MxW VfqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522334; x=1699127134; 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=+X+7ARY9SpSCXVHzvXgsobDyxq2/hmAeX0xNgjlPdBc=; b=U/0Z7wnIcGPAVIUMgcs3EKhlUz+/BnVPOuylhZ4F89dyrjVv1PLrwOCUp6/s/BGChm MYN2fzIuQ5anMTP8I3QAeSp6eMAMJUB4aqj3R69ITDyNj+fB7kVwZgg9nBTsoQR6Mem+ DSSJohAxbGBsD9w6QUxZE6/AUwkQWdpRF50c2JJazkId7zSCeNnBKlhm0xSQjMdAS0cK MMHhUVHbdbp4jedHLYcf5xfUxPGGZug01WgwlVfVPbKqANHJfpc5JeJkb1GNkjHWZECK r8i0BT9p7mOOl+wZmYIK7K4oAxFMrazR6o8mi+HAblembpr+dtgMGEyRpWwwM0ILV/U/ 8oeA== X-Gm-Message-State: AOJu0YyAE7iG0MKhOQE6Hbf4pwAMLMe7X4oYQuVK1dX5F+m+oiEPt5vG GZrht1h1hb5+el7S3te8UV87KCblXnYGAXV14ek= X-Google-Smtp-Source: AGHT+IEq8p8oKtD7qUFRQSJWWSf4oxhqo2o84Xbn9WrsmIrB3tIjarOXrqzSGXeRY4zf5bqNyMdHhg== X-Received: by 2002:a05:6358:186:b0:168:dea8:8897 with SMTP id d6-20020a056358018600b00168dea88897mr9012239rwa.22.1698522334245; Sat, 28 Oct 2023 12:45:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 11/35] tcg/arm: Support TCG_COND_TST{EQ,NE} Date: Sat, 28 Oct 2023 12:44:58 -0700 Message-Id: <20231028194522.245170-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::c2d; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc2d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522642923100006 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.c.inc | 59 ++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 0c29a3929b..0fc7273b16 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1191,6 +1191,33 @@ static void tcg_out_mb(TCGContext *s, TCGArg a0) } } =20 +static TCGCond tcg_out_cmp(TCGContext *s, TCGCond cond, TCGReg a, + TCGArg b, int b_const) +{ + if (!is_tst_cond(cond)) { + tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, a, b, b_const= ); + return cond; + } + + cond =3D tcg_tst_eqne_cond(cond); + if (b_const) { + int imm12 =3D encode_imm(b); + + /* + * The compare constraints allow rIN, but TST does not support N. + * Be prepared to load the constant into a scratch register. + */ + if (imm12 >=3D 0) { + tcg_out_dat_imm(s, COND_AL, ARITH_TST, 0, a, imm12); + return cond; + } + tcg_out_movi32(s, COND_AL, TCG_REG_TMP, b); + b =3D TCG_REG_TMP; + } + tcg_out_dat_reg(s, COND_AL, ARITH_TST, 0, a, b, SHIFT_IMM_LSL(0)); + return cond; +} + static TCGCond tcg_out_cmp2(TCGContext *s, const TCGArg *args, const int *const_args) { @@ -1218,6 +1245,13 @@ static TCGCond tcg_out_cmp2(TCGContext *s, const TCG= Arg *args, tcg_out_dat_rI(s, COND_EQ, ARITH_CMP, 0, al, bl, const_bl); return cond; =20 + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + /* Similar, but with TST instead of CMP. */ + tcg_out_dat_rI(s, COND_AL, ARITH_TST, 0, ah, bh, const_bh); + tcg_out_dat_rI(s, COND_EQ, ARITH_TST, 0, al, bl, const_bl); + return tcg_tst_eqne_cond(cond); + case TCG_COND_LT: case TCG_COND_GE: /* We perform a double-word subtraction and examine the result. @@ -1806,9 +1840,8 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, /* Constraints mean that v2 is always in the same register as dest, * so we only need to do "if condition passed, move v1 to dest". */ - tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, - args[1], args[2], const_args[2]); - tcg_out_dat_rIK(s, tcg_cond_to_arm_cond[args[5]], ARITH_MOV, + c =3D tcg_out_cmp(s, args[5], args[1], args[2], const_args[2]); + tcg_out_dat_rIK(s, tcg_cond_to_arm_cond[c], ARITH_MOV, ARITH_MVN, args[0], 0, args[3], const_args[3]); break; case INDEX_op_add_i32: @@ -1958,25 +1991,21 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, break; =20 case INDEX_op_brcond_i32: - tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, - args[0], args[1], const_args[1]); - tcg_out_goto_label(s, tcg_cond_to_arm_cond[args[2]], - arg_label(args[3])); + c =3D tcg_out_cmp(s, args[2], args[0], args[1], const_args[1]); + tcg_out_goto_label(s, tcg_cond_to_arm_cond[c], arg_label(args[3])); break; case INDEX_op_setcond_i32: - tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, - args[1], args[2], const_args[2]); - tcg_out_dat_imm(s, tcg_cond_to_arm_cond[args[3]], + c =3D tcg_out_cmp(s, args[3], args[1], args[2], const_args[2]); + tcg_out_dat_imm(s, tcg_cond_to_arm_cond[c], ARITH_MOV, args[0], 0, 1); - tcg_out_dat_imm(s, tcg_cond_to_arm_cond[tcg_invert_cond(args[3])], + tcg_out_dat_imm(s, tcg_cond_to_arm_cond[tcg_invert_cond(c)], ARITH_MOV, args[0], 0, 0); break; case INDEX_op_negsetcond_i32: - tcg_out_dat_rIN(s, COND_AL, ARITH_CMP, ARITH_CMN, 0, - args[1], args[2], const_args[2]); - tcg_out_dat_imm(s, tcg_cond_to_arm_cond[args[3]], + c =3D tcg_out_cmp(s, args[3], args[1], args[2], const_args[2]); + tcg_out_dat_imm(s, tcg_cond_to_arm_cond[c], ARITH_MVN, args[0], 0, 0); - tcg_out_dat_imm(s, tcg_cond_to_arm_cond[tcg_invert_cond(args[3])], + tcg_out_dat_imm(s, tcg_cond_to_arm_cond[tcg_invert_cond(c)], ARITH_MOV, args[0], 0, 0); break; =20 --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522528; cv=none; d=zohomail.com; s=zohoarc; b=W0si/tgSGZfTJ2qAJj5IAbJgdsk5RV7dV841lQbP40GWRshKkFfYrw4dBkfUc5nFbuWXTt9yHCPaC9TvHVxB/WcIYnOB/KumE8i1zT7wkc+vcj0mr3xlOaXnH80lEsia7zZdURGn1JuAtEEvt4aLnMwTOgzvZTZ97cspJfZLXfM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522528; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=eaS806fXDgpWYQcWW93tmIyE7x8YLTYsN4JgDu9oFC8=; b=HlM0C8jV+P/pcP23CmUJz2ArazS2StVP7maIOKzmyfmN8GVcRmeAh1epl8801JfK47hg6JJdvvVqxazFS2eoUySSijclry36XgL+fR2wincR4rrekcgxXp19jmXkfqE6Ue1mwhwADJuF38ukbV0n3hwlMteYoXvYleXULBZa8pM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169852252891284.38613828961047; Sat, 28 Oct 2023 12:48:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpG0-0004uf-6A; Sat, 28 Oct 2023 15:46:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFa-0004jg-TS for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:38 -0400 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 1qwpFY-00047S-Hv for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:37 -0400 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-2800f7c8125so1116322a91.1 for ; Sat, 28 Oct 2023 12:45:36 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522335; x=1699127135; 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=eaS806fXDgpWYQcWW93tmIyE7x8YLTYsN4JgDu9oFC8=; b=rVgYZSBt9Pf8H91V09NR2pblM28ZYPRm5NL8J7nvng+Xw9L0PyoB/kK8MfwZzkd7I1 NglQeXllnGLqagki+JcqFUhntBCKPNNLc/sC9pg1aqJ1tyGFn83LwR9pUJyBmpwxqZsY cAhZpT4J8XOgFyVZcVQ6IJ2Jc5N6/dw59MT3vjtjIqZ/VyTpo5U8uuRcvbAkbIXDoIqD iiuEtIk4IF1Y/nmTOBHKrbq7MLG+6YvGEFqAaql4L5Y8SMw9nl09acr9QyveIVMo1qKx CAYbHQoogNNnqcQZ5vqWdU5TPs8Bhm5M0E3TepghXUGYVHF032mQcWpcocZ9rppmG4a8 BQlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522335; x=1699127135; 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=eaS806fXDgpWYQcWW93tmIyE7x8YLTYsN4JgDu9oFC8=; b=cN3zVdqvO/iydAw5wV8wAWtASPOoemFUfl1qskKpYGBgpdPra5Z47Ojaer/wKDXqmA ljzQreFpVT6CXPE6HH/QPkzHpb5xT9bFIe3Je3bJyyNh2CAUijreCFJ20zxjMGocTsPV ecKBPyjQDNfN52XdlouUVxkqxAGQsjRTjMuXQgqRmePBeBa0CLvEmsQd0f/JJMxpCRr2 H8/g02FZ9qDJ+DQIVUtPWMb76oFJnE58uRIRLtyrVOY+rDU121d7Tr9lGzmC8V/Mqm2g buYp3gIDO6LZR9/ksS1+609ZHXsedpNXwGn7POB/jDXo0XH060KuEsnqV6BAfXUVSnLd T1QA== X-Gm-Message-State: AOJu0YySU/DA74FxfvxYj951muUVcFAe38rnuj9K5PU2ZDScEFM1KJbE xId0MatX+d6+R1sb1a09Wx7DQPtJDZUWJMH7V/E= X-Google-Smtp-Source: AGHT+IEwNoz8OpQ4Qn4EhH7d9WlqsfZ5iaZQKgOMWXwhAe7n6quAYDBYRCvHNGULUMPdaRPKk4OfFA== X-Received: by 2002:a17:90b:2405:b0:280:204e:9121 with SMTP id nr5-20020a17090b240500b00280204e9121mr3687604pjb.23.1698522335114; Sat, 28 Oct 2023 12:45:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 12/35] tcg/i386: Pass x86 condition codes to tcg_out_cmov Date: Sat, 28 Oct 2023 12:44:59 -0700 Message-Id: <20231028194522.245170-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522530461100003 Content-Type: text/plain; charset="utf-8" Hoist the tcg_cond_to_jcc index outside the function. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 eeb23d3fca..8b1baa8206 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1669,14 +1669,14 @@ static void tcg_out_setcond2(TCGContext *s, const T= CGArg *args, } #endif =20 -static void tcg_out_cmov(TCGContext *s, TCGCond cond, int rexw, +static void tcg_out_cmov(TCGContext *s, int jcc, int rexw, TCGReg dest, TCGReg v1) { if (have_cmov) { - tcg_out_modrm(s, OPC_CMOVCC | tcg_cond_to_jcc[cond] | rexw, dest, = v1); + tcg_out_modrm(s, OPC_CMOVCC | jcc | rexw, dest, v1); } else { TCGLabel *over =3D gen_new_label(); - tcg_out_jxx(s, tcg_cond_to_jcc[tcg_invert_cond(cond)], over, 1); + tcg_out_jxx(s, jcc ^ 1, over, 1); tcg_out_mov(s, TCG_TYPE_I32, dest, v1); tcg_out_label(s, over); } @@ -1687,7 +1687,7 @@ static void tcg_out_movcond(TCGContext *s, int rexw, = TCGCond cond, TCGReg v1) { tcg_out_cmp(s, c1, c2, const_c2, rexw); - tcg_out_cmov(s, cond, rexw, dest, v1); + tcg_out_cmov(s, tcg_cond_to_jcc[cond], rexw, dest, v1); } =20 static void tcg_out_ctz(TCGContext *s, int rexw, TCGReg dest, TCGReg arg1, @@ -1699,12 +1699,12 @@ static void tcg_out_ctz(TCGContext *s, int rexw, TC= GReg dest, TCGReg arg1, tcg_debug_assert(arg2 =3D=3D (rexw ? 64 : 32)); } else { tcg_debug_assert(dest !=3D arg2); - tcg_out_cmov(s, TCG_COND_LTU, rexw, dest, arg2); + tcg_out_cmov(s, JCC_JB, rexw, dest, arg2); } } else { tcg_debug_assert(dest !=3D arg2); tcg_out_modrm(s, OPC_BSF + rexw, dest, arg1); - tcg_out_cmov(s, TCG_COND_EQ, rexw, dest, arg2); + tcg_out_cmov(s, JCC_JE, rexw, dest, arg2); } } =20 @@ -1717,7 +1717,7 @@ static void tcg_out_clz(TCGContext *s, int rexw, TCGR= eg dest, TCGReg arg1, tcg_debug_assert(arg2 =3D=3D (rexw ? 64 : 32)); } else { tcg_debug_assert(dest !=3D arg2); - tcg_out_cmov(s, TCG_COND_LTU, rexw, dest, arg2); + tcg_out_cmov(s, JCC_JB, rexw, dest, arg2); } } else { tcg_debug_assert(!const_a2); @@ -1730,7 +1730,7 @@ static void tcg_out_clz(TCGContext *s, int rexw, TCGR= eg dest, TCGReg arg1, =20 /* Since we have destroyed the flags from BSR, we have to re-test.= */ tcg_out_cmp(s, arg1, 0, 1, rexw); - tcg_out_cmov(s, TCG_COND_EQ, rexw, dest, arg2); + tcg_out_cmov(s, JCC_JE, rexw, dest, arg2); } } =20 --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522562; cv=none; d=zohomail.com; s=zohoarc; b=lQyTgts5dm6touFN/8iXkqeEgxQ4wEYT1sdH21U/HjPzEcdrUivSnLWvInlCtu8KLIETp5rjaLaZ8QtmCm8Jctks4rzV8/cQORb2a5GfS1vGo/6K3r3TPYK9mSG7bdei8qa9r51Bf243DhS241TmajpXylgfn6akMTL2AEOJDe0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522562; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=avET+iT/h/AqsEJA9yMKornLFdjzPZD4XFSW/W2EXLM=; b=GBhsK7+OGD/b5TKKTHeoS2uThe5y4ycrB05GjNrGMUthJmLogqQbgGpi5LEr50w9Ynnrorucxq2xXpRKTylyxDp6mRaBKleneEtgPFkInqqjWmwEz3cDPeS0BA2O4zLGD5Fy5Rma+f0JZKUwa33MeCX8BEQLm2i/QyMyAKRRle0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522562866776.9504193922941; Sat, 28 Oct 2023 12:49:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpG0-0004ug-A8; Sat, 28 Oct 2023 15:46:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFb-0004js-AC for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:40 -0400 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFZ-00047s-Ic for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:39 -0400 Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-53fbf2c42bfso2528168a12.3 for ; Sat, 28 Oct 2023 12:45:37 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522336; x=1699127136; 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=avET+iT/h/AqsEJA9yMKornLFdjzPZD4XFSW/W2EXLM=; b=sxR9b+PZAy7Swk6+NwtRM0BL/paAkwWBHJCfyk2BNu3EprrEmP2bMiSEKr6zgbpWV9 8KIo6VRRRQ8AZNaMSpgToruYk3Lbt7p8mST/P0HdFz+ahtKjPOCFzH4f+Sz4KowsfIxp UZFHRORyLaY2RVokpBfGIDpccNQv4LI0g5fid/hS51+jPHC7CdP5NnPOkgpQYnbd1fKx lxTCg1S5524etWeZcOqAX1zxwXVodjXebdZ79WFamf6Utm4aJS2PWR9ed73FvgtiEzbo rWKvDbFo8bCMUwJnmwnvH0xeTU08vFBy1QytYPEEdvpIeawnJnldoe+II17lu7QvSbgP eRVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522336; x=1699127136; 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=avET+iT/h/AqsEJA9yMKornLFdjzPZD4XFSW/W2EXLM=; b=adwOTS0gupqUknuUdAcQRx0G3UgD8cJaFyqM7miscUKi8hJDty2DdWMeUHv5SFhid2 FhVmOs2UXPVjjEaYgXvyiUiSUTKj6arr3zs6c5t7WYx4A9AgPzV9VTPUIt6xspUcm0h/ LztkmFOvZGTpjiJhVsX5adJyVDxnE+sCfdzBCoXzn/WGsAfm2ovtyvCfhaHvI9J/sbZ7 uyQi3Pms2utWFQlMjJ0CrkEroxOBpPOsWNGVJv6zaJXndJSUyxFWYFnlmlJC7V+VHL28 3W3Vj+WcTc0o2sCMQRloN4AmuqBRo+0fOAE6FglHXkjdGSdP8NT6dtCpQWRipA40qZaN iVzQ== X-Gm-Message-State: AOJu0YwMqgTGfUC9bcPHJSnKexDRF7rXFFqvJytE9yEiq1wxk2wT7S5f /s7wKmqMbILFe+30cHmyeY9aN5q5tnhtyQ0ft/E= X-Google-Smtp-Source: AGHT+IHd3d2++BqX6yqOWnwto7B5Zom5dVPVmVW1QWkPKd6tebZrfUGL6tQQ7RgBScAxlLVUlOmhmw== X-Received: by 2002:a17:90b:19d0:b0:268:ca76:64a with SMTP id nm16-20020a17090b19d000b00268ca76064amr4963481pjb.49.1698522336145; Sat, 28 Oct 2023 12:45:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 13/35] tcg/i386: Move tcg_cond_to_jcc[] into tcg_out_cmp Date: Sat, 28 Oct 2023 12:45:00 -0700 Message-Id: <20231028194522.245170-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x529.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522563138100001 Content-Type: text/plain; charset="utf-8" Return the x86 condition codes to use after the compare. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 8b1baa8206..7d5ed0d045 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1419,8 +1419,8 @@ static void tcg_out_jxx(TCGContext *s, int opc, TCGLa= bel *l, bool small) } } =20 -static void tcg_out_cmp(TCGContext *s, TCGArg arg1, TCGArg arg2, - int const_arg2, int rexw) +static int tcg_out_cmp(TCGContext *s, TCGCond cond, TCGArg arg1, + TCGArg arg2, int const_arg2, int rexw) { if (const_arg2) { if (arg2 =3D=3D 0) { @@ -1432,14 +1432,15 @@ static void tcg_out_cmp(TCGContext *s, TCGArg arg1,= TCGArg arg2, } else { tgen_arithr(s, ARITH_CMP + rexw, arg1, arg2); } + return tcg_cond_to_jcc[cond]; } =20 static void tcg_out_brcond(TCGContext *s, int rexw, TCGCond cond, TCGArg arg1, TCGArg arg2, int const_arg2, TCGLabel *label, bool small) { - tcg_out_cmp(s, arg1, arg2, const_arg2, rexw); - tcg_out_jxx(s, tcg_cond_to_jcc[cond], label, small); + int jcc =3D tcg_out_cmp(s, cond, arg1, arg2, const_arg2, rexw); + tcg_out_jxx(s, jcc, label, small); } =20 #if TCG_TARGET_REG_BITS =3D=3D 32 @@ -1531,6 +1532,7 @@ static void tcg_out_setcond(TCGContext *s, int rexw, = TCGCond cond, { bool inv =3D false; bool cleared; + int jcc; =20 switch (cond) { case TCG_COND_NE: @@ -1567,7 +1569,7 @@ static void tcg_out_setcond(TCGContext *s, int rexw, = TCGCond cond, * We can then use NEG or INC to produce the desired result. * This is always smaller than the SETCC expansion. */ - tcg_out_cmp(s, arg1, arg2, const_arg2, rexw); + tcg_out_cmp(s, TCG_COND_LTU, arg1, arg2, const_arg2, rexw); =20 /* X - X - C =3D -C =3D (C ? -1 : 0) */ tgen_arithr(s, ARITH_SBB + (neg ? rexw : 0), dest, dest); @@ -1614,8 +1616,8 @@ static void tcg_out_setcond(TCGContext *s, int rexw, = TCGCond cond, cleared =3D true; } =20 - tcg_out_cmp(s, arg1, arg2, const_arg2, rexw); - tcg_out_modrm(s, OPC_SETCC | tcg_cond_to_jcc[cond], 0, dest); + jcc =3D tcg_out_cmp(s, cond, arg1, arg2, const_arg2, rexw); + tcg_out_modrm(s, OPC_SETCC | jcc, 0, dest); =20 if (!cleared) { tcg_out_ext8u(s, dest, dest); @@ -1686,8 +1688,8 @@ static void tcg_out_movcond(TCGContext *s, int rexw, = TCGCond cond, TCGReg dest, TCGReg c1, TCGArg c2, int const_c= 2, TCGReg v1) { - tcg_out_cmp(s, c1, c2, const_c2, rexw); - tcg_out_cmov(s, tcg_cond_to_jcc[cond], rexw, dest, v1); + int jcc =3D tcg_out_cmp(s, cond, c1, c2, const_c2, rexw); + tcg_out_cmov(s, jcc, rexw, dest, v1); } =20 static void tcg_out_ctz(TCGContext *s, int rexw, TCGReg dest, TCGReg arg1, @@ -1729,8 +1731,8 @@ static void tcg_out_clz(TCGContext *s, int rexw, TCGR= eg dest, TCGReg arg1, tgen_arithi(s, ARITH_XOR + rexw, dest, rexw ? 63 : 31, 0); =20 /* Since we have destroyed the flags from BSR, we have to re-test.= */ - tcg_out_cmp(s, arg1, 0, 1, rexw); - tcg_out_cmov(s, JCC_JE, rexw, dest, arg2); + int jcc =3D tcg_out_cmp(s, TCG_COND_EQ, arg1, 0, 1, rexw); + tcg_out_cmov(s, jcc, rexw, dest, arg2); } } =20 --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522577; cv=none; d=zohomail.com; s=zohoarc; b=NtPp4xyi6ecSlgCogCTwh5iUS07qOu77G2wHzB6gDKrPsTVweGpSuG53yfumvOCwQKZtg5XDdL7y1uKahSaMfFM57FKp0RlSigsY9kWnXo70Y/8E3faB28cNQz9MSTYp1+6utMvBn+0LmGrmv8KoPJq3JGtEhgMxpZEKCX/7B/8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522577; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iSXidM1wbTbYTYZXzWmhm92Wt1k0ggjpkGjdIlsf5fU=; b=KmTcVFSmbZChmV/CRe5Lv3pPHUgaCLtBxLwHOd8TLyQUddJSJLk8PlqZkYrlOGrbRSoUGMPnY4IDCzoIytp+K5xJXGSlsVAFAszd1Api1JoBkZIo4PozKxqHepILnktQHimPnQwUDo0JDTeuwEUKJ6AQ8sTFqWm8l/JN2Asfx3Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522577056190.1105605526377; Sat, 28 Oct 2023 12:49:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpFt-0004pd-5E; Sat, 28 Oct 2023 15:45:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFc-0004jx-Hf for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:41 -0400 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 1qwpFa-00047w-Ll for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:40 -0400 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-5b92b852390so2371539a12.2 for ; Sat, 28 Oct 2023 12:45:37 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522337; x=1699127137; 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=iSXidM1wbTbYTYZXzWmhm92Wt1k0ggjpkGjdIlsf5fU=; b=hnKYRhKWOEppTAZAYi2PL7rhViKVRcyohIXuyebD6uBogrdWlFAmD1xM4P5KCemMaS KhgVFnyuvtFRakzdUR56vvaY1GaF3iDShHuozeTDnAhP1OOxdySZc3RnNxp4D8VZ5m9V ueScD/057Zh/sNVLJiIPR9MMzyQfJ1vnZyPR1e3tQ4d0wmylliNKudoWG9npOwrC16G8 t1TN75IQCwapPgyj5/IGOn9yolACH6UvcHucxCL7Wr74V+vxTfnqznlBVYWDqiAJRWzX G/PXR3/OlfFPIugA9sWBM+0MraFbTz1AehMeMUpSBG11mxxaRr33N0R1z3d+a9axcgTt F22g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522337; x=1699127137; 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=iSXidM1wbTbYTYZXzWmhm92Wt1k0ggjpkGjdIlsf5fU=; b=Hl/bY871fE4wapGay0uQRs3itSpj6bYsYXJsxdzcd7QCSBrkovdCjZeOAW58CO07QR d7bNkm5q1864JHAGxCl0/n9dVLkxkUlRUcN9QLswa0iZb2wmbZIgsBeStHfSTKCuzZXM Cxl+MdiDjN3RcF5Rh5VVqBTfJqkZdqAD7kqV5aeQTD2kw3TO8q2tATKVnDmCV2Do00CY GpkOA7pXDQqdA0IqQgMA1+3KEfzzTla7gmsBWiZQoouWqCeIzpNggH+UQFLgiFVyIUsm nFtTCM84J9+QRO/q0jjjsae3vzN3IY5vMU1+rZMfG3JTLWJhF0jWotj1f3os3KNjOR94 q04Q== X-Gm-Message-State: AOJu0YyWlLHG0QVF121lX8Md6tq4VqyBEoTN4iabboKBsX9SM20IAki1 BkidQLNFJ0cjfwOs+uuSAzlLfY1WbgMdEqEQ+rM= X-Google-Smtp-Source: AGHT+IFtccTC2tPesOD+F0Nh7PNBozrVGO4M3Gy1r3oZ7rQhqm/bn24jJV8n/EKe0WJpOsDNaHQLfQ== X-Received: by 2002:a17:90a:8c07:b0:27d:b244:cd28 with SMTP id a7-20020a17090a8c0700b0027db244cd28mr4944847pjo.42.1698522337000; Sat, 28 Oct 2023 12:45:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 14/35] tcg/i386: Support TCG_COND_TST{EQ,NE} Date: Sat, 28 Oct 2023 12:45:01 -0700 Message-Id: <20231028194522.245170-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522577462100001 Content-Type: text/plain; charset="utf-8" Merge tcg_out_testi into tcg_out_cmp and adjust the two uses. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/i386/tcg-target.c.inc | 83 ++++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 7d5ed0d045..17b250f16f 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -505,6 +505,8 @@ static const uint8_t tcg_cond_to_jcc[] =3D { [TCG_COND_GEU] =3D JCC_JAE, [TCG_COND_LEU] =3D JCC_JBE, [TCG_COND_GTU] =3D JCC_JA, + [TCG_COND_TSTEQ] =3D JCC_JE, + [TCG_COND_TSTNE] =3D JCC_JNE, }; =20 #if TCG_TARGET_REG_BITS =3D=3D 64 @@ -1422,15 +1424,35 @@ static void tcg_out_jxx(TCGContext *s, int opc, TCG= Label *l, bool small) static int tcg_out_cmp(TCGContext *s, TCGCond cond, TCGArg arg1, TCGArg arg2, int const_arg2, int rexw) { - if (const_arg2) { - if (arg2 =3D=3D 0) { - /* test r, r */ - tcg_out_modrm(s, OPC_TESTL + rexw, arg1, arg1); + if (is_tst_cond(cond)) { + if (!const_arg2) { + tcg_out_modrm(s, OPC_TESTL + rexw, arg1, arg2); + } else if (arg2 <=3D 0xff && (TCG_TARGET_REG_BITS =3D=3D 64 || arg= 1 < 4)) { + tcg_out_modrm(s, OPC_GRP3_Eb | P_REXB_RM, EXT3_TESTi, arg1); + tcg_out8(s, arg2); + } else if ((arg2 & ~0xff00) =3D=3D 0 && arg1 < 4) { + tcg_out_modrm(s, OPC_GRP3_Eb, EXT3_TESTi, arg1 + 4); + tcg_out8(s, arg2 >> 8); } else { - tgen_arithi(s, ARITH_CMP + rexw, arg1, arg2, 0); + if (rexw) { + if (arg2 =3D=3D (uint32_t)arg2) { + rexw =3D 0; + } else { + tcg_debug_assert(arg2 =3D=3D (int32_t)arg2); + } + } + tcg_out_modrm(s, OPC_GRP3_Ev + rexw, EXT3_TESTi, arg1); + tcg_out32(s, arg2); } } else { - tgen_arithr(s, ARITH_CMP + rexw, arg1, arg2); + if (!const_arg2) { + tgen_arithr(s, ARITH_CMP + rexw, arg1, arg2); + } else if (arg2 =3D=3D 0) { + tcg_out_modrm(s, OPC_TESTL + rexw, arg1, arg1); + } else { + tcg_debug_assert(!rexw || arg2 =3D=3D (int32_t)arg2); + tgen_arithi(s, ARITH_CMP + rexw, arg1, arg2, 0); + } } return tcg_cond_to_jcc[cond]; } @@ -1449,18 +1471,21 @@ static void tcg_out_brcond2(TCGContext *s, const TC= GArg *args, { TCGLabel *label_next =3D gen_new_label(); TCGLabel *label_this =3D arg_label(args[5]); + TCGCond cond =3D args[4]; =20 - switch(args[4]) { + switch (cond) { case TCG_COND_EQ: - tcg_out_brcond(s, 0, TCG_COND_NE, args[0], args[2], const_args[2], - label_next, 1); - tcg_out_brcond(s, 0, TCG_COND_EQ, args[1], args[3], const_args[3], + case TCG_COND_TSTEQ: + tcg_out_brcond(s, 0, tcg_invert_cond(cond), + args[0], args[2], const_args[2], label_next, 1); + tcg_out_brcond(s, 0, cond, args[1], args[3], const_args[3], label_this, small); break; case TCG_COND_NE: - tcg_out_brcond(s, 0, TCG_COND_NE, args[0], args[2], const_args[2], + case TCG_COND_TSTNE: + tcg_out_brcond(s, 0, cond, args[0], args[2], const_args[2], label_this, small); - tcg_out_brcond(s, 0, TCG_COND_NE, args[1], args[3], const_args[3], + tcg_out_brcond(s, 0, cond, args[1], args[3], const_args[3], label_this, small); break; case TCG_COND_LT: @@ -1797,23 +1822,6 @@ static void tcg_out_nopn(TCGContext *s, int n) tcg_out8(s, 0x90); } =20 -/* Test register R vs immediate bits I, setting Z flag for EQ/NE. */ -static void __attribute__((unused)) -tcg_out_testi(TCGContext *s, TCGReg r, uint32_t i) -{ - /* - * This is used for testing alignment, so we can usually use testb. - * For i686, we have to use testl for %esi/%edi. - */ - if (i <=3D 0xff && (TCG_TARGET_REG_BITS =3D=3D 64 || r < 4)) { - tcg_out_modrm(s, OPC_GRP3_Eb | P_REXB_RM, EXT3_TESTi, r); - tcg_out8(s, i); - } else { - tcg_out_modrm(s, OPC_GRP3_Ev, EXT3_TESTi, r); - tcg_out32(s, i); - } -} - typedef struct { TCGReg base; int index; @@ -2074,16 +2082,17 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGConte= xt *s, HostAddress *h, tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_L0, TCG_REG_L0, offsetof(CPUTLBEntry, addend)); } else if (a_mask) { - ldst =3D new_ldst_label(s); + int jcc; =20 + ldst =3D new_ldst_label(s); ldst->is_ld =3D is_ld; ldst->oi =3D oi; ldst->addrlo_reg =3D addrlo; ldst->addrhi_reg =3D addrhi; =20 - tcg_out_testi(s, addrlo, a_mask); /* jne slow_path */ - tcg_out_opc(s, OPC_JCC_long + JCC_JNE, 0, 0, 0); + jcc =3D tcg_out_cmp(s, TCG_COND_TSTNE, addrlo, a_mask, true, false= ); + tcg_out_opc(s, OPC_JCC_long + jcc, 0, 0, 0); ldst->label_ptr[0] =3D s->code_ptr; s->code_ptr +=3D 4; } @@ -2229,9 +2238,10 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TC= GReg datalo, TCGReg datahi, } else { TCGLabel *l1 =3D gen_new_label(); TCGLabel *l2 =3D gen_new_label(); + int jcc; =20 - tcg_out_testi(s, h.base, 15); - tcg_out_jxx(s, JCC_JNE, l1, true); + jcc =3D tcg_out_cmp(s, TCG_COND_TSTNE, h.base, 15, true, false= ); + tcg_out_jxx(s, jcc, l1, true); =20 tcg_out_vex_modrm_sib_offset(s, OPC_MOVDQA_VxWx + h.seg, TCG_TMP_VEC, 0, @@ -2357,9 +2367,10 @@ static void tcg_out_qemu_st_direct(TCGContext *s, TC= GReg datalo, TCGReg datahi, } else { TCGLabel *l1 =3D gen_new_label(); TCGLabel *l2 =3D gen_new_label(); + int jcc; =20 - tcg_out_testi(s, h.base, 15); - tcg_out_jxx(s, JCC_JNE, l1, true); + jcc =3D tcg_out_cmp(s, TCG_COND_TSTNE, h.base, 15, true, false= ); + tcg_out_jxx(s, jcc, l1, true); =20 tcg_out_vex_modrm_sib_offset(s, OPC_MOVDQA_WxVx + h.seg, TCG_TMP_VEC, 0, --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522641; cv=none; d=zohomail.com; s=zohoarc; b=mpe5rNYLNusQm3RgBgzC1ZMNTQ5YMbnZUGJbh4MXAhMQijNQCui4DNz44oqFg41apJCDCVQ199Mwjebdi091+pYWssRuPMNyTYgCLuLIQXk6TIDfHy3MNyTzuli3VWqONyX/LWovTbgr0XpB6+7FiAYtZMTUn/mNrb6k8AfNxfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522641; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2YeM+4oP+r9qlt49XreLO4t20hEw82/Jgmzg6CBtnr4=; b=OE0YoXVK/oGSr3BRlSmnfBZj+YZeioPPRtMecUt5v5qX2VxlnaqIyO4vJj1NE1s0MhlrqCY+aD1uYy2oO9xIsu91IB1TdDMnCT0reQ4nHXp+jB6o7CfUPPcRdQxlKN3SUj6c0AwY60MSy+0eLSUcx7ZQLQEx9UMJ0ldIC6xDewk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522641428378.03614037740385; Sat, 28 Oct 2023 12:50:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpFx-0004s4-Vp; Sat, 28 Oct 2023 15:46:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFe-0004kh-Ko for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:49 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFb-000485-GH for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:41 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1c87a85332bso28249045ad.2 for ; Sat, 28 Oct 2023 12:45:39 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522338; x=1699127138; 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=2YeM+4oP+r9qlt49XreLO4t20hEw82/Jgmzg6CBtnr4=; b=OHGIeGztKeJw28a61FUaeh20KD4/tXOCcZYOSmhcYiF/TM+vMcYiVFLjE3uptOBEZy 4rZBG8u8GcMr6kenkqtrvGR8VXS6s4lvJsPLPzz9r2s24ZHmPSeLc4fb31CIKBNJGQxC +aTiqErGN7bz7NjPr8IVKZTvwH2ye1BWCEmReZr4biuOTl7L1XJ/VjM8TbHJOzPL4oxq l0pX9YUp1aPKi2ZJhsuaBqfBWmRdtN2zHANwLMdQj+yde4piQa8+ZioHgTFLZbkn5UiC 9asIAAGiRSpUNIk/BksY6mQkPubDgX3nZIN7LN/lRJ/fOaRrB5tuwfhnUP1I6x3RqNvD aZ/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522338; x=1699127138; 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=2YeM+4oP+r9qlt49XreLO4t20hEw82/Jgmzg6CBtnr4=; b=IBZ0cEC2TXLSD8KaUdk8nYNTyBIHxL9HWQ7Nz1zJaLmUJNxn1iGhlqMnA7G/n6oMiv ByIhNvSY7+mw6N1zY99H8KgiTV4n0LnteSQYIyb1E31K+7ddwigroUY9L7mflDFc6VkO 0HG8+UcSIZofdTk5BftHh3dpaSC6vrvNY/LOafiyPe2Ulf7Mm02YQbIeI11r3qMPMM7f PSUWVhTHlG+mTrCaYUBh/i/qtHPKtGxLGmG++wLR5e635VWDqmGeFLVZc+kld/xAfW18 +qYf0oAglXP7eGQexhyhTroFoxOskljNW3mE7AuhB/LwrGCTJmGeEaSaFFMMzGj++aKb wjdA== X-Gm-Message-State: AOJu0YyXuv8ZXPVDu/HeUA7yu+fgQcWLQPqE+HlemxirfZfjdmbgLLLt mZhcCDNUGfNXeeQtVjWhv/RA75ROd2MVnjoZpbI= X-Google-Smtp-Source: AGHT+IGHidV3ys+YyZXd0syhJZQJa5RZSdMVpZfQFPuxVVyc1HPoKA2lQAgs7XFi5Rg/qRNQpLl6sw== X-Received: by 2002:a17:902:ea10:b0:1cc:247a:f9f3 with SMTP id s16-20020a170902ea1000b001cc247af9f3mr5389725plg.48.1698522337886; Sat, 28 Oct 2023 12:45:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 15/35] tcg/i386: Improve TSTNE/TESTEQ vs powers of two Date: Sat, 28 Oct 2023 12:45:02 -0700 Message-Id: <20231028194522.245170-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522642919100005 Content-Type: text/plain; charset="utf-8" Use "test x,x" when the bit is one of the 4 sign bits. Use "bt imm,x" otherwise. Signed-off-by: Richard Henderson --- tcg/i386/tcg-target-con-set.h | 6 ++-- tcg/i386/tcg-target-con-str.h | 1 + tcg/i386/tcg-target.c.inc | 56 ++++++++++++++++++++++++++++++++--- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/tcg/i386/tcg-target-con-set.h b/tcg/i386/tcg-target-con-set.h index 7d00a7dde8..e24241cfa2 100644 --- a/tcg/i386/tcg-target-con-set.h +++ b/tcg/i386/tcg-target-con-set.h @@ -20,7 +20,7 @@ C_O0_I2(L, L) C_O0_I2(qi, r) C_O0_I2(re, r) C_O0_I2(ri, r) -C_O0_I2(r, re) +C_O0_I2(r, reT) C_O0_I2(s, L) C_O0_I2(x, r) C_O0_I3(L, L, L) @@ -34,7 +34,7 @@ C_O1_I1(r, r) C_O1_I1(x, r) C_O1_I1(x, x) C_O1_I2(q, 0, qi) -C_O1_I2(q, r, re) +C_O1_I2(q, r, reT) C_O1_I2(r, 0, ci) C_O1_I2(r, 0, r) C_O1_I2(r, 0, re) @@ -50,7 +50,7 @@ C_N1_I2(r, r, r) C_N1_I2(r, r, rW) C_O1_I3(x, 0, x, x) C_O1_I3(x, x, x, x) -C_O1_I4(r, r, re, r, 0) +C_O1_I4(r, r, reT, r, 0) C_O1_I4(r, r, r, ri, ri) C_O2_I1(r, r, L) C_O2_I2(a, d, a, r) diff --git a/tcg/i386/tcg-target-con-str.h b/tcg/i386/tcg-target-con-str.h index 95a30e58cd..cc22db227b 100644 --- a/tcg/i386/tcg-target-con-str.h +++ b/tcg/i386/tcg-target-con-str.h @@ -28,5 +28,6 @@ REGS('s', ALL_BYTEL_REGS & ~SOFTMMU_RESERVE_REGS) /* q= emu_st8_i32 data */ */ CONST('e', TCG_CT_CONST_S32) CONST('I', TCG_CT_CONST_I32) +CONST('T', TCG_CT_CONST_TST) CONST('W', TCG_CT_CONST_WSZ) CONST('Z', TCG_CT_CONST_U32) diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 17b250f16f..3d7306b341 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -132,6 +132,7 @@ static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKin= d kind, int slot) #define TCG_CT_CONST_U32 0x200 #define TCG_CT_CONST_I32 0x400 #define TCG_CT_CONST_WSZ 0x800 +#define TCG_CT_CONST_TST 0x1000 =20 /* Registers used with L constraint, which are the first argument registers on x86_64, and two random call clobbered registers on @@ -202,7 +203,8 @@ static bool tcg_target_const_match(int64_t val, int ct, return 1; } if (type =3D=3D TCG_TYPE_I32) { - if (ct & (TCG_CT_CONST_S32 | TCG_CT_CONST_U32 | TCG_CT_CONST_I32))= { + if (ct & (TCG_CT_CONST_S32 | TCG_CT_CONST_U32 | + TCG_CT_CONST_I32 | TCG_CT_CONST_TST)) { return 1; } } else { @@ -215,6 +217,17 @@ static bool tcg_target_const_match(int64_t val, int ct, if ((ct & TCG_CT_CONST_I32) && ~val =3D=3D (int32_t)~val) { return 1; } + /* + * This will be used in combination with TCG_CT_CONST_S32, + * so "normal" TESTQ is already matched. Also accept: + * TESTQ -> TESTL (uint32_t) + * TESTQ -> BT (is_power_of_2) + */ + if ((ct & TCG_CT_CONST_TST) + && is_tst_cond(cond) + && (val =3D=3D (uint32_t)val || is_power_of_2(val))) { + return 1; + } } if ((ct & TCG_CT_CONST_WSZ) && val =3D=3D (type =3D=3D TCG_TYPE_I32 ? = 32 : 64)) { return 1; @@ -395,6 +408,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) @@ -441,6 +455,12 @@ static bool tcg_target_const_match(int64_t val, int ct, #define OPC_GRP3_Ev (0xf7) #define OPC_GRP5 (0xff) #define OPC_GRP14 (0x73 | P_EXT | P_DATA16) +#define OPC_GRPBT (0xba | P_EXT) + +#define OPC_GRPBT_BT 4 +#define OPC_GRPBT_BTS 5 +#define OPC_GRPBT_BTR 6 +#define OPC_GRPBT_BTC 7 =20 /* Group 1 opcode extensions for 0x80-0x83. These are also used as modifiers for OPC_ARITH. */ @@ -1433,6 +1453,34 @@ static int tcg_out_cmp(TCGContext *s, TCGCond cond, = TCGArg arg1, } else if ((arg2 & ~0xff00) =3D=3D 0 && arg1 < 4) { tcg_out_modrm(s, OPC_GRP3_Eb, EXT3_TESTi, arg1 + 4); tcg_out8(s, arg2 >> 8); + } else if (is_power_of_2(rexw ? arg2 : (uint32_t)arg2)) { + int js =3D (cond =3D=3D TCG_COND_TSTNE ? JCC_JS : JCC_JNS); + int sh =3D ctz64(arg2); + + switch (sh) { + case 7: + if (TCG_TARGET_REG_BITS =3D=3D 64 || arg1 < 4) { + tcg_out_modrm(s, OPC_TESTB | P_REXB_R, arg1, arg1); + return js; + } + break; + case 15: + if (arg1 < 4) { + tcg_out_modrm(s, OPC_TESTB, arg1 + 4, arg1 + 4); + } else { + tcg_out_modrm(s, OPC_TESTL | P_DATA16, arg1, arg1); + } + return js; + case 31: + tcg_out_modrm(s, OPC_TESTL | P_DATA16, arg1, arg1); + return js; + case 63: + tcg_out_modrm(s, OPC_TESTL | P_REXW, arg1, arg1); + return js; + } + rexw =3D sh >=3D 32; + tcg_out_modrm(s, OPC_GRPBT + rexw, OPC_GRPBT_BT, arg1); + tcg_out8(s, sh); } else { if (rexw) { if (arg2 =3D=3D (uint32_t)arg2) { @@ -3357,7 +3405,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode op) =20 case INDEX_op_brcond_i32: case INDEX_op_brcond_i64: - return C_O0_I2(r, re); + return C_O0_I2(r, reT); =20 case INDEX_op_bswap16_i32: case INDEX_op_bswap16_i64: @@ -3405,11 +3453,11 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGO= pcode op) case INDEX_op_setcond_i64: case INDEX_op_negsetcond_i32: case INDEX_op_negsetcond_i64: - return C_O1_I2(q, r, re); + return C_O1_I2(q, r, reT); =20 case INDEX_op_movcond_i32: case INDEX_op_movcond_i64: - return C_O1_I4(r, r, re, r, 0); + return C_O1_I4(r, r, reT, r, 0); =20 case INDEX_op_div2_i32: case INDEX_op_div2_i64: --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522628; cv=none; d=zohomail.com; s=zohoarc; b=Z5NnJOS4Z/aLXAEoh46BQMGR5hch/BUtZiz+b9+EPoaXX/78hoIc/53QV5IRdh+6RIHSykZpa/LrQL4zPyMzICkmQ4xPRgxYME3fhmM1z90kmJex0jjj6bKSwqLUO64LlR6uzq8AKiKPlA7fLfw7vVjD0KFq5sHY9y3Y+Mw8yCw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522628; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qd1KYkP1mjjPOSt2a57McXEK543XMiCskNaYfZeSrS0=; b=PWx+GdBh9GFoqRRw+zrQkE/AexdI+Fdkt50vaxHgG2wr+SyVDFKTNjJCTAN/76JU9JDicT2Ad4Mpna8bPRCennmOuzrfceJjdM/FGlk9iqgBFcTGFnysDHz0tGZBVeuUdhweVJLcqLTu77R5Q5bUSK/VQCn/sidEFzTxstiH6wI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522628568176.99296000057598; Sat, 28 Oct 2023 12:50:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpFv-0004q2-MM; Sat, 28 Oct 2023 15:45:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFe-0004ki-LK for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:49 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFc-00048I-Av for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:41 -0400 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-5b94489e82eso807406a12.2 for ; Sat, 28 Oct 2023 12:45:39 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522339; x=1699127139; 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=qd1KYkP1mjjPOSt2a57McXEK543XMiCskNaYfZeSrS0=; b=ekzLAxWRr4VGMgkuSzoEqbZytwQFZ/Q+2k43P36hYiOp5tFSzZMZm9TaX2gDk89fgG aaavhkEiYjhY/PiobWLZee3clN2Uojzy5EJQI3rgLT/KOx1tQDxDQq69IpvX/ECbF5+V 6kHsOoawmfmHB7fWowhhJOU9Fv91ipIi7whuBvErp9PUmR6cLwTiRF/+NKWSE+0Piajo TaVzC0lbIEaqOsnct9/+6RsQR5T/O1nwJTbDAOTLAKSqRWZnQqsdRzcefHc8FdD2+iyA 7oXK/ZO0gcUolxx76i/oJ7nbAOwJxxAfhVMm5cmgYVVvNb+qZoI+8dt27pgbO4mnTYRK di6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522339; x=1699127139; 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=qd1KYkP1mjjPOSt2a57McXEK543XMiCskNaYfZeSrS0=; b=vlcBZCq+fbf29Emr9uZsqlrjR3Jrw4oki6V8eL7Gq/beHunUqlnaA/lPvl7x5gziGa 2DG7TxMNJPq8fE6G5g+iMBznbFgo9D+Xt+PtMfUO/4TaIhR8fvekPRnZH/5321rVmz9l xiqJGqRWI6IUBojxhm3Yg7ZyhEZ98eLYuvT4od2bBGFJojrCjr62G93R/FqNcf31FKNa hFT+y6OF34/ePa0bBnbmzXwKMVuqOw/xuSwd5zTj5CyK2uBLPbmHyVyT/SHiOTnofanQ 4YvpfyySQwRB1Bgy2k6Iqt114SQxDJGNPTi7708oVLbOAGRMSh3otW1T16Tm4xPT2Ae9 4TyQ== X-Gm-Message-State: AOJu0YzX3Oj/gm8q1GfqcW/hNPLqMl6JSIAEBxYDAs/VuLhh6dTMLckJ XcjVvGe9S00HnRHoxGMJdMvtcitcvRSKUJhpkBA= X-Google-Smtp-Source: AGHT+IHv/y1an6nnroIbsp9aBHNVnHZg+N2BUFaJ9qscsj6haHYisWe5Pjv09Qs3Ml8KuceVxo3qRA== X-Received: by 2002:a17:90a:f298:b0:280:2856:5eef with SMTP id fs24-20020a17090af29800b0028028565eefmr1073584pjb.22.1698522338811; Sat, 28 Oct 2023 12:45:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 16/35] tcg/loongarch64: Support TCG_COND_TST{EQ,NE} Date: Sat, 28 Oct 2023 12:45:03 -0700 Message-Id: <20231028194522.245170-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522630514100005 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/loongarch64/tcg-target.c.inc | 56 ++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.= c.inc index 384d2ba342..7770e1bfa0 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -556,6 +556,7 @@ static int tcg_out_setcond_int(TCGContext *s, TCGCond c= ond, TCGReg ret, case TCG_COND_GEU: /* -> LTU */ case TCG_COND_GT: /* -> LE */ case TCG_COND_GTU: /* -> LEU */ + case TCG_COND_TSTEQ: /* -> TSTNE */ cond =3D tcg_invert_cond(cond); flags ^=3D SETCOND_INV; break; @@ -612,6 +613,18 @@ static int tcg_out_setcond_int(TCGContext *s, TCGCond = cond, TCGReg ret, } break; =20 + case TCG_COND_TSTNE: + flags |=3D SETCOND_NEZ; + if (!c2) { + tcg_out_opc_and(s, ret, arg1, arg2); + } else if (arg2 >=3D 0 && arg2 <=3D 0xfff) { + tcg_out_opc_andi(s, ret, arg1, arg2); + } else { + tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_TMP0, arg2); + tcg_out_opc_and(s, ret, arg1, TCG_REG_TMP0); + } + break; + case TCG_COND_LT: case TCG_COND_LTU: if (c2) { @@ -696,29 +709,36 @@ static void tcg_out_movcond(TCGContext *s, TCGCond co= nd, TCGReg ret, * Branch helpers */ =20 -static const struct { - LoongArchInsn op; - bool swap; -} tcg_brcond_to_loongarch[] =3D { - [TCG_COND_EQ] =3D { OPC_BEQ, false }, - [TCG_COND_NE] =3D { OPC_BNE, false }, - [TCG_COND_LT] =3D { OPC_BGT, true }, - [TCG_COND_GE] =3D { OPC_BLE, true }, - [TCG_COND_LE] =3D { OPC_BLE, false }, - [TCG_COND_GT] =3D { OPC_BGT, false }, - [TCG_COND_LTU] =3D { OPC_BGTU, true }, - [TCG_COND_GEU] =3D { OPC_BLEU, true }, - [TCG_COND_LEU] =3D { OPC_BLEU, false }, - [TCG_COND_GTU] =3D { OPC_BGTU, false } -}; - static void tcg_out_brcond(TCGContext *s, TCGCond cond, TCGReg arg1, TCGReg arg2, TCGLabel *l) { - LoongArchInsn op =3D tcg_brcond_to_loongarch[cond].op; + static const struct { + LoongArchInsn op; + bool swap; + } tcg_brcond_to_loongarch[16] =3D { + [TCG_COND_EQ] =3D { OPC_BEQ, false }, + [TCG_COND_NE] =3D { OPC_BNE, false }, + [TCG_COND_LT] =3D { OPC_BGT, true }, + [TCG_COND_GE] =3D { OPC_BLE, true }, + [TCG_COND_LE] =3D { OPC_BLE, false }, + [TCG_COND_GT] =3D { OPC_BGT, false }, + [TCG_COND_LTU] =3D { OPC_BGTU, true }, + [TCG_COND_GEU] =3D { OPC_BLEU, true }, + [TCG_COND_LEU] =3D { OPC_BLEU, false }, + [TCG_COND_GTU] =3D { OPC_BGTU, false } + }; =20 + LoongArchInsn op; + + if (is_tst_cond(cond)) { + tcg_out_opc_and(s, TCG_REG_TMP0, arg1, arg2); + arg1 =3D TCG_REG_TMP0; + arg2 =3D TCG_REG_ZERO; + cond =3D tcg_tst_eqne_cond(cond); + } + + op =3D tcg_brcond_to_loongarch[cond].op tcg_debug_assert(op !=3D 0); - if (tcg_brcond_to_loongarch[cond].swap) { TCGReg t =3D arg1; arg1 =3D arg2; --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522569; cv=none; d=zohomail.com; s=zohoarc; b=l1GXpU4M92YsIZeb8wdlNcw20HWnhgheiw5y3b06jR/g6gaOk+wYgoOU8Qlxs8lY5QNxe83j72/q6flkLpq5XyBOahosO7QrgRiLz1CcrRUTzl2iP6h77vLBBBvhlaLZ1fD+vB5qOlFgNsBI7ApUlS2Uua7FTxpYQ2jy9KglkdE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522569; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FATcYYBcT5Qcr4CmjwLfHyaaqUPwRVxCY1BCP+WOhQw=; b=CaRYI/EDn3zyPX5WhJftu99ywe1dnSDtGeVbcP2W0/nDuQ+HrKDY0vd6FxWGaUo3XXmUqi/CP34doRGj+DBkjBNrFp5TNx5+ZhC4ovtXuJyVQ/hcITVDqbNPggK8Ew95gZmI5H4e/zQ2NUguo3BfrZIoinLd7nbhVzJISdeuPGM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522569698254.01595342928522; Sat, 28 Oct 2023 12:49:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpG0-0004uy-NZ; Sat, 28 Oct 2023 15:46:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFg-0004ko-6Q for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:49 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFe-00048P-DR for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:43 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6b3c2607d9bso2910957b3a.1 for ; Sat, 28 Oct 2023 12:45:40 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522340; x=1699127140; 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=FATcYYBcT5Qcr4CmjwLfHyaaqUPwRVxCY1BCP+WOhQw=; b=u5Y1tfMf9IJAcKxqPAwYF6WogSzsvXu1kLsSE3diwyYr+Lo7XjzMC0Kh7Trw4uvmUt RORpa+S/mponZJO+8Gu60KqU+rnD8DlfGbVm4/PVKlX+HJkNqHC2Y25OATiCu4foYh7l /6r1HScUKQshXeaOe6BC0xzrUUxCB5sfj5IXYq+C9xr0xEwYQe4DpI+ZVRrKrqAO0YnN 73hJkcJ2ja/+ystvr0Mf4qpt5lwg2kRZ6wTgecyOtV5fZ0gvs4JfnLO51X33FfIpsA5b x9rvFppYYAS1nR3aO/G+2YVwupVPWmvsIl5Wfebh0IQyBvsO8JaisaBX8UqSjSyqWQgV 8CvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522340; x=1699127140; 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=FATcYYBcT5Qcr4CmjwLfHyaaqUPwRVxCY1BCP+WOhQw=; b=Fb7qG2QSGuh4GMULok+Dn1SVxrR341BeHa+xF4W0Yi1IlNoTrYE/35siaPuT2psjz7 cfS/7PhRCf8AzmvFIYucXV3wJkEU6m6h107gYcyNzWFbiFXkBZGr9sS074Y4CjjCIMOo NMYdpeSyOHrAC7t8Kmoz/HRc72n5v0BnGOzYe6XvfC0JmTXw7PXDD/u2+7EeZ1oJ0mJS qMVIoY4VOGPbyGer5AWjyPtLmgI9pwVwhco10g1nGUd6I0TDosjfkt4EEJmg7Kiees+E 9+bk+tWH/og5D1Uu6LelWKqQkjt1m00luw7HDSCm2yw+hpOetn/YV4egsT/85tsIa+xz scWw== X-Gm-Message-State: AOJu0Yx9DfVSIn2P92Hjg1gj+B023xUyzrTZ3ccH3AEyWilkYAHO7Kxf ioL7qNa3KRu2k8lA4lD7Q5xXHQcURsFYexBR6m4= X-Google-Smtp-Source: AGHT+IEMyW+svbMr2DZifst5/6ZohgPgGPb52oWwTS0QJg1R2o2/fxI4tu7W8uMKCA4wIwa7OqxtkA== X-Received: by 2002:a05:6a21:66cb:b0:16b:f71d:1b82 with SMTP id ze11-20020a056a2166cb00b0016bf71d1b82mr4993965pzb.34.1698522339685; Sat, 28 Oct 2023 12:45:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 17/35] tcg/mips: Support TCG_COND_TST{EQ,NE} Date: Sat, 28 Oct 2023 12:45:04 -0700 Message-Id: <20231028194522.245170-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522571349100006 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 35eff82bb3..f5680d7b89 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -910,6 +910,16 @@ static void tcg_out_setcond(TCGContext *s, TCGCond con= d, TCGReg ret, tcg_out_opc_reg(s, OPC_SLTU, ret, TCG_REG_ZERO, arg1); break; =20 + case TCG_COND_TSTEQ: + tcg_out_opc_reg(s, OPC_AND, ret, arg1, arg2); + tcg_out_opc_imm(s, OPC_SLTIU, ret, ret, 1); + break; + + case TCG_COND_TSTNE: + tcg_out_opc_reg(s, OPC_AND, ret, arg1, arg2); + tcg_out_opc_reg(s, OPC_SLTU, ret, TCG_REG_ZERO, ret); + break; + case TCG_COND_LT: case TCG_COND_GE: case TCG_COND_LE: @@ -990,6 +1000,14 @@ static void tcg_out_brcond(TCGContext *s, TCGCond con= d, TCGReg arg1, arg2 =3D TCG_REG_ZERO; break; =20 + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + tcg_out_opc_reg(s, OPC_AND, TCG_TMP0, arg1, arg2); + arg1 =3D TCG_TMP0; + arg2 =3D TCG_REG_ZERO; + b_opc =3D cond =3D=3D TCG_COND_TSTEQ ? OPC_BEQ : OPC_BNE; + break; + default: g_assert_not_reached(); break; @@ -1053,6 +1071,14 @@ static void tcg_out_setcond2(TCGContext *s, TCGCond = cond, TCGReg ret, tcg_out_setcond(s, cond, ret, tmp1, TCG_REG_ZERO); break; =20 + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + tcg_out_opc_reg(s, OPC_AND, TCG_TMP0, al, bl); + tcg_out_opc_reg(s, OPC_AND, TCG_TMP1, ah, bh); + tcg_out_opc_reg(s, OPC_OR, ret, TCG_TMP0, TCG_TMP1); + tcg_out_setcond(s, tcg_eqne_cond(cond), ret, tmp1, TCG_REG_ZERO); + break; + default: tcg_out_setcond(s, TCG_COND_EQ, tmp0, ah, bh); tcg_out_setcond(s, tcg_unsigned_cond(cond), tmp1, al, bl); @@ -1079,6 +1105,13 @@ static void tcg_out_brcond2(TCGContext *s, TCGCond c= ond, TCGReg al, TCGReg ah, tmp =3D tcg_out_reduce_eq2(s, TCG_TMP0, TCG_TMP1, al, ah, bl, bh); break; =20 + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + tcg_out_opc_reg(s, OPC_AND, TCG_TMP0, al, bl); + tcg_out_opc_reg(s, OPC_AND, TCG_TMP1, ah, bh); + tcg_out_opc_reg(s, OPC_OR, TCG_TMP1, TCG_TMP1, TCG_TMP0); + break; + default: /* Minimize code size by preferring a compare not requiring INV. = */ if (mips_cmp_map[cond] & MIPS_CMP_INV) { @@ -1115,6 +1148,14 @@ static void tcg_out_movcond(TCGContext *s, TCGCond c= ond, TCGReg ret, } break; =20 + case TCG_COND_TSTEQ: + eqz =3D true; + /* FALLTHRU */ + case TCG_COND_TSTNE: + tcg_out_opc_reg(s, OPC_AND, TCG_TMP0, c1, c2); + c1 =3D TCG_TMP0; + break; + default: /* Minimize code size by preferring a compare not requiring INV. = */ if (mips_cmp_map[cond] & MIPS_CMP_INV) { --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522460; cv=none; d=zohomail.com; s=zohoarc; b=DKn5DWoqMQGpOwiMHomfepyA18J7w9wctmn7OLua8O8NfalSo0S9W5pF08X5nXSssg5Q/2722vymQRImB3NKpPq9Kjwibzxd8icRGv0DvAWym2TgdgTPX9vLWYJ5uDX/xzrseJapwcoAh9QT2iXfJVc8pBg0ZEynxVgKTravcwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522460; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JJ1WN/0iuBwc2NCK63JpHvn6inIzrDX6DykcbHZYqkQ=; b=Z1BGmo0C2Qu5y1l2Upr9ys9WzM8NZxxSw+jYbBa76nYI/D0j589VCGNtRyEcWhDSlvVr//caztIsP06vO+cjcHJT4g0A1CTJDhHWCE36NYfLRBSEh3ZlfSAI0Rf5ziix3BH1QkcwpdUZlbQZ6soFEvUnkyQOPbOu+3oPD3a50S0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522460328419.9226458011268; Sat, 28 Oct 2023 12:47:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpFz-0004uR-2O; Sat, 28 Oct 2023 15:46:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFg-0004kn-3I for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:49 -0400 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 1qwpFe-00048a-Dg for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:43 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1cc0d0a0355so20257935ad.3 for ; Sat, 28 Oct 2023 12:45:41 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522340; x=1699127140; 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=JJ1WN/0iuBwc2NCK63JpHvn6inIzrDX6DykcbHZYqkQ=; b=lCQZL2vNTmhwUS/CqGbpr96K3gD6oh4v7DKcV+QfcJWC1X8zITg4t5sQ5HLh6gNUR8 HHt9VkFLVemHlPE4pQfsIzp6NBd1RbCEeql7YeACYkgkyB+MfOqbgI2FFBWoSDo4E/b3 NoxSoTnzGPyrlh8hwfmGnzhpdi4FXI6MOZHB56kE8LlLP3gmyC7SxYI0cIOdjWi00isf SA+BhP7ltvmX3M3HF//C4lSXpd+QSxO1DYsh5nXnGtwE7Ov4Z45YxbOSbUTjXGaCopA4 d9fZON+rsZ1hhudkZimuEeLHfi/tdgwhcE0+UNk1Rc/ipbl9t+x5he2vpLwVSIH1DXbu 2B9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522340; x=1699127140; 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=JJ1WN/0iuBwc2NCK63JpHvn6inIzrDX6DykcbHZYqkQ=; b=mMw2pYWuph2awWpNYdlY8n0GzU+k4GWkycm0szV1IbvyrrXCSs+zR2dNCzuna4D1Bu F0yZZPmT8ASttVRuIfpTjwy4DmvBmHUSHjHH2xJtsR3bsbDbCm4C8t1J/gyP040ojuFn Jh1cbYXXZmqDgXL5z08bRY/zY79MkxfY4Pvo+E1rNXFgQSKiy3KCuDH92XyofzIT7C9g wk/8+xfKvhcuPqiNgKp9aohRlvobkFLQxuyFg8xzRvrEI76qH6gDphkFg8n0R5zx5cTo UNzIY6mZOt8aQ64OR9tsODFI5H1AqL+L24XB7lkVQz3gGV4sjQQuHnT9Hz50Nogf7J7T BPpw== X-Gm-Message-State: AOJu0YwwkuVSMqHqUh90HdNx1dyaX38jlpBRvDmF+FF3u9bOa3DihdV1 BBxAKHq3VJm+o4AqcKYlSxhaJRF9ryhl1tgfb8k= X-Google-Smtp-Source: AGHT+IE0vgUpkYIuASda/Mta2vzqQUWtZGaSdvoZYzeDpPqvXJ0KVYJQmS2CHc/HaG8dB/5Z6Gb7DA== X-Received: by 2002:a17:902:fa4e:b0:1c9:d667:4e85 with SMTP id lb14-20020a170902fa4e00b001c9d6674e85mr4449665plb.40.1698522340613; Sat, 28 Oct 2023 12:45:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 18/35] tcg/riscv: Support TCG_COND_TST{EQ,NE} Date: Sat, 28 Oct 2023 12:45:05 -0700 Message-Id: <20231028194522.245170-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522460915100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/riscv/tcg-target.c.inc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 639363039b..358579b3fd 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -799,8 +799,14 @@ static const struct { static void tcg_out_brcond(TCGContext *s, TCGCond cond, TCGReg arg1, TCGReg arg2, TCGLabel *l) { - RISCVInsn op =3D tcg_brcond_to_riscv[cond].op; + RISCVInsn op; =20 + if (is_tst_cond(cond)) { + tcg_out_opc_reg(s, OPC_AND, TCG_REG_TMP0, arg1, arg2); + cond =3D tcg_tst_eqne_cond(cond); + } + + op =3D tcg_brcond_to_riscv[cond].op; tcg_debug_assert(op !=3D 0); =20 if (tcg_brcond_to_riscv[cond].swap) { @@ -828,6 +834,7 @@ static int tcg_out_setcond_int(TCGContext *s, TCGCond c= ond, TCGReg ret, case TCG_COND_GEU: /* -> LTU */ case TCG_COND_GT: /* -> LE */ case TCG_COND_GTU: /* -> LEU */ + case TCG_COND_TSTEQ: /* -> TSTNE */ cond =3D tcg_invert_cond(cond); flags ^=3D SETCOND_INV; break; @@ -887,6 +894,15 @@ static int tcg_out_setcond_int(TCGContext *s, TCGCond = cond, TCGReg ret, } break; =20 + case TCG_COND_TSTNE: + flags |=3D SETCOND_NEZ; + if (c2) { + tcg_out_opc_imm(s, OPC_ANDI, ret, arg1, arg2); + } else { + tcg_out_opc_reg(s, OPC_AND, ret, arg1, arg2); + } + break; + case TCG_COND_LT: if (c2) { tcg_out_opc_imm(s, OPC_SLTI, ret, arg1, arg2); @@ -1080,7 +1096,7 @@ static void tcg_out_movcond(TCGContext *s, TCGCond co= nd, TCGReg ret, int tmpflags; TCGReg t; =20 - if (!have_zicond && (!c_cmp2 || cmp2 =3D=3D 0)) { + if (!have_zicond && (!c_cmp2 || cmp2 =3D=3D 0) && !is_tst_cond(cond)) { tcg_out_movcond_br2(s, cond, ret, cmp1, cmp2, val1, c_val1, val2, c_val2); return; --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522501; cv=none; d=zohomail.com; s=zohoarc; b=X1GqhxgxJbsrDVo0zMQPGUuuFY2SYSWZ0vPEynbsUkn3cSsOsShJrfQl1aqtmbFsO18UEEzg3IEZ9iizBlAFavUfjoQnmNFoWKVGfDzsCbT5DvWfyqlTqXIG2G3RsuP82l8QugDvbFGv0HLnn9VqzKWyaaxKOI0UAmAQ8xSEulo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522501; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zu3IwXhRqKjvVQc9/ToEW3nFAd+p4tbm1VkVHoUThRc=; b=K8GihTgq9TaQ01tG6RypUsUNwj+erMfJLYr2n74+Zdt8JQMVVF6dA8NcHc1PW9K1NL1FdZiC5pieFDFS3vr7BX9cueyZ6SonGR2vyEfsYk0fD5bg1yUMdivCeexYsa6MbSU0BfCfK/jHs9fX/b0onfEsUAv9vgStjvIi7yEV5IE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522501054364.9076902668429; Sat, 28 Oct 2023 12:48:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpG6-00059F-5H; Sat, 28 Oct 2023 15:46:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFh-0004kr-H9 for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:49 -0400 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 1qwpFe-00048g-Kx for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:45 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1c8a1541232so28455345ad.0 for ; Sat, 28 Oct 2023 12:45:42 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522341; x=1699127141; 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=zu3IwXhRqKjvVQc9/ToEW3nFAd+p4tbm1VkVHoUThRc=; b=Er2ShF5njLEfdqycdJzI8O/5bKxLi2QaxAKhjLvtg9gu8cpDioB6ekeodxatInVw3s 9oR5ZS97CD/IusYw1t4fKjnGavQwqdgtyPexwWumrXYRAc4sNQkmlPYNRT3eY8cOoWNf gQ9yQpEeIEVVRKLHa8hnPEevugQ5/ZpLukr8irmeqo8HJakSt4JhEq8FrO4EeZ7gcwSy FVt9CAQRid7JUmcjtGP9wDAL+DKotEi6QIZmrrKrR/jWUfOlBJG6G6EI97PVTiSohfAP L5JNfodQgxK2pEGZfysCMrvNr98C+6araLD5iFZ25RCZWaUG+WpOqLv4J+YcQTr4CV6J BylQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522341; x=1699127141; 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=zu3IwXhRqKjvVQc9/ToEW3nFAd+p4tbm1VkVHoUThRc=; b=onaIxwNwbv9F2VW3iI/zmVwUR5JdK2OqZ8ORLxqwMUdDXmwSbWAjJNBMBBOAdR2yrn pLyWaH641XlXuAFgR9JxHH7zHEmMQgwJpqj/6LOLTQMDPV1XlTRIKqrE6jGjYXdQgm6E AMqNOrCtOEbbejvM4wfzSQexmDpIHgrOZFdFbjK011wNGL9FyKI8FdzX6PO+b75mg2Jr A5W0rx+p955WfbFXQ74gxOpG1w1rDgRt3AMUejGB1KtHb/DCSc5gnqRUiLM2IB5/IxDq /UEwq8U+fxEbNgjxPAGpAcP/gEYMXVtFhSA5aNLJ8IBcO1H/kgG1XyubJI9JlV4Vj8OI zF4Q== X-Gm-Message-State: AOJu0Yz78YgiwPCfu1EQkAvyXmTbN0oNGgX85VZd15vo/x3ZbOIY/rQw atqOUMb4LKj7qepKTCZC1hl9ZYgyR/5l2aKOc/Q= X-Google-Smtp-Source: AGHT+IECsyHKtpcMwiluSfaMk+0Kc0gMEoFB1BKGK4bF/7wKAtnoAsN5yvwB1sFVWaSO/wkz4gp2rg== X-Received: by 2002:a17:902:fac4:b0:1cc:40eb:79ae with SMTP id ld4-20020a170902fac400b001cc40eb79aemr280063plb.63.1698522341493; Sat, 28 Oct 2023 12:45:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com, qemu-stable@nongnu.org Subject: [PATCH v2 19/35] tcg/sparc64: Implement tcg_out_extrl_i64_i32 Date: Sat, 28 Oct 2023 12:45:06 -0700 Message-Id: <20231028194522.245170-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522501943100003 Content-Type: text/plain; charset="utf-8" Build fix for missing symbol. Cc: qemu-stable@nongnu.org Fixes: b8b94ac6753 ("tcg: Split out tcg_out_extrl_i64_i32") Signed-off-by: Richard Henderson --- tcg/sparc64/tcg-target.c.inc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc index 386f51f29e..ac86b92b75 100644 --- a/tcg/sparc64/tcg-target.c.inc +++ b/tcg/sparc64/tcg-target.c.inc @@ -530,6 +530,11 @@ static void tcg_out_extu_i32_i64(TCGContext *s, TCGReg= rd, TCGReg rs) tcg_out_ext32u(s, rd, rs); } =20 +static void tcg_out_extrl_i64_i32(TCGContext *s, TCGReg rd, TCGReg rs) +{ + tcg_out_ext32u(s, rd, rs); +} + static bool tcg_out_xchg(TCGContext *s, TCGType type, TCGReg r1, TCGReg r2) { return false; --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522409; cv=none; d=zohomail.com; s=zohoarc; b=jySsxlijDChqBFihhAouJwJtocqvtkN0bdEFsyiSXv6h1pnIW3LqSIOTMF1dMpEhoRhcOBlzEGPkfjaS4hhqvbpxeyps7xJIEHEVlq05dReELi5ZCIixNEtLBWaKOl/7RKyKFrD4drI1ekql1qBIs+UuFeuzuRsWjd3MzJjdPBA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522409; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HCvTsJxszRM1kWvCfAgS3PnaRgG5ZKysHYNxBhOcP2k=; b=PgETRPKDL/0lz5bdGMN4w14MP1oDC//jxSoXbBldVvp6YglqwG/HB4mXqwpo5X4dAuxxS9rurDhcF+QYoj0oF0GhwEgOas9sbSR0xeuAwlGKfaMW+m7QDv0yeA8yKwz5Zd22fZ2vx87LmB57xq9uhvcwlq1mAPCFYwvihx0YcV0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522409644998.1266929206081; Sat, 28 Oct 2023 12:46:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpG1-0004uz-0G; Sat, 28 Oct 2023 15:46:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFh-0004ks-MK for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:49 -0400 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 1qwpFg-00048w-0Z for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:45 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1c9d407bb15so28754505ad.0 for ; Sat, 28 Oct 2023 12:45:43 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522342; x=1699127142; 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=HCvTsJxszRM1kWvCfAgS3PnaRgG5ZKysHYNxBhOcP2k=; b=SZT2Y1+okXvsisXu5Y5Hbv5FVTkJKvor2BuFkHQPrloJ10WDsgNZbIrY2DK8B3kcRg Nk9VvtYnS35Guxq2QRBI+Up4vSqe9sp8wi9mqUdIrmG2YTE8tr+xXEzkXs1i0kM1k/tx 4p+/dImcGiM/hBLLoRX/0tKvZKSsbA06W9+XEYgaLsOCsn/MGckEC5GVJ+dRq9GiGeS9 2OV+WFEmMWT8uIsy9wLZeqwOCbFGRjCtcKQv3Y6ndVqfiXYjkZIfai6qyM+H7vo5EPL1 8rE6GBLLCBcrj3FEcBqiG0sUpAHkRrQqEtFgVnQpLWSKMjOq0GQ+k/93/Fb2ZPZO+WCu +rDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522342; x=1699127142; 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=HCvTsJxszRM1kWvCfAgS3PnaRgG5ZKysHYNxBhOcP2k=; b=H7JHhU7daByLq5q+ZvqdqL2Em6AmzBdHllCxFm/dgfYrQC+qec6WWvFOqQurlqrLx+ OPewZq9x6aZmdXl9KtIDNv+94OCfUruoHauBSnlXqfXWrGHFDVxkkMeGE3uVTn3QEuGb T2lecM2BDZd7NMkB9po8tGTzV4mSAS2OgtBVoRj/kQ4pHBaATR++kSQ/hWfRRH2s5C2F is4K0AITRijDC39hIdpwZLMd8KVHIqXX16VWSry7u4sIUec/Kc4+ivw1a7HEBQbIM+iV Petqv/8dFUqFKLu2DFsON/lA8DlHJ8YM8QUPezUgYxd9fQyt6xLA9AaZwVMk6kfkRKEz XtAQ== X-Gm-Message-State: AOJu0YxPJdz3yhQXoFTR/kqgfQfVzYtQ25+5gvEGh/Rt2rhAu0bcyeCh 13uoeSCI2d7j/TBoWEyLB1YRNOGMulrnmLJbH54= X-Google-Smtp-Source: AGHT+IFxt4R9fhQLpe9zhAoxX0ST9a7iqGdB71M6iWGx6ZQOTXY+kOLnrKCxd4mwotj30GVAEAa9rg== X-Received: by 2002:a17:902:c70c:b0:1cc:2eda:bde8 with SMTP id p12-20020a170902c70c00b001cc2edabde8mr3043509plp.24.1698522342385; Sat, 28 Oct 2023 12:45:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 20/35] tcg/sparc64: Hoist read of tcg_cond_to_rcond Date: Sat, 28 Oct 2023 12:45:07 -0700 Message-Id: <20231028194522.245170-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522410138100001 Content-Type: text/plain; charset="utf-8" Use a non-zero value here (an illegal encoding) as a better condition than is_unsigned_cond for when MOVR/BPR is usable. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/sparc64/tcg-target.c.inc | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc index ac86b92b75..e16b25e309 100644 --- a/tcg/sparc64/tcg-target.c.inc +++ b/tcg/sparc64/tcg-target.c.inc @@ -620,7 +620,7 @@ static const uint8_t tcg_cond_to_bcond[] =3D { [TCG_COND_GTU] =3D COND_GU, }; =20 -static const uint8_t tcg_cond_to_rcond[] =3D { +static const uint8_t tcg_cond_to_rcond[16] =3D { [TCG_COND_EQ] =3D RCOND_Z, [TCG_COND_NE] =3D RCOND_NZ, [TCG_COND_LT] =3D RCOND_LZ, @@ -679,7 +679,8 @@ static void tcg_out_brcond_i64(TCGContext *s, TCGCond c= ond, TCGReg arg1, int32_t arg2, int const_arg2, TCGLabel *l) { /* For 64-bit signed comparisons vs zero, we can avoid the compare. */ - if (arg2 =3D=3D 0 && !is_unsigned_cond(cond)) { + int rcond =3D tcg_cond_to_rcond[cond]; + if (arg2 =3D=3D 0 && rcond) { int off16 =3D 0; =20 if (l->has_value) { @@ -688,7 +689,7 @@ static void tcg_out_brcond_i64(TCGContext *s, TCGCond c= ond, TCGReg arg1, tcg_out_reloc(s, s->code_ptr, R_SPARC_WDISP16, l, 0); } tcg_out32(s, INSN_OP(0) | INSN_OP2(3) | BPR_PT | INSN_RS1(arg1) - | INSN_COND(tcg_cond_to_rcond[cond]) | off16); + | INSN_COND(rcond) | off16); } else { tcg_out_cmp(s, arg1, arg2, const_arg2); tcg_out_bpcc(s, tcg_cond_to_bcond[cond], BPCC_XCC | BPCC_PT, l); @@ -696,11 +697,10 @@ static void tcg_out_brcond_i64(TCGContext *s, TCGCond= cond, TCGReg arg1, tcg_out_nop(s); } =20 -static void tcg_out_movr(TCGContext *s, TCGCond cond, TCGReg ret, TCGReg c= 1, +static void tcg_out_movr(TCGContext *s, int rcond, TCGReg ret, TCGReg c1, int32_t v1, int v1const) { - tcg_out32(s, ARITH_MOVR | INSN_RD(ret) | INSN_RS1(c1) - | (tcg_cond_to_rcond[cond] << 10) + tcg_out32(s, ARITH_MOVR | INSN_RD(ret) | INSN_RS1(c1) | (rcond << 10) | (v1const ? INSN_IMM10(v1) : INSN_RS2(v1))); } =20 @@ -711,9 +711,9 @@ static void tcg_out_movcond_i64(TCGContext *s, TCGCond = cond, TCGReg ret, /* For 64-bit signed comparisons vs zero, we can avoid the compare. Note that the immediate range is one bit smaller, so we must check for that as well. */ - if (c2 =3D=3D 0 && !is_unsigned_cond(cond) - && (!v1const || check_fit_i32(v1, 10))) { - tcg_out_movr(s, cond, ret, c1, v1, v1const); + int rcond =3D tcg_cond_to_rcond[cond]; + if (c2 =3D=3D 0 && rcond && (!v1const || check_fit_i32(v1, 10))) { + tcg_out_movr(s, rcond, ret, c1, v1, v1const); } else { tcg_out_cmp(s, c1, c2, c2const); tcg_out_movcc(s, cond, MOVCC_XCC, ret, v1, v1const); @@ -788,6 +788,8 @@ static void tcg_out_setcond_i32(TCGContext *s, TCGCond = cond, TCGReg ret, static void tcg_out_setcond_i64(TCGContext *s, TCGCond cond, TCGReg ret, TCGReg c1, int32_t c2, int c2const, bool n= eg) { + int rcond; + if (use_vis3_instructions && !neg) { switch (cond) { case TCG_COND_NE: @@ -807,9 +809,10 @@ static void tcg_out_setcond_i64(TCGContext *s, TCGCond= cond, TCGReg ret, =20 /* For 64-bit signed comparisons vs zero, we can avoid the compare if the input does not overlap the output. */ - if (c2 =3D=3D 0 && !is_unsigned_cond(cond) && c1 !=3D ret) { + rcond =3D tcg_cond_to_rcond[cond]; + if (c2 =3D=3D 0 && rcond && c1 !=3D ret) { tcg_out_movi_s13(s, ret, 0); - tcg_out_movr(s, cond, ret, c1, neg ? -1 : 1, 1); + tcg_out_movr(s, rcond, ret, c1, neg ? -1 : 1, 1); } else { tcg_out_cmp(s, c1, c2, c2const); tcg_out_movi_s13(s, ret, 0); --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522563; cv=none; d=zohomail.com; s=zohoarc; b=GPANeDQcXwGDqZi09BsrYBtBhgv9+umdKbrLtbgw/JTfyd8++mLEjYAlCrpvC3QClPXzBm1+GUGEt+bKN55TcIYYxLlu79yP835N8CEdu2LN/AVj4PM0PlO6hWDYcuwh7tPgvOX2bgveT/RBkJbgfZYd8uPZ14i7Vgzj+XkVvDw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522563; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MwVxkbAXYLmkseWHOh9WFstoLQErXGaZYO3LsVFGKmE=; b=H9Bc4S5UdVEl1MjkoMqjDrn+qlxQzM8ChfXm7cF2aOi/mL+eJg11g+p9R/zwbGxVhrR6GAsd/iy/oqAAK0hdCLs+HhcZ8gNaKHx2wNmc+nkiwwBTZPezklycX7I0BHelGfd9Uh/haKNAFEmwhjHKiaBxajHnypbCS+kY9+D/cQU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522563838980.2411628679722; Sat, 28 Oct 2023 12:49:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpFu-0004ph-6X; Sat, 28 Oct 2023 15:45:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFi-0004kv-EW for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:49 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFg-00048z-F6 for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:46 -0400 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-53fa455cd94so2449856a12.2 for ; Sat, 28 Oct 2023 12:45:43 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522343; x=1699127143; 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=MwVxkbAXYLmkseWHOh9WFstoLQErXGaZYO3LsVFGKmE=; b=HxTe7WkXDWC9+sNfddiNLVPWOLB/tS5zeEyD+i6hXp5mjXeMOrSAXgWA28fuYzBDwB E6M+uIMWgW0t+xx6PWt/iWfbx2RNEhgRMKyr5mCCojeRA6dPjQp+wSC9pm5/defYKGpc 46vAMSxv7KE3cK33sHJIqBb+x22NKK/v2OJiKb93yJ3rVqtXNmEV5OT+aqRFedv/pgtw JT1AFllmOWOjdmu391LaiE2LcwncFY7KzKfUV0Qs5cnkf0ILl2Q9Ocd1oBZkjHgsEHPm /+STm+d/FNljyZvQHfX1aSnqvAuwMb3prlSMydhBDBDVuO5bJMIrG2Vu1e3AXIRWVFBg 4+OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522343; x=1699127143; 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=MwVxkbAXYLmkseWHOh9WFstoLQErXGaZYO3LsVFGKmE=; b=miafb3SGdfhKP1ReioHZTvxSQCpNmEyWVrHbs73RdUpirh7z2LUrHGpBe95thSXgtb OBkV1MDvvLQJ0pjnRuQNE2w0wJi9btldVkgXIDwx3guBHBOSaXS1dUM8l8MUx7WDssD4 DNqxv3RtpZMlsrFzvWrXLmDaNFIdNauoy3tbDOphtOrRayM4dbUJBNgozYbpb6hMdp3P 94N4O+JQwOOB8o1n0e+k0ELugvB6mSJAOfUleRgKxXnOr82UYMIK+m4b4x4pRwvpt9F5 VwJdAxH1exzPqBZdMcBQkIav0gjhrC+hN+urQqA/MFzpIZ05HOvybgFZ5hGkrur0fwsW M+BQ== X-Gm-Message-State: AOJu0YyJiuUXJn4BuDtniGnuPQIgZBEUD/bXsger09895/Un0REKEa/N qBfPO7Pb7sILoj08vIFa8f8eyjKGsZdEr2wyIfE= X-Google-Smtp-Source: AGHT+IEYgwYbix/Af8Q0Tdw2dPYOAIDhsiX6nohhN2iLqBeVVqBrvFJG+r4JSnfa9dCbm36exOXY5Q== X-Received: by 2002:a17:902:d48a:b0:1ca:85ae:3b4f with SMTP id c10-20020a170902d48a00b001ca85ae3b4fmr6283295plg.55.1698522343192; Sat, 28 Oct 2023 12:45:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 21/35] tcg/sparc64: Pass TCGCond to tcg_out_cmp Date: Sat, 28 Oct 2023 12:45:08 -0700 Message-Id: <20231028194522.245170-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522565160100007 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/sparc64/tcg-target.c.inc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc index e16b25e309..10fb8a1a0d 100644 --- a/tcg/sparc64/tcg-target.c.inc +++ b/tcg/sparc64/tcg-target.c.inc @@ -646,7 +646,8 @@ static void tcg_out_bpcc(TCGContext *s, int scond, int = flags, TCGLabel *l) tcg_out_bpcc0(s, scond, flags, off19); } =20 -static void tcg_out_cmp(TCGContext *s, TCGReg c1, int32_t c2, int c2const) +static void tcg_out_cmp(TCGContext *s, TCGCond cond, + TCGReg c1, int32_t c2, int c2const) { tcg_out_arithc(s, TCG_REG_G0, c1, c2, c2const, ARITH_SUBCC); } @@ -654,7 +655,7 @@ static void tcg_out_cmp(TCGContext *s, TCGReg c1, int32= _t c2, int c2const) static void tcg_out_brcond_i32(TCGContext *s, TCGCond cond, TCGReg arg1, int32_t arg2, int const_arg2, TCGLabel *l) { - tcg_out_cmp(s, arg1, arg2, const_arg2); + tcg_out_cmp(s, cond, arg1, arg2, const_arg2); tcg_out_bpcc(s, tcg_cond_to_bcond[cond], BPCC_ICC | BPCC_PT, l); tcg_out_nop(s); } @@ -671,7 +672,7 @@ static void tcg_out_movcond_i32(TCGContext *s, TCGCond = cond, TCGReg ret, TCGReg c1, int32_t c2, int c2const, int32_t v1, int v1const) { - tcg_out_cmp(s, c1, c2, c2const); + tcg_out_cmp(s, cond, c1, c2, c2const); tcg_out_movcc(s, cond, MOVCC_ICC, ret, v1, v1const); } =20 @@ -691,7 +692,7 @@ static void tcg_out_brcond_i64(TCGContext *s, TCGCond c= ond, TCGReg arg1, tcg_out32(s, INSN_OP(0) | INSN_OP2(3) | BPR_PT | INSN_RS1(arg1) | INSN_COND(rcond) | off16); } else { - tcg_out_cmp(s, arg1, arg2, const_arg2); + tcg_out_cmp(s, cond, arg1, arg2, const_arg2); tcg_out_bpcc(s, tcg_cond_to_bcond[cond], BPCC_XCC | BPCC_PT, l); } tcg_out_nop(s); @@ -715,7 +716,7 @@ static void tcg_out_movcond_i64(TCGContext *s, TCGCond = cond, TCGReg ret, if (c2 =3D=3D 0 && rcond && (!v1const || check_fit_i32(v1, 10))) { tcg_out_movr(s, rcond, ret, c1, v1, v1const); } else { - tcg_out_cmp(s, c1, c2, c2const); + tcg_out_cmp(s, cond, c1, c2, c2const); tcg_out_movcc(s, cond, MOVCC_XCC, ret, v1, v1const); } } @@ -759,13 +760,13 @@ static void tcg_out_setcond_i32(TCGContext *s, TCGCon= d cond, TCGReg ret, /* FALLTHRU */ =20 default: - tcg_out_cmp(s, c1, c2, c2const); + tcg_out_cmp(s, cond, c1, c2, c2const); tcg_out_movi_s13(s, ret, 0); tcg_out_movcc(s, cond, MOVCC_ICC, ret, neg ? -1 : 1, 1); return; } =20 - tcg_out_cmp(s, c1, c2, c2const); + tcg_out_cmp(s, cond, c1, c2, c2const); if (cond =3D=3D TCG_COND_LTU) { if (neg) { /* 0 - 0 - C =3D -C =3D (C ? -1 : 0) */ @@ -799,7 +800,7 @@ static void tcg_out_setcond_i64(TCGContext *s, TCGCond = cond, TCGReg ret, c2 =3D c1, c2const =3D 0, c1 =3D TCG_REG_G0; /* FALLTHRU */ case TCG_COND_LTU: - tcg_out_cmp(s, c1, c2, c2const); + tcg_out_cmp(s, cond, c1, c2, c2const); tcg_out_arith(s, ret, TCG_REG_G0, TCG_REG_G0, ARITH_ADDXC); return; default: @@ -814,7 +815,7 @@ static void tcg_out_setcond_i64(TCGContext *s, TCGCond = cond, TCGReg ret, tcg_out_movi_s13(s, ret, 0); tcg_out_movr(s, rcond, ret, c1, neg ? -1 : 1, 1); } else { - tcg_out_cmp(s, c1, c2, c2const); + tcg_out_cmp(s, cond, c1, c2, c2const); tcg_out_movi_s13(s, ret, 0); tcg_out_movcc(s, cond, MOVCC_XCC, ret, neg ? -1 : 1, 1); } @@ -1102,7 +1103,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext= *s, HostAddress *h, tcg_out_movi_s32(s, TCG_REG_T3, compare_mask); tcg_out_arith(s, TCG_REG_T3, addr_reg, TCG_REG_T3, ARITH_AND); } - tcg_out_cmp(s, TCG_REG_T2, TCG_REG_T3, 0); + tcg_out_cmp(s, TCG_COND_NE, TCG_REG_T2, TCG_REG_T3, 0); =20 ldst =3D new_ldst_label(s); ldst->is_ld =3D is_ld; --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522488; cv=none; d=zohomail.com; s=zohoarc; b=aMgIWjKML6Ww12/4Z660QELzzffucfYHwwYcFCB8fUuEFWMTFkhvmdExgiXnsssHmnUQrNZD1Lk6N3fLdVTvciijsEeIC/skHFFqEhJ6/6VFuqBp7hFWdKIDGKuhM2ihIHscNkBsagTXkqYS/1AxUsao1UE/y4mNjJKLybUisJ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522488; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bILXU6Tv3/UsJC5IcZK0AlLd3YFdGLp0U4K4tlGQLvs=; b=cHGrGlAzTwiTucsPLS5UfRNXk56NPqii2PwbUoxW1YAfbvaxBB/JmpXMrlplAYdHS7aDTQ+0xFF9HqDj+vmAkesIDIl3L1npkX6HEe5B1hpR7wok8TBVuHpyk4Ubq0jyJEd10GcbFehEOuhhKQs6fjKspkPWfkgVz7iitXyuC20= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522488638247.3386069291007; Sat, 28 Oct 2023 12:48:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpG6-0005Ee-Uo; Sat, 28 Oct 2023 15:46:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFi-0004l1-Sv for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:49 -0400 Received: from mail-il1-x12b.google.com ([2607:f8b0:4864:20::12b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFh-00049G-DR for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:46 -0400 Received: by mail-il1-x12b.google.com with SMTP id e9e14a558f8ab-3576121362eso9787735ab.1 for ; Sat, 28 Oct 2023 12:45:45 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522344; x=1699127144; 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=bILXU6Tv3/UsJC5IcZK0AlLd3YFdGLp0U4K4tlGQLvs=; b=wsKrDK4VxrHWc/x5L15gEIxQsQ6OUYWH9xdkpcl7YlmEftdoxImKEnQuKC4zet5Dsa oA3hIm0ocgYIsYt54oMPcxiq59t39aRwKHZU7q4WVvyuq/NAJVv+gGQA4kgcH/N5Dh9x UbDNIIvwv3rk8uCeTxSSogxG3cSBmOQtRdqJGGt5/yefQ1ez7shtPl+Ex01zCYnSAZYY 3Twtj4U3SeZhjeVuy3vS+wiR5HfBxZX5tEmNMSf7lpa9OIOPWuJoxmUBdfZcUx/VXngH wjLI7DtM4x2K4vBNLZK8a18ZtsDzbPjos4loEiboD3bLuvA9/N7Da74QzF3jgQJeMJSv 46yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522344; x=1699127144; 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=bILXU6Tv3/UsJC5IcZK0AlLd3YFdGLp0U4K4tlGQLvs=; b=KoE8TX0HuOR5BNpwTP8HixorryJ4ZUCts8IPT+foY/gdrb7OnVKuFWJWMPJMpn+n0a ag5WcLzmY3Xw9lnaf56bJnDh+uB+/NrQPZq7u8aai4cncjiUB+YW93DdpJ5zD2y7yP2C 5m6OpcvCg1DHVqyfJy4fJ0waQqxjeVm4HDpawj540vAkoa64KR3Q/SuTrwDigkyzme2t 90VcGNg7UrMVMvTDARg6PHFwUptpeo4WCQsbqUXMySV4fqGxOK5domdWKPlaY6GS2fOy +jBoDv/8w6NrM/uG+4W9cHrPtAA/iC2bH5dI6sXo2lSt2OE+6nE6YngB+7Z8cz3LeCQM 0/Hg== X-Gm-Message-State: AOJu0Yyu1eGFiYmV3V6gaIjaFWVx9t5DpHD3kAazkB8EfFDP61PjhtkR 1uHtkF171bAiDj3cgjtEeW5BxPW1ALG4p0tSNm4= X-Google-Smtp-Source: AGHT+IGHNyki1/dZ+aQQuuXINUoht13lh1zGAnN/0t3QnilQ5GNYFlyPPKOdS8lJUH6So2tI9eqDxg== X-Received: by 2002:a05:6e02:2163:b0:357:704a:8699 with SMTP id s3-20020a056e02216300b00357704a8699mr10683602ilv.8.1698522344165; Sat, 28 Oct 2023 12:45:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 22/35] tcg/sparc64: Support TCG_COND_TST{EQ,NE} Date: Sat, 28 Oct 2023 12:45:09 -0700 Message-Id: <20231028194522.245170-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::12b; envelope-from=richard.henderson@linaro.org; helo=mail-il1-x12b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522489633100007 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/sparc64/tcg-target.c.inc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tcg/sparc64/tcg-target.c.inc b/tcg/sparc64/tcg-target.c.inc index 10fb8a1a0d..176c98740b 100644 --- a/tcg/sparc64/tcg-target.c.inc +++ b/tcg/sparc64/tcg-target.c.inc @@ -607,9 +607,11 @@ static void tcg_out_div32(TCGContext *s, TCGReg rd, TC= GReg rs1, uns ? ARITH_UDIV : ARITH_SDIV); } =20 -static const uint8_t tcg_cond_to_bcond[] =3D { +static const uint8_t tcg_cond_to_bcond[16] =3D { [TCG_COND_EQ] =3D COND_E, [TCG_COND_NE] =3D COND_NE, + [TCG_COND_TSTEQ] =3D COND_E, + [TCG_COND_TSTNE] =3D COND_NE, [TCG_COND_LT] =3D COND_L, [TCG_COND_GE] =3D COND_GE, [TCG_COND_LE] =3D COND_LE, @@ -649,7 +651,8 @@ static void tcg_out_bpcc(TCGContext *s, int scond, int = flags, TCGLabel *l) static void tcg_out_cmp(TCGContext *s, TCGCond cond, TCGReg c1, int32_t c2, int c2const) { - tcg_out_arithc(s, TCG_REG_G0, c1, c2, c2const, ARITH_SUBCC); + tcg_out_arithc(s, TCG_REG_G0, c1, c2, c2const, + is_tst_cond(cond) ? ARITH_ANDCC : ARITH_SUBCC); } =20 static void tcg_out_brcond_i32(TCGContext *s, TCGCond cond, TCGReg arg1, @@ -744,6 +747,15 @@ static void tcg_out_setcond_i32(TCGContext *s, TCGCond= cond, TCGReg ret, cond =3D (cond =3D=3D TCG_COND_EQ ? TCG_COND_GEU : TCG_COND_LTU); break; =20 + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + /* Transform to inequality vs zero. */ + tcg_out_arithc(s, TCG_REG_T1, c1, c2, c2const, ARITH_AND); + c1 =3D TCG_REG_G0; + c2 =3D TCG_REG_T1, c2const =3D 0; + cond =3D (cond =3D=3D TCG_COND_TSTEQ ? TCG_COND_GEU : TCG_COND_LTU= ); + break; + case TCG_COND_GTU: case TCG_COND_LEU: /* If we don't need to load a constant into a register, we can --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522569; cv=none; d=zohomail.com; s=zohoarc; b=Y/Mii4rVeB/GwR+ai3A3ey5GK+dJlgavo9RRW9cZZ/zMalSDSv59SYxC9WqDizJUErW5lt+MrpbsrfT/rQ2uqYfGFQqQFuHtWHeHP5iRvQL4VVQCa0pQHwiRAxjPq7LR+MINDGGYAzqP8knvUlVjC792GwfLkQRDNhpRawgqIfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522569; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GQqAIZ7Xh7BNepoaMPlY+YxkKXZzZN5XYqBDd4SweoE=; b=eXQ5DnvjvJUHTj1n4ArYZdLnE8zWJVeK4OPxyHI1zfXcdvZTWIFazBohSzz+6PdFIJ5pVhF49ZMNro/LYIUd/cDynFIHspNL37z27SJR+7rSYA4k29y92Rq7+FfQFipUKND4clWEKUsUMTbHoh80G1FkpYGZuqZtrbaBXCtP2Jk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522569852108.24489097060814; Sat, 28 Oct 2023 12:49:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpG1-0004v1-47; Sat, 28 Oct 2023 15:46:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFk-0004l6-93 for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:49 -0400 Received: from mail-il1-x12b.google.com ([2607:f8b0:4864:20::12b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFi-00049W-28 for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:47 -0400 Received: by mail-il1-x12b.google.com with SMTP id e9e14a558f8ab-3577ce73552so9702295ab.2 for ; Sat, 28 Oct 2023 12:45:45 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522345; x=1699127145; 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=GQqAIZ7Xh7BNepoaMPlY+YxkKXZzZN5XYqBDd4SweoE=; b=lqe2NBNvhpGXDAetg4hf8J4xMjDUxWOyLj7HQoIcsAA4F76I9X8l9dq4O145n7BojG wP3OiZgw8fbhoex5dHFGwURT8GyJSdssEtcNaggQYU/Athy6DKTDnlYmsZ1qxoGQ8XxK /cCtRJgRjkYBzklMDjt3JA2TY4FfiAvnCl28XzT2kLUqkJ6NsZ9/FcM/Q91JUy7zY4qF 7u5dT0Q9UadIdq6qCcbxOMni8WI4xQ4afrhtu+K1ZU+iACGSYdvWChCQQLXa62Ql+pSM Y8nRDoUGbSSmhtqlXNDpbfziujx7aUMmZZqQm5bSoQRoXnaD78vJLZjcp6dmEGCkdOhD xIbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522345; x=1699127145; 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=GQqAIZ7Xh7BNepoaMPlY+YxkKXZzZN5XYqBDd4SweoE=; b=BJ1xPSeQCpSMJjsr2xcuulYljrMJ8O6kLml3ojj1nLYfYBdD2/rudWtywd3VPc9AbA a/cvvIwYw/K7tD6yYJcp13MjO9wHYwVy25BzoQC4KMleoKAHKalyOFlNNYIlyDsjR+rG uZrBOE+AX0WG2O5eTWblJI25LmZbPG14GBt9uqqepQG9eAEEsxJ16uHvxgrJpmwA+N5+ cXAnQ3yWwY0GWOoo0PmDMLE5wkX1YA61lISAE+2k/59RYQauxBm5wEfy7O/wjpblCX+1 zMruSQULmX2R5KP0VV1er4P0OXKl0dKBzxFMdkKchKNYoMtb/cBbUfMH3WRdqM2gV5lc iX7Q== X-Gm-Message-State: AOJu0YzViYZ6gzqZGhSmFO8OCmC7NwY2+5TfYL27TJuCcbm0OgY034RU ct6hFwdVTBKWUgqocDw67HfmNPJQmHJqYF7+lts= X-Google-Smtp-Source: AGHT+IG+F8c6PA4k4v5a2yykqAsxLRjq4pM135v00Qk0m/vmb4IcX8WzxJ4m5jfWDBvVhRhYrOVB2A== X-Received: by 2002:a05:6e02:748:b0:359:92:48aa with SMTP id x8-20020a056e02074800b00359009248aamr5196351ils.28.1698522345032; Sat, 28 Oct 2023 12:45:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 23/35] tcg/ppc: Sink tcg_to_bc usage into tcg_out_bc Date: Sat, 28 Oct 2023 12:45:10 -0700 Message-Id: <20231028194522.245170-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::12b; envelope-from=richard.henderson@linaro.org; helo=mail-il1-x12b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522571324100005 Content-Type: text/plain; charset="utf-8" Rename the current tcg_out_bc function to tcg_out_bc_lab, and create a new function that takes an integer displacement + link. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 a5871f55b1..ca281dd33e 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -1946,14 +1946,20 @@ static void tcg_out_setcond(TCGContext *s, TCGType = type, TCGCond cond, } } =20 -static void tcg_out_bc(TCGContext *s, int bc, TCGLabel *l) +static void tcg_out_bc(TCGContext *s, TCGCond cond, int bd) { + tcg_out32(s, tcg_to_bc[cond] | bd); +} + +static void tcg_out_bc_lab(TCGContext *s, TCGCond cond, TCGLabel *l) +{ + int bd =3D 0; if (l->has_value) { - bc |=3D reloc_pc14_val(tcg_splitwx_to_rx(s->code_ptr), l->u.value_= ptr); + bd =3D reloc_pc14_val(tcg_splitwx_to_rx(s->code_ptr), l->u.value_p= tr); } else { tcg_out_reloc(s, s->code_ptr, R_PPC_REL14, l, 0); } - tcg_out32(s, bc); + tcg_out_bc(s, cond, bd); } =20 static void tcg_out_brcond(TCGContext *s, TCGCond cond, @@ -1961,7 +1967,7 @@ static void tcg_out_brcond(TCGContext *s, TCGCond con= d, TCGLabel *l, TCGType type) { tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 7, type); - tcg_out_bc(s, tcg_to_bc[cond], l); + tcg_out_bc_lab(s, cond, l); } =20 static void tcg_out_movcond(TCGContext *s, TCGType type, TCGCond cond, @@ -2003,7 +2009,7 @@ static void tcg_out_movcond(TCGContext *s, TCGType ty= pe, TCGCond cond, } } /* Branch forward over one insn */ - tcg_out32(s, tcg_to_bc[cond] | 8); + tcg_out_bc(s, cond, 8); if (v2 =3D=3D 0) { tcg_out_movi(s, type, dest, 0); } else { @@ -2024,11 +2030,11 @@ static void tcg_out_cntxz(TCGContext *s, TCGType ty= pe, uint32_t opc, tcg_out32(s, opc | RA(TCG_REG_R0) | RS(a1)); tcg_out32(s, tcg_to_isel[TCG_COND_EQ] | TAB(a0, a2, TCG_REG_R0= )); } else if (!const_a2 && a0 =3D=3D a2) { - tcg_out32(s, tcg_to_bc[TCG_COND_EQ] | 8); + tcg_out_bc(s, TCG_COND_EQ, 8); tcg_out32(s, opc | RA(a0) | RS(a1)); } else { tcg_out32(s, opc | RA(a0) | RS(a1)); - tcg_out32(s, tcg_to_bc[TCG_COND_NE] | 8); + tcg_out_bc(s, TCG_COND_NE, 8); if (const_a2) { tcg_out_movi(s, type, a0, 0); } else { @@ -2108,11 +2114,11 @@ static void tcg_out_setcond2(TCGContext *s, const T= CGArg *args, tcg_out_rlw(s, RLWINM, args[0], TCG_REG_R0, 31, 31, 31); } =20 -static void tcg_out_brcond2 (TCGContext *s, const TCGArg *args, - const int *const_args) +static void tcg_out_brcond2(TCGContext *s, const TCGArg *args, + const int *const_args) { tcg_out_cmp2(s, args, const_args); - tcg_out_bc(s, BC | BI(7, CR_EQ) | BO_COND_TRUE, arg_label(args[5])); + tcg_out_bc_lab(s, TCG_COND_EQ, arg_label(args[5])); } =20 static void tcg_out_mb(TCGContext *s, TCGArg a0) @@ -2446,7 +2452,7 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext= *s, HostAddress *h, =20 /* Load a pointer into the current opcode w/conditional branch-lin= k. */ ldst->label_ptr[0] =3D s->code_ptr; - tcg_out32(s, BC | BI(7, CR_EQ) | BO_COND_FALSE | LK); + tcg_out_bc(s, TCG_COND_NE, LK); =20 h->base =3D TCG_REG_TMP1; } else { --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522484; cv=none; d=zohomail.com; s=zohoarc; b=bhOXj7wQF7OJrRNxYid0s3Opdlhd2gC6zbi9uUpfDTJvyAIS4+AG2sue/Z5HbcX7PAMc4YpNYEAlmt7pSHeNdJicqJOsSn7+jx6Vhu18tiI++B6e/8mw8d+pBHFtVfItJbHoe705jzIdaBAfvqGdxkkehdS8OQ+9Wd/maEwQNMI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522484; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XWynlm/jnWba87671dZ3jT3T3Pz1rJpw/GEtPhdBxeA=; b=eT7njgomc022fiSxaFGFQWt/pXhOZQePaXkR/UJReFW0CJUDl272UDRPQnTFC9pjtI90TtuXqdsXvhrOAydCR/oPfnRxAXjUbuUb3QbpzJDrwnCueddS0GZYRLUdstpCC+37BVcf/uf23p3kuTjR57IsCNlGIIVJnp/RatJriIo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522484889757.6270950609473; Sat, 28 Oct 2023 12:48:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpFw-0004qK-9c; Sat, 28 Oct 2023 15:46:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFl-0004l9-6w for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:50 -0400 Received: from mail-oa1-x35.google.com ([2001:4860:4864:20::35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFj-00049m-Ce for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:48 -0400 Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-1e0ee4e777bso2117959fac.3 for ; Sat, 28 Oct 2023 12:45:46 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522346; x=1699127146; 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=XWynlm/jnWba87671dZ3jT3T3Pz1rJpw/GEtPhdBxeA=; b=gMKwFBnS30D9z859HPNrbUM6qEfVK+TnB7zGMZx8Rk94EGZM1UeambTamJCprLJ5T3 MlQWoqskXopizQ0h9Rv65klHpwvMmSqe9d+CcrIzyviZdemWK6rjsrzcKczmPk3OJEB+ y1LICGivKtrh4bAsGXxzAtd/nagXRo+77amfvRCIO4FTn5f4auz00IEs/rqUpzuTDQ0V KDHFh+JOk/7d1KIJIBjYzvBh1N4/xLjStm6n6akcMGFA2nXKOTbxw9Yov3rH+m0EB+7X 6CS9dO13k7Fxh8umufg+tfr3oIvTkC+jtgzjv43NJyfARtGju/h/isJTM5/Zjnm65YQk IQSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522346; x=1699127146; 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=XWynlm/jnWba87671dZ3jT3T3Pz1rJpw/GEtPhdBxeA=; b=qZEzfY/VOgdL5UDG70w/042QyIybSb1CyF/k+svycF/PbNR/8fCWnwg7F7oYXGJYoC zR7uo8v5fOwr/Kz2VHG04QMBRm+0SeVlhGRBds/uuviB4OeW1R8aDGDBfwWSzhKdny/f tQ/0S5liBiKa8K6gkwNO5AARcs+YyoMFF0z2RhC8DvAQIVpGlk1942/2MroePU0Z6VjY bMkxKaFvbNAeJ3tuqpgRvn1OB+VmH+urTM+4WQPSZ/kknHjVx/l56XfstScb7hI+yO3a /oQgghlv9gh5INRElcWz0j3oFPmNZXXtkXKe0zRoMQ6FRIhBQm32QVU9j+W6cFKWFz15 B9aQ== X-Gm-Message-State: AOJu0YwsagAE6nLrxOtXp38ALaZzqLMeCMDaRp32O8xVYM9Uu8O+mROU mCC3AmL4sMNROvXTCmy2QiP7lhECtUVBQNiz2+g= X-Google-Smtp-Source: AGHT+IF/MhrPqERbqvkCe2O0yvsbJk+zvTLj0F6ST7SJ1Js8NZW7P28F6LKK6DKj2zgDNh//Q7R+zg== X-Received: by 2002:a05:6358:2806:b0:168:e48a:8b25 with SMTP id k6-20020a056358280600b00168e48a8b25mr6960551rwb.0.1698522345874; Sat, 28 Oct 2023 12:45:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 24/35] tcg/ppc: Use cr0 in tcg_to_bc and tcg_to_isel Date: Sat, 28 Oct 2023 12:45:11 -0700 Message-Id: <20231028194522.245170-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::35; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x35.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522485508100001 Content-Type: text/plain; charset="utf-8" Using cr0 means we could choose to use rc=3D1 to compute the condition. Adjust the tables and tcg_out_cmp that feeds them. Signed-off-by: Richard Henderson --- 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 ca281dd33e..1ac11acc7c 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -671,30 +671,30 @@ enum { }; =20 static const uint32_t tcg_to_bc[] =3D { - [TCG_COND_EQ] =3D BC | BI(7, CR_EQ) | BO_COND_TRUE, - [TCG_COND_NE] =3D BC | BI(7, CR_EQ) | BO_COND_FALSE, - [TCG_COND_LT] =3D BC | BI(7, CR_LT) | BO_COND_TRUE, - [TCG_COND_GE] =3D BC | BI(7, CR_LT) | BO_COND_FALSE, - [TCG_COND_LE] =3D BC | BI(7, CR_GT) | BO_COND_FALSE, - [TCG_COND_GT] =3D BC | BI(7, CR_GT) | BO_COND_TRUE, - [TCG_COND_LTU] =3D BC | BI(7, CR_LT) | BO_COND_TRUE, - [TCG_COND_GEU] =3D BC | BI(7, CR_LT) | BO_COND_FALSE, - [TCG_COND_LEU] =3D BC | BI(7, CR_GT) | BO_COND_FALSE, - [TCG_COND_GTU] =3D BC | BI(7, CR_GT) | BO_COND_TRUE, + [TCG_COND_EQ] =3D BC | BI(0, CR_EQ) | BO_COND_TRUE, + [TCG_COND_NE] =3D BC | BI(0, CR_EQ) | BO_COND_FALSE, + [TCG_COND_LT] =3D BC | BI(0, CR_LT) | BO_COND_TRUE, + [TCG_COND_GE] =3D BC | BI(0, CR_LT) | BO_COND_FALSE, + [TCG_COND_LE] =3D BC | BI(0, CR_GT) | BO_COND_FALSE, + [TCG_COND_GT] =3D BC | BI(0, CR_GT) | BO_COND_TRUE, + [TCG_COND_LTU] =3D BC | BI(0, CR_LT) | BO_COND_TRUE, + [TCG_COND_GEU] =3D BC | BI(0, CR_LT) | BO_COND_FALSE, + [TCG_COND_LEU] =3D BC | BI(0, CR_GT) | BO_COND_FALSE, + [TCG_COND_GTU] =3D BC | BI(0, CR_GT) | BO_COND_TRUE, }; =20 /* The low bit here is set if the RA and RB fields must be inverted. */ static const uint32_t tcg_to_isel[] =3D { - [TCG_COND_EQ] =3D ISEL | BC_(7, CR_EQ), - [TCG_COND_NE] =3D ISEL | BC_(7, CR_EQ) | 1, - [TCG_COND_LT] =3D ISEL | BC_(7, CR_LT), - [TCG_COND_GE] =3D ISEL | BC_(7, CR_LT) | 1, - [TCG_COND_LE] =3D ISEL | BC_(7, CR_GT) | 1, - [TCG_COND_GT] =3D ISEL | BC_(7, CR_GT), - [TCG_COND_LTU] =3D ISEL | BC_(7, CR_LT), - [TCG_COND_GEU] =3D ISEL | BC_(7, CR_LT) | 1, - [TCG_COND_LEU] =3D ISEL | BC_(7, CR_GT) | 1, - [TCG_COND_GTU] =3D ISEL | BC_(7, CR_GT), + [TCG_COND_EQ] =3D ISEL | BC_(0, CR_EQ), + [TCG_COND_NE] =3D ISEL | BC_(0, CR_EQ) | 1, + [TCG_COND_LT] =3D ISEL | BC_(0, CR_LT), + [TCG_COND_GE] =3D ISEL | BC_(0, CR_LT) | 1, + [TCG_COND_LE] =3D ISEL | BC_(0, CR_GT) | 1, + [TCG_COND_GT] =3D ISEL | BC_(0, CR_GT), + [TCG_COND_LTU] =3D ISEL | BC_(0, CR_LT), + [TCG_COND_GEU] =3D ISEL | BC_(0, CR_LT) | 1, + [TCG_COND_LEU] =3D ISEL | BC_(0, CR_GT) | 1, + [TCG_COND_GTU] =3D ISEL | BC_(0, CR_GT), }; =20 static bool patch_reloc(tcg_insn_unit *code_ptr, int type, @@ -1827,7 +1827,7 @@ static void tcg_out_setcond(TCGContext *s, TCGType ty= pe, TCGCond cond, if (have_isa_3_10) { tcg_insn_unit bi, opc; =20 - tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 7, type); + tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 0, type); =20 /* Re-use tcg_to_bc for BI and BO_COND_{TRUE,FALSE}. */ bi =3D tcg_to_bc[cond] & (0x1f << 16); @@ -1880,7 +1880,7 @@ static void tcg_out_setcond(TCGContext *s, TCGType ty= pe, TCGCond cond, if (have_isel) { int isel, tab; =20 - tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 7, type); + tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 0, type); =20 isel =3D tcg_to_isel[cond]; =20 @@ -1966,7 +1966,7 @@ static void tcg_out_brcond(TCGContext *s, TCGCond con= d, TCGArg arg1, TCGArg arg2, int const_arg2, TCGLabel *l, TCGType type) { - tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 7, type); + tcg_out_cmp(s, cond, arg1, arg2, const_arg2, 0, type); tcg_out_bc_lab(s, cond, l); } =20 @@ -1980,7 +1980,7 @@ static void tcg_out_movcond(TCGContext *s, TCGType ty= pe, TCGCond cond, return; } =20 - tcg_out_cmp(s, cond, c1, c2, const_c2, 7, type); + tcg_out_cmp(s, cond, c1, c2, const_c2, 0, type); =20 if (have_isel) { int isel =3D tcg_to_isel[cond]; @@ -2024,7 +2024,7 @@ static void tcg_out_cntxz(TCGContext *s, TCGType type= , uint32_t opc, if (const_a2 && a2 =3D=3D (type =3D=3D TCG_TYPE_I32 ? 32 : 64)) { tcg_out32(s, opc | RA(a0) | RS(a1)); } else { - tcg_out_cmp(s, TCG_COND_EQ, a1, 0, 1, 7, type); + tcg_out_cmp(s, TCG_COND_EQ, a1, 0, 1, 0, type); /* Note that the only other valid constant for a2 is 0. */ if (have_isel) { tcg_out32(s, opc | RA(TCG_REG_R0) | RS(a1)); @@ -2079,7 +2079,7 @@ static void tcg_out_cmp2(TCGContext *s, const TCGArg = *args, do_equality: tcg_out_cmp(s, cond, al, bl, blconst, 6, TCG_TYPE_I32); tcg_out_cmp(s, cond, ah, bh, bhconst, 7, TCG_TYPE_I32); - tcg_out32(s, op | BT(7, CR_EQ) | BA(6, CR_EQ) | BB(7, CR_EQ)); + tcg_out32(s, op | BT(0, CR_EQ) | BA(6, CR_EQ) | BB(7, CR_EQ)); break; =20 case TCG_COND_LT: @@ -2097,8 +2097,8 @@ static void tcg_out_cmp2(TCGContext *s, const TCGArg = *args, =20 tcg_out_cmp(s, cond, ah, bh, bhconst, 6, TCG_TYPE_I32); tcg_out_cmp(s, cond2, al, bl, blconst, 7, TCG_TYPE_I32); - tcg_out32(s, op | BT(7, CR_EQ) | BA(6, CR_EQ) | BB(7, bit2)); - tcg_out32(s, CROR | BT(7, CR_EQ) | BA(6, bit1) | BB(7, CR_EQ)); + tcg_out32(s, op | BT(0, CR_EQ) | BA(6, CR_EQ) | BB(7, bit2)); + tcg_out32(s, CROR | BT(0, CR_EQ) | BA(6, bit1) | BB(0, CR_EQ)); break; =20 default: @@ -2110,8 +2110,8 @@ static void tcg_out_setcond2(TCGContext *s, const TCG= Arg *args, const int *const_args) { tcg_out_cmp2(s, args + 1, const_args + 1); - tcg_out32(s, MFOCRF | RT(TCG_REG_R0) | FXM(7)); - tcg_out_rlw(s, RLWINM, args[0], TCG_REG_R0, 31, 31, 31); + tcg_out32(s, MFOCRF | RT(TCG_REG_R0) | FXM(0)); + tcg_out_rlw(s, RLWINM, args[0], TCG_REG_R0, CR_EQ + 0*4 + 1, 31, 31); } =20 static void tcg_out_brcond2(TCGContext *s, const TCGArg *args, @@ -2442,12 +2442,12 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGConte= xt *s, HostAddress *h, tcg_out_cmp(s, TCG_COND_EQ, addrhi, TCG_REG_TMP2, 0, 6, TCG_TYPE_I32); =20 - /* Combine comparisons into cr7. */ - tcg_out32(s, CRAND | BT(7, CR_EQ) | BA(6, CR_EQ) | BB(7, CR_EQ= )); + /* Combine comparisons into cr0. */ + tcg_out32(s, CRAND | BT(0, CR_EQ) | BA(6, CR_EQ) | BB(7, CR_EQ= )); } else { - /* Full comparison into cr7. */ + /* Full comparison into cr0. */ tcg_out_cmp(s, TCG_COND_EQ, TCG_REG_R0, TCG_REG_TMP2, - 0, 7, addr_type); + 0, 0, addr_type); } =20 /* Load a pointer into the current opcode w/conditional branch-lin= k. */ --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522520; cv=none; d=zohomail.com; s=zohoarc; b=XKeKZT3/bPEzY3Pw/5T0ommh0rvyqDOX4xjgzGDhPymfrhZSupGCtxenGBpMBXq6YR/IWBxbaoxj/B5eBWfwQFZPk+g1SaI9zmQ95RVdvMzvTTy6iMQAbQ9GghtPd/HB/nzi1GfU8/zjVcKhdTSVjJE3uZB3SZ5XIoUtXAUkHII= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522520; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ajiz1bDFNjKojGZgG2uqP1JdM6uHPJtL3w2kXcO5r5w=; b=WuMGP5hQvlBcvPcuB3nws4d9eu24N2PEzWAihSxRBtdQvwaXdLBsbpym2nU3QYkaP6xES/qtsbOB++3ElH9W6CvetB68hPNveay3fRbOU013cx+FQk21zvSx9FBWhl2k/jD/8IbMqmiRqSlOd82VxVseDxGXdA/cz0yod10woDc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522520924877.4945561580193; Sat, 28 Oct 2023 12:48:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpFu-0004pz-MZ; Sat, 28 Oct 2023 15:45:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFl-0004lI-NY for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:51 -0400 Received: from mail-oa1-x2c.google.com ([2001:4860:4864:20::2c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFk-00049w-2D for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:49 -0400 Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-1e9ac336589so2124010fac.1 for ; Sat, 28 Oct 2023 12:45:47 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522347; x=1699127147; 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=Ajiz1bDFNjKojGZgG2uqP1JdM6uHPJtL3w2kXcO5r5w=; b=lXo5BSW03gu389XMTcBHm7o2qbDjmCURDS+yww+VfOliizxBkIcEtZ+jrECJY41Eap u9mCg6Ky3p0jU4bAGtbus28rgDgPoNv060zf5fyiDHZP2z+UFVWGc4rPL0atJixAtWyg +AH6ILJnXpA9DTcBWP0+mTajJ8oaYWWekdiYu4ox6T6a9GriocykPx4rCpWe3+qxtdqz 4wEbYR0vGGZ7GgTuouCuVPH96we9TcJV6YvTxKEY5L9sY+Z4s4dj+mq8LHYvncy9cwo1 Yg1FkCbdKT8n9ZAU2Bc/UkM7kR2RUmSLurgl2t3DM5EpDKajUiEtKNnV181BLWdhIOQf MQgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522347; x=1699127147; 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=Ajiz1bDFNjKojGZgG2uqP1JdM6uHPJtL3w2kXcO5r5w=; b=ZpXIXFd115nPXplefZpLeGD29vGFjzyjNrk7AUmZPSQkTcGJ62oUnUbyj+SvdxaMtv 0LGKcmo7rtKaM5MVMDpzF6c7jeUoZ3H0VnqFMTwIc8TJxIbBaMUSe8+EpkHSBDz+Qdr7 AXzsuqm6+9ZZmfORM7J9o9b49orgJTvvLpjKHjZQT5DlrpOe8BABFeMLI4omFl12uPgp PdYromiuRrzw5EGBA1KCyfHwpQOBOfyzYWMwY8MxU0ixkP68GpB0GYv6D/utu6mlj4iO T1BrZwZIiSFvhf4GA8QCjhiUC+NbMLXA6XAknywXWAnR5t2wdcfZLPKrIKMtlbmSoDg6 3vtA== X-Gm-Message-State: AOJu0YztXtj1UdyKf9io1l7P9yf2PkFOfOls/c4KkC7TiphpxnwIxHhN OFtNBN0Gfapyqu9P4ayTrvZQqo68dRlo8+4Nz38= X-Google-Smtp-Source: AGHT+IGY9nA3kzAV4qvh9tMrla85xGPo2cIuXmmyEf0JZQtUHA0lDWVLk1w8MjYSxor5L6Iy6hujZg== X-Received: by 2002:a05:6358:e497:b0:168:e887:2646 with SMTP id by23-20020a056358e49700b00168e8872646mr7273805rwb.29.1698522346735; Sat, 28 Oct 2023 12:45:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 25/35] tcg/ppc: Tidy up tcg_target_const_match Date: Sat, 28 Oct 2023 12:45:12 -0700 Message-Id: <20231028194522.245170-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::2c; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522522235100007 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 1ac11acc7c..13d43ef9ba 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -282,31 +282,36 @@ static bool reloc_pc34(tcg_insn_unit *src_rw, const t= cg_insn_unit *target) } =20 /* test if a constant matches the constraint */ -static bool tcg_target_const_match(int64_t val, int ct, +static bool tcg_target_const_match(int64_t sval, int ct, TCGType type, TCGCond cond, int vece) { + uint64_t uval =3D sval; + if (ct & TCG_CT_CONST) { return 1; } =20 - /* The only 32-bit constraint we use aside from - TCG_CT_CONST is TCG_CT_CONST_S16. */ if (type =3D=3D TCG_TYPE_I32) { - val =3D (int32_t)val; + uval =3D (uint32_t)sval; + sval =3D (int32_t)sval; } =20 - if ((ct & TCG_CT_CONST_S16) && val =3D=3D (int16_t)val) { + if ((ct & TCG_CT_CONST_S16) && sval =3D=3D (int16_t)sval) { return 1; - } else if ((ct & TCG_CT_CONST_S32) && val =3D=3D (int32_t)val) { + } + if ((ct & TCG_CT_CONST_S32) && sval =3D=3D (int32_t)sval) { return 1; - } else if ((ct & TCG_CT_CONST_U32) && val =3D=3D (uint32_t)val) { + } + if ((ct & TCG_CT_CONST_U32) && uval =3D=3D (uint32_t)uval) { return 1; - } else if ((ct & TCG_CT_CONST_ZERO) && val =3D=3D 0) { + } + if ((ct & TCG_CT_CONST_ZERO) && sval =3D=3D 0) { return 1; - } else if ((ct & TCG_CT_CONST_MONE) && val =3D=3D -1) { + } + if ((ct & TCG_CT_CONST_MONE) && sval =3D=3D -1) { return 1; - } else if ((ct & TCG_CT_CONST_WSZ) - && val =3D=3D (type =3D=3D TCG_TYPE_I32 ? 32 : 64)) { + } + if ((ct & TCG_CT_CONST_WSZ) && sval =3D=3D (type =3D=3D TCG_TYPE_I32 ?= 32 : 64)) { return 1; } return 0; --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522628; cv=none; d=zohomail.com; s=zohoarc; b=ODAgKnENUTlDbVH1J2Y4oeUao0CO2644wNWa/dshTfWk/m+Rg67oE2lxQmJ0mvAsMYKVd1JeRiBACIy1thd3ExuSMdUrli2D+b37tUxbo4CeCJiwihu6xrGkpVIqcjAw/pOCOmSLPwSiGFm/hFp1eXmwwprdGoVRtdZ4eyFdcEc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522628; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BOiaD60Pop9BL/fjcx346e3KqYhFz6lBjdoxHSd51pk=; b=DTXQN9RL/GM6zZSeRkKtp+37EcsRw5pqpAJvPXpRp+HctLr/FL1CoZ+v1IUMXxXjfTHENB0F43ErrQQZU7Z30h4Ds+7Ik1Tu7GEUJ7/KTwKm/d4c618pfaSURNqhGf5maQBLsUS6AeFj2Yp+IPItL2QlTdEVeHuuKqtW2b8EOEM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522628599608.6197278697018; Sat, 28 Oct 2023 12:50:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpFx-0004r9-0c; Sat, 28 Oct 2023 15:46:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFm-0004lO-8T for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:52 -0400 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 1qwpFk-0004A3-K7 for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:50 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1cc20df5187so11929755ad.0 for ; Sat, 28 Oct 2023 12:45:48 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522347; x=1699127147; 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=BOiaD60Pop9BL/fjcx346e3KqYhFz6lBjdoxHSd51pk=; b=t+oVARTRUKyOzmwYYoMobKrEO2nEYvLYuj2FW7KDDv+1j1AW03rNnVBym5Nqp7CFcT R7mMOkikcpHDtenGXnIKYkGiraTGtVKMZMDyRcFWuo9yqcFFBAWnxLPGLvMiFMl3vku6 Z+OYn9RatKLptI8fZY3of/z+t+GHrnDz7SGTkG2Ke8YO7lHzrQUS5xCZ6HqpY+r/faRy uGo70HwThEmrSMzNaS+rprUElPh6Et7/DZrNkh/OVpJL9ZGisUV1qAZSymjdMfscLaFT QecV1cDakn+3M/3ACao/7ry5MtbH9LaaY1muRgDR1s67lKNqi3euXN9qSDPaWFcMIm2O nQ9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522347; x=1699127147; 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=BOiaD60Pop9BL/fjcx346e3KqYhFz6lBjdoxHSd51pk=; b=iNoOYJIxtcc3c5jn14gHaA7SVJ43lOlqSerkJD6Sen9DsuDLOdl29BkRpYYn/iRa0J es/meUg0L2UdpRknOgfXjouGiEO6liHx+qsU50vNeg0zoQ/f1k1vT0S9hbRbUeedy3Jo /9RvNEmNMW+XK/Z/SjNHoK4UHp9n8mtCGmID7BbjrHuMVMy8Unn3evuv3Ak9RMqjqgI/ 6GkecAy+NtqRSfJUQ10MNLVDIzkawuUvNpzXg/eLYRr8mXdZhDNrJ3fBoGYW/GeMJINq QmEjwl9YY/PwtJYwH4UxVk563AeKYwWwQGOZXnIuDl21ebh65CogV1rl96nDlGx2mFBq czxg== X-Gm-Message-State: AOJu0Yw1RPQYB8/UP1YdQ1kArgfGINblfab7aoMvqnf6H1v1y8d8DYCS FL20Oq2Ue7wUZ7z5sCojgz+TKYEKBm3gv5Tsujg= X-Google-Smtp-Source: AGHT+IHhVGlk7Q5HNc48ESxg0LAZ9VLmi1SGTuZo9qZlWxPJJyarXiOf/PydMQjiCudikLFWmAz+gw== X-Received: by 2002:a17:902:c949:b0:1bd:e258:a256 with SMTP id i9-20020a170902c94900b001bde258a256mr7554840pla.32.1698522347444; Sat, 28 Oct 2023 12:45:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 26/35] tcg/ppc: Add TCG_CT_CONST_CMP Date: Sat, 28 Oct 2023 12:45:13 -0700 Message-Id: <20231028194522.245170-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522630527100006 Content-Type: text/plain; charset="utf-8" Better constraint for tcg_out_cmp, based on the comparison. We can't yet remove the fallback to load constants into a scratch because of tcg_out_cmp2, but that path should not be as frequent. Signed-off-by: Richard Henderson --- 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 bbd7b21247..aa1dac8740 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_O2_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 13d43ef9ba..b20dbe036d 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -92,11 +92,13 @@ #define SZR (TCG_TARGET_REG_BITS / 8) =20 #define TCG_CT_CONST_S16 0x100 +#define TCG_CT_CONST_U16 0x200 #define TCG_CT_CONST_S32 0x400 #define TCG_CT_CONST_U32 0x800 #define TCG_CT_CONST_ZERO 0x1000 #define TCG_CT_CONST_MONE 0x2000 #define TCG_CT_CONST_WSZ 0x4000 +#define TCG_CT_CONST_CMP 0x8000 =20 #define ALL_GENERAL_REGS 0xffffffffu #define ALL_VECTOR_REGS 0xffffffff00000000ull @@ -296,9 +298,35 @@ static bool tcg_target_const_match(int64_t sval, int c= t, sval =3D (int32_t)sval; } =20 + if (ct & TCG_CT_CONST_CMP) { + switch (cond) { + case TCG_COND_EQ: + case TCG_COND_NE: + ct |=3D TCG_CT_CONST_S16 | TCG_CT_CONST_U16; + break; + case TCG_COND_LT: + case TCG_COND_GE: + case TCG_COND_LE: + case TCG_COND_GT: + ct |=3D TCG_CT_CONST_S16; + break; + case TCG_COND_LTU: + case TCG_COND_GEU: + case TCG_COND_LEU: + case TCG_COND_GTU: + ct |=3D TCG_CT_CONST_U16; + break; + default: + g_assert_not_reached(); + } + } + if ((ct & TCG_CT_CONST_S16) && sval =3D=3D (int16_t)sval) { return 1; } + if ((ct & TCG_CT_CONST_U16) && uval =3D=3D (uint16_t)uval) { + return 1; + } if ((ct & TCG_CT_CONST_S32) && sval =3D=3D (int32_t)sval) { return 1; } @@ -1682,7 +1710,10 @@ static void tcg_out_cmp(TCGContext *s, int cond, TCG= Arg arg1, TCGArg arg2, =20 tcg_debug_assert(TCG_TARGET_REG_BITS =3D=3D 64 || type =3D=3D TCG_TYPE= _I32); =20 - /* Simplify the comparisons below wrt CMPI. */ + /* + * Simplify the comparisons below wrt CMPI. + * All of the tests are 16-bit, so a 32-bit sign extend always works. + */ if (type =3D=3D TCG_TYPE_I32) { arg2 =3D (int32_t)arg2; } @@ -3990,8 +4021,6 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode op) case INDEX_op_sar_i32: case INDEX_op_rotl_i32: case INDEX_op_rotr_i32: - case INDEX_op_setcond_i32: - case INDEX_op_negsetcond_i32: case INDEX_op_and_i64: case INDEX_op_andc_i64: case INDEX_op_shl_i64: @@ -3999,8 +4028,6 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode op) case INDEX_op_sar_i64: case INDEX_op_rotl_i64: case INDEX_op_rotr_i64: - case INDEX_op_setcond_i64: - case INDEX_op_negsetcond_i64: return C_O1_I2(r, r, ri); =20 case INDEX_op_mul_i32: @@ -4044,11 +4071,16 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGO= pcode op) =20 case INDEX_op_brcond_i32: case INDEX_op_brcond_i64: - return C_O0_I2(r, ri); - + return C_O0_I2(r, rC); + case INDEX_op_setcond_i32: + case INDEX_op_setcond_i64: + case INDEX_op_negsetcond_i32: + case INDEX_op_negsetcond_i64: + return C_O1_I2(r, r, rC); case INDEX_op_movcond_i32: case INDEX_op_movcond_i64: - return C_O1_I4(r, r, ri, rZ, rZ); + return C_O1_I4(r, r, rC, rZ, rZ); + case INDEX_op_deposit_i32: case INDEX_op_deposit_i64: return C_O1_I2(r, 0, rZ); --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522493; cv=none; d=zohomail.com; s=zohoarc; b=fulx5zdgJdf1bDPn80T2S/24O1y2jdZROIh7b8AJ32N/20h2Zj0RDp/O9i/flVE7HG/yADjaQqIK3jwUlk+G+n2W0Q2tLyPGn5VBzvdvtLxZXjlD1480XPjoFPRHYyPdySEE4+8ecmzCsaYR2c10XZ2AWjWK27BbfzQ8xJFvq6Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522493; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iyWIBc/bae3SRvX15BHebB0rh43djQLxGZtPVa1AI4o=; b=ICUDtCmKMIydxYWC1i84g4u+2Ve6V3wWsm4Xt3ySBgDzt5xDgafwauvgWKx1qSUOTTi0+R8dA9df20UyWxarg0Gebcqg+52AvP0LPw8cmN+CcLz1eTJZB4MbScMPtVnz2zfjwaABWLi04OSkXrWbnOWfNXMHB0uKVeliaThLSu0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522493746569.6638385359751; Sat, 28 Oct 2023 12:48:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpG4-0004xz-UA; Sat, 28 Oct 2023 15:46:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFn-0004lV-8U for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:52 -0400 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 1qwpFl-0004AE-FV for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:51 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1cc329ce84cso5536705ad.2 for ; Sat, 28 Oct 2023 12:45:49 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522348; x=1699127148; 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=iyWIBc/bae3SRvX15BHebB0rh43djQLxGZtPVa1AI4o=; b=aeh1SuNwgKh5r7B244wojGKeav1pj3rMb8TuM+oSpa1LH1SCYIXhefXDlQiS3P9CJp Rz2fPeFYH6weA7XgTMzLaCZbF7ghH0BbLQ7H1FWJrXlQ8qg3z13GD4/JgRhlthlS6QE8 iu9Lan2HB6uxgM/btI1N+hjjOkas4RzToUEeb4xHv/LRlwU/uUKaSG7vqTERfSHqx1lc 3iqSDBWdqRIvuuiKHFZ+fGJKpjidbQNMXTYjV4VTDL5pYeOo/W0nb3Ra3gc0IlBGWWsR 5ewzfQ8PpTbQ/IAo1bIgfSMB+0meNMfJe+VY89k3DJJCX3jvEA8ljSLFTu32B/O/ywSd zGcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522348; x=1699127148; 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=iyWIBc/bae3SRvX15BHebB0rh43djQLxGZtPVa1AI4o=; b=fQ7Jt+LTcxy2l7W2ojEcugt116YHGwyCFRuEacMVZySYi+C1mNszOD3EEhUuAa347B LTNh7H3sik9yYvFj6b3oysMwsAbF+ZTIDRKmFUKiJ6NlKVnevt7wpfMqPd5LDytpW7Or ZhvFCij+PtQ9XbODZQhNJ5EFTcirgxqcT0oFmMPIPujulLQQIuXPK99Aa/EstwXsyosn Pt1n/a6vXruGX1TwrOUNiyNoOjPc6ZpvhEWb0lAL/E1rZN/3KJ5RXRASNh1PRQDGQxNI LAL0+DPGZiTCPo1EvMeT4VFiXsB203HP6LQOHj9OxbQD/ZZZ7VaTtuvXqYKueFUZrhF2 ZJ4w== X-Gm-Message-State: AOJu0YzSxgHu2Fhw6VIDgxIcFRbn8bhaGI5a259khLaOt7xxIshPqYGq JT6+2GLz12H03JqLn0nccD+eoLeV7J++thE/aSw= X-Google-Smtp-Source: AGHT+IFz2Dc+eS6oqrbO16D+fEo1AO3R/gSIjJSsFlcTo8qjchM0co6B7q51gA03yOMxJtdFlhb0WA== X-Received: by 2002:a17:902:cec7:b0:1c1:f6d1:3118 with SMTP id d7-20020a170902cec700b001c1f6d13118mr7463315plg.27.1698522348216; Sat, 28 Oct 2023 12:45:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 27/35] tcg/ppc: Support TCG_COND_TST{EQ,NE} Date: Sat, 28 Oct 2023 12:45:14 -0700 Message-Id: <20231028194522.245170-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522495823100006 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.c.inc | 105 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 98 insertions(+), 7 deletions(-) diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index b20dbe036d..ef1d959892 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -703,9 +703,11 @@ enum { CR_SO }; =20 -static const uint32_t tcg_to_bc[] =3D { +static const uint32_t tcg_to_bc[16] =3D { [TCG_COND_EQ] =3D BC | BI(0, CR_EQ) | BO_COND_TRUE, [TCG_COND_NE] =3D BC | BI(0, CR_EQ) | BO_COND_FALSE, + [TCG_COND_TSTEQ] =3D BC | BI(0, CR_EQ) | BO_COND_TRUE, + [TCG_COND_TSTNE] =3D BC | BI(0, CR_EQ) | BO_COND_FALSE, [TCG_COND_LT] =3D BC | BI(0, CR_LT) | BO_COND_TRUE, [TCG_COND_GE] =3D BC | BI(0, CR_LT) | BO_COND_FALSE, [TCG_COND_LE] =3D BC | BI(0, CR_GT) | BO_COND_FALSE, @@ -717,9 +719,11 @@ static const uint32_t tcg_to_bc[] =3D { }; =20 /* The low bit here is set if the RA and RB fields must be inverted. */ -static const uint32_t tcg_to_isel[] =3D { +static const uint32_t tcg_to_isel[16] =3D { [TCG_COND_EQ] =3D ISEL | BC_(0, CR_EQ), [TCG_COND_NE] =3D ISEL | BC_(0, CR_EQ) | 1, + [TCG_COND_TSTEQ] =3D ISEL | BC_(0, CR_EQ), + [TCG_COND_TSTNE] =3D ISEL | BC_(0, CR_EQ) | 1, [TCG_COND_LT] =3D ISEL | BC_(0, CR_LT), [TCG_COND_GE] =3D ISEL | BC_(0, CR_LT) | 1, [TCG_COND_LE] =3D ISEL | BC_(0, CR_GT) | 1, @@ -872,21 +876,33 @@ static bool tcg_out_mov(TCGContext *s, TCGType type, = TCGReg ret, TCGReg arg) return true; } =20 -static inline void tcg_out_rld(TCGContext *s, int op, TCGReg ra, TCGReg rs, - int sh, int mb) +static void tcg_out_rld_rc(TCGContext *s, int op, TCGReg ra, TCGReg rs, + int sh, int mb, bool rc) { tcg_debug_assert(TCG_TARGET_REG_BITS =3D=3D 64); sh =3D SH(sh & 0x1f) | (((sh >> 5) & 1) << 1); mb =3D MB64((mb >> 5) | ((mb << 1) & 0x3f)); - tcg_out32(s, op | RA(ra) | RS(rs) | sh | mb); + tcg_out32(s, op | RA(ra) | RS(rs) | sh | mb | rc); } =20 -static inline void tcg_out_rlw(TCGContext *s, int op, TCGReg ra, TCGReg rs, - int sh, int mb, int me) +static void tcg_out_rld(TCGContext *s, int op, TCGReg ra, TCGReg rs, + int sh, int mb) +{ + tcg_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)); } =20 +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) { tcg_out32(s, EXTSB | RA(dst) | RS(src)); @@ -1702,6 +1718,50 @@ static inline bool tcg_out_sti(TCGContext *s, TCGTyp= e type, TCGArg val, return false; } =20 +/* + * Set dest non-zero if and only if (arg1 & arg2) is non-zero. + * If RC, then also set RC0. + */ +static void tcg_out_test(TCGContext *s, TCGReg dest, TCGReg arg1, TCGArg a= rg2, + bool const_arg2, TCGType type, bool rc) +{ + int mb, me; + + if (!const_arg2) { + tcg_out32(s, AND | SAB(arg1, dest, arg2) | rc); + return; + } + + if (type =3D=3D TCG_TYPE_I32) { + arg2 =3D (uint32_t)arg2; + } else if (arg2 =3D=3D (uint32_t)arg2) { + type =3D TCG_TYPE_I32; + } + + if ((arg2 & ~0xffff) =3D=3D 0) { + tcg_out32(s, ANDI | SAI(arg1, dest, arg2)); + return; + } + if ((arg2 & ~0xffff0000ull) =3D=3D 0) { + tcg_out32(s, ANDI | SAI(arg1, dest, arg2)); + return; + } + if (type =3D=3D TCG_TYPE_I32) { + if (mask_operand(arg2, &mb, &me)) { + tcg_out_rlw_rc(s, RLWINM, dest, arg1, 0, mb, me, rc); + return; + } + } else { + int sh =3D clz64(arg2); + if (mask64_operand(arg2 << sh, &mb, &me)) { + tcg_out_rld_rc(s, RLDICR, dest, arg1, sh, me, rc); + return; + } + } + /* Constraints should satisfy this. */ + g_assert_not_reached(); +} + static void tcg_out_cmp(TCGContext *s, int cond, TCGArg arg1, TCGArg arg2, int const_arg2, int cr, TCGType type) { @@ -1736,6 +1796,12 @@ static void tcg_out_cmp(TCGContext *s, int cond, TCG= Arg arg1, TCGArg arg2, imm =3D 0; break; =20 + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + tcg_debug_assert(cr =3D=3D 0); + tcg_out_test(s, TCG_REG_R0, arg1, arg2, const_arg2, type, true); + return; + case TCG_COND_LT: case TCG_COND_GE: case TCG_COND_LE: @@ -1946,6 +2012,16 @@ static void tcg_out_setcond(TCGContext *s, TCGType t= ype, TCGCond cond, tcg_out_setcond_ne0(s, type, arg0, arg1, neg); break; =20 + case TCG_COND_TSTEQ: + tcg_out_test(s, TCG_REG_R0, arg1, arg2, const_arg2, type, false); + tcg_out_setcond_eq0(s, type, arg0, TCG_REG_R0, neg); + break; + + case TCG_COND_TSTNE: + tcg_out_test(s, TCG_REG_R0, arg1, arg2, const_arg2, type, false); + tcg_out_setcond_ne0(s, type, arg0, TCG_REG_R0, neg); + break; + case TCG_COND_LE: case TCG_COND_LEU: inv =3D true; @@ -2118,6 +2194,21 @@ static void tcg_out_cmp2(TCGContext *s, const TCGArg= *args, tcg_out32(s, op | BT(0, CR_EQ) | BA(6, CR_EQ) | BB(7, CR_EQ)); break; =20 + case TCG_COND_TSTEQ: + case TCG_COND_TSTNE: + if (blconst) { + tcg_out_andi32(s, TCG_REG_R0, al, bl); + } else { + tcg_out32(s, AND | SAB(al, TCG_REG_R0, bl)); + } + if (bhconst) { + tcg_out_andi32(s, TCG_REG_TMP1, ah, bh); + } else { + tcg_out32(s, AND | SAB(ah, TCG_REG_TMP1, bh)); + } + tcg_out32(s, OR | SAB(TCG_REG_R0, TCG_REG_R0, TCG_REG_TMP1) | 1); + break; + case TCG_COND_LT: case TCG_COND_LE: case TCG_COND_GT: --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522470; cv=none; d=zohomail.com; s=zohoarc; b=czhdtAf+pM3SQjz7qtXzbgYcOZ90eZqs6ThWFCvukWJHMse0bFD8xiPN3ZLJHLqmNaF2p/LyCKRL1JwwksJKj3M/MCZmKzAuGUzywFEnZ7zmKDSUyT1k9ynwTrpOmcM80YjkPS/gaNUNYaGezaB0+es9NPu+vDtgCNa6iVGDRW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522470; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SG+rKuUVbaUxXp+EMRwo0KDiuCri6E6fV9fOpbonh9A=; b=e081D7+efDcdZpb8s6dTm+rbzQFlC0mKQJ+nW4EKyEQ+R723diGbiR4UTiGAkPpoq//cSDdYgTijbtPCzBHVw4d0v41wUV5btdCkML3fNgFopRSVd3O25CMjMwwm09Hv0OaHUgC3tL6vo312E9Nr97ocd070Pu9L0onOXNqQ3DA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522470868194.044124108382; Sat, 28 Oct 2023 12:47:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpFw-0004qu-ST; Sat, 28 Oct 2023 15:46:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFo-0004mD-OE for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:53 -0400 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 1qwpFm-0004AT-Kj for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:52 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1cc1ee2d8dfso16307195ad.3 for ; Sat, 28 Oct 2023 12:45:50 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522349; x=1699127149; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SG+rKuUVbaUxXp+EMRwo0KDiuCri6E6fV9fOpbonh9A=; b=JutwFo6LS6kNkeJbI0GoekCwpznnXFiEpulus4ktzSaIeU5xP3QdJIJG8w828PhXle Siz++A69578gKEdrBaSoTO5XpMHtYnjejnC33YjSCpEiAlqglBCwN0i4kXqk0kaHzngG k9zEfGX5VFul8mJvUFjXggM37P++giLwTO6KcLFu+QtTEDZ3AYKBCgELOVNRWRgsZX4D cBewIYnAMmVOjOTQaPRFQGbA9w4Q7BIIpIEk8j9gCJJ+/NQpE+dxKTW6rf1QTmdvIqBs IhFUmiv+zHFSw8tE58nM+EDlUjTA5evIJtJCMmZMmcdIUJiNkXHDrLSNWRYu0CFi82bJ JOcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522349; x=1699127149; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SG+rKuUVbaUxXp+EMRwo0KDiuCri6E6fV9fOpbonh9A=; b=q3iZAJd++NEYqUdhftiVYulNTDRBIl7XeuNMB7Wqtvx/R4ENVo8o2pGg2ZVEbxrv/X Zo3qR0FIGxlXSuANKPHiKgbVoRWP5Cuv4/nGqfJFtP0uQTGuuF2XwWaFH/Qi7o5LRsY0 GLDH7AIckY/D+TtMnY2ddjqlSBIEbOiP9CnbOWNARo3DiepKpl9TRqHn771LIAXd0COw UEWrNtBlhElUAFlau0XxVFGNUJEGdyeO+ow9Wcw0XIntIzxfB55WxHVslwHqa/yB/yia IPkjlhcBKRVMwQKBJO7xe7iFYeLSxGWIk/Oee/8PBq775v8I+VpQIt59w1/RxIbiCO6n YErA== X-Gm-Message-State: AOJu0YxN83/9sFIWwWikpybG3hY6Uth1MhueHyYPxJg5MIThlcGLuOEQ dkHNe7aRanlawAztA3Z3X4ZYV++abm2O/af0lXs= X-Google-Smtp-Source: AGHT+IGMPr81cLzuervqz646NH+3HslUYnsogbIcDw15k5/ZrGFIyq8iu36fxyy2FbRAI+GKErOA/g== X-Received: by 2002:a17:902:f394:b0:1c5:f0fd:51be with SMTP id f20-20020a170902f39400b001c5f0fd51bemr4657587ple.69.1698522349247; Sat, 28 Oct 2023 12:45:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 28/35] tcg/s390x: Split constraint A into J+U Date: Sat, 28 Oct 2023 12:45:15 -0700 Message-Id: <20231028194522.245170-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522473128100003 Content-Type: text/plain; charset="utf-8" Signed 33-bit =3D=3D signed 32-bit + unsigned 32-bit. 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 08fe00a392..a317ccd3a5 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -30,7 +30,7 @@ =20 #define TCG_CT_CONST_S16 (1 << 8) #define TCG_CT_CONST_S32 (1 << 9) -#define TCG_CT_CONST_S33 (1 << 10) +#define TCG_CT_CONST_U32 (1 << 10) #define TCG_CT_CONST_ZERO (1 << 11) #define TCG_CT_CONST_P32 (1 << 12) #define TCG_CT_CONST_INV (1 << 13) @@ -542,22 +542,23 @@ static bool tcg_target_const_match(int64_t val, int c= t, TCGType type, TCGCond cond, int vece) { if (ct & TCG_CT_CONST) { - return 1; + return true; } - if (type =3D=3D TCG_TYPE_I32) { val =3D (int32_t)val; } =20 - /* The following are mutually exclusive. */ - if (ct & TCG_CT_CONST_S16) { - return val =3D=3D (int16_t)val; - } else if (ct & TCG_CT_CONST_S32) { - return val =3D=3D (int32_t)val; - } else if (ct & TCG_CT_CONST_S33) { - return val >=3D -0xffffffffll && val <=3D 0xffffffffll; - } else if (ct & TCG_CT_CONST_ZERO) { - return val =3D=3D 0; + if ((ct & TCG_CT_CONST_S32) && val =3D=3D (int32_t)val) { + return true; + } + if ((ct & TCG_CT_CONST_U32) && val =3D=3D (uint32_t)val) { + return true; + } + if ((ct & TCG_CT_CONST_S16) && val =3D=3D (int16_t)val) { + return true; + } + if ((ct & TCG_CT_CONST_ZERO) && val =3D=3D 0) { + return true; } =20 if (ct & TCG_CT_CONST_INV) { @@ -573,8 +574,7 @@ static bool tcg_target_const_match(int64_t val, int ct, if ((ct & TCG_CT_CONST_INVRISBG) && risbg_mask(~val)) { return true; } - - return 0; + return false; } =20 /* Emit instructions according to the given instruction format. */ @@ -3137,7 +3137,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode op) return C_O1_I2(r, r, ri); case INDEX_op_setcond_i64: case INDEX_op_negsetcond_i64: - return C_O1_I2(r, r, rA); + return C_O1_I2(r, r, rJU); =20 case INDEX_op_clz_i64: return C_O1_I2(r, r, rI); @@ -3187,7 +3187,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode op) case INDEX_op_brcond_i32: return C_O0_I2(r, ri); case INDEX_op_brcond_i64: - return C_O0_I2(r, rA); + return C_O0_I2(r, rJU); =20 case INDEX_op_bswap16_i32: case INDEX_op_bswap16_i64: @@ -3240,7 +3240,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode op) case INDEX_op_movcond_i32: return C_O1_I4(r, r, ri, rI, r); case INDEX_op_movcond_i64: - return C_O1_I4(r, r, rA, rI, r); + return C_O1_I4(r, r, rJU, rI, r); =20 case INDEX_op_div2_i32: case INDEX_op_div2_i64: @@ -3259,7 +3259,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode op) =20 case INDEX_op_add2_i64: case INDEX_op_sub2_i64: - return C_N1_O1_I4(r, r, 0, 1, rA, r); + return C_N1_O1_I4(r, r, 0, 1, rJU, r); =20 case INDEX_op_st_vec: return C_O0_I2(v, r); --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522582; cv=none; d=zohomail.com; s=zohoarc; b=fIbT0pED0ZRkCB4efNACK3nKBB90wjbab59q/TcZAm6cVyCYyWNZf4N7dnYF8oYujjMegB9xSlXjhN8WRpaeRMgPYDIKrZugFe/N0/vkUnq2NfxxoNLABOdmChMfNuyoOdIV8mOOZN1TX5MpQPzQLMTJ+RcYLiPjHBCPxxYppOg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522582; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aJQydxS3NvJxT4eWGTovhRM0Zt2nynj/3g50i7a6gMo=; b=iA6XekNEtvyf4U+uhVNt+9Eh8IxHBki/9o+8XvnCvWJea4Vt0KUCVhoQ6YpkgzACHgFTY9XY1PQ7X2wLSGOiHB51Nv765sAjp84z+N6EVb+zOMdYgQazlOX7FjPN9PyZcDrufwVznixAy5xRpRUbpvGq/6SUhtOHG/qPzYzABsk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522582517333.84191719214573; Sat, 28 Oct 2023 12:49:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpG1-0004v3-DG; Sat, 28 Oct 2023 15:46:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFq-0004nD-8N for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:55 -0400 Received: from mail-oo1-xc2e.google.com ([2607:f8b0:4864:20::c2e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFo-0004Af-EX for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:53 -0400 Received: by mail-oo1-xc2e.google.com with SMTP id 006d021491bc7-5844bc378feso1940477eaf.0 for ; Sat, 28 Oct 2023 12:45:51 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522350; x=1699127150; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aJQydxS3NvJxT4eWGTovhRM0Zt2nynj/3g50i7a6gMo=; b=mFNBNOXMAh+Wn6VvpM+Rv0PcW1DTxiqEV1eWTj4EtonXaHF6lcliusQ4TXWoTvxKow FH8AcBLOz9JG1US9XANAwRJayD7iq336J2MlP5OIhweOL7f3pH170KLzCclQDT0sd5Ym Lxi00seayruYKsCuf3dZwcrsJVEjpvFfmU/GrN9IJr5nNZ/9E2AXAisPkGNSG6L01Md0 /cF4Or5VBUvvnwPr3n0X7FLzX0wZVsovR8wVKwBFHTiOUm3pr2sakWEdC2cG9gvnfgUV YChMaOEafTN5VQ17M8ULe6aYSKcxTkdXgRzceEAEFXn0cKtYBHQek7tITUfcKkoz7HEk W6PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522350; x=1699127150; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aJQydxS3NvJxT4eWGTovhRM0Zt2nynj/3g50i7a6gMo=; b=vHK3N1D4e6+IVPJdbkrJcb3HkhIuWok/ILB0yNK6B/DcaLsGQuroz6F+z6LBSLtxg8 NCyzp1IzFPKLuSzOyRxs7UKl7lPhTnblkg/K73nX23/ZSoTUhuPwFaEPT+UyZNqCZ5bU Tg6ATJSpmr92UxbPp2VBJGwX4RWJ6TsN+GKuluGd1G7UiDTUgUNoQngFGIL9BiaKc2pN nAGpmT2+BpV9HmblXD0fqP2KQc5XdpgCj0QqM0DKxnRucSLNWOVKXCT/UMU2Jbs+rbDH yefxQWDCtJ9QZpPZd4TfrqVkQSc8bg0DRD6OgLeF5n4VqdkwiKGGETeJ5o+a0oD+pZQr r9LA== X-Gm-Message-State: AOJu0Ywdu/lrW6zyTwtVLZCNE6bPuVjCchuV9zGj2ufiJdHtFeR7wAXA no3nuQJyeiDuIbjEMpf+HhZyFohf46XuD0VbaiQ= X-Google-Smtp-Source: AGHT+IGhAotzGMY+VRC6abxq3Ld6MMvpLTyZrs4CGsGxrOU1clvIid8Nk47324BpajK4ozeZ46T70Q== X-Received: by 2002:a05:6358:7e08:b0:169:5ad5:8c42 with SMTP id o8-20020a0563587e0800b001695ad58c42mr3490909rwm.19.1698522350278; Sat, 28 Oct 2023 12:45:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 29/35] tcg/s390x: Add TCG_CT_CONST_CMP Date: Sat, 28 Oct 2023 12:45:16 -0700 Message-Id: <20231028194522.245170-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::c2e; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc2e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522583611100006 Content-Type: text/plain; charset="utf-8" Better constraint for tcg_out_cmp, based on the comparison. 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 a317ccd3a5..86ec737768 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -35,6 +35,7 @@ #define TCG_CT_CONST_P32 (1 << 12) #define TCG_CT_CONST_INV (1 << 13) #define TCG_CT_CONST_INVRISBG (1 << 14) +#define TCG_CT_CONST_CMP (1 << 15) =20 #define ALL_GENERAL_REGS MAKE_64BIT_MASK(0, 16) #define ALL_VECTOR_REGS MAKE_64BIT_MASK(32, 32) @@ -548,6 +549,29 @@ static bool tcg_target_const_match(int64_t val, int ct, val =3D (int32_t)val; } =20 + if (ct & TCG_CT_CONST_CMP) { + switch (cond) { + case TCG_COND_EQ: + case TCG_COND_NE: + ct |=3D TCG_CT_CONST_S32 | TCG_CT_CONST_U32; /* CGFI or CLGFI= */ + break; + case TCG_COND_LT: + case TCG_COND_GE: + case TCG_COND_LE: + case TCG_COND_GT: + ct |=3D TCG_CT_CONST_S32; /* CGFI */ + break; + case TCG_COND_LTU: + case TCG_COND_GEU: + case TCG_COND_LEU: + case TCG_COND_GTU: + ct |=3D TCG_CT_CONST_U32; /* CLGFI */ + break; + default: + g_assert_not_reached(); + } + } + if ((ct & TCG_CT_CONST_S32) && val =3D=3D (int32_t)val) { return true; } @@ -1229,22 +1253,34 @@ static int tgen_cmp2(TCGContext *s, TCGType type, T= CGCond c, TCGReg r1, goto exit; } =20 - /* - * Constraints are for a signed 33-bit operand, which is a - * convenient superset of this signed/unsigned test. - */ - if (c2 =3D=3D (is_unsigned ? (TCGArg)(uint32_t)c2 : (TCGArg)(int32= _t)c2)) { - op =3D (is_unsigned ? RIL_CLGFI : RIL_CGFI); - tcg_out_insn_RIL(s, op, r1, c2); - goto exit; + /* Should match TCG_CT_CONST_CMP. */ + switch (c) { + case TCG_COND_LT: + case TCG_COND_GE: + case TCG_COND_LE: + case TCG_COND_GT: + tcg_debug_assert(c2 =3D=3D (int32_t)c2); + op =3D RIL_CGFI; + break; + case TCG_COND_EQ: + case TCG_COND_NE: + if (c2 =3D=3D (int32_t)c2) { + op =3D RIL_CGFI; + break; + } + /* fall through */ + case TCG_COND_LTU: + case TCG_COND_GEU: + case TCG_COND_LEU: + case TCG_COND_GTU: + tcg_debug_assert(c2 =3D=3D (uint32_t)c2); + op =3D RIL_CLGFI; + break; + default: + g_assert_not_reached(); } - - /* Load everything else into a register. */ - tcg_out_movi(s, TCG_TYPE_I64, TCG_TMP0, c2); - c2 =3D TCG_TMP0; - } - - if (type =3D=3D TCG_TYPE_I32) { + tcg_out_insn_RIL(s, op, r1, c2); + } else if (type =3D=3D TCG_TYPE_I32) { op =3D (is_unsigned ? RR_CLR : RR_CR); tcg_out_insn_RR(s, op, r1, c2); } else { @@ -3137,7 +3173,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode op) return C_O1_I2(r, r, ri); case INDEX_op_setcond_i64: case INDEX_op_negsetcond_i64: - return C_O1_I2(r, r, rJU); + return C_O1_I2(r, r, rC); =20 case INDEX_op_clz_i64: return C_O1_I2(r, r, rI); @@ -3187,7 +3223,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode op) case INDEX_op_brcond_i32: return C_O0_I2(r, ri); case INDEX_op_brcond_i64: - return C_O0_I2(r, rJU); + return C_O0_I2(r, rC); =20 case INDEX_op_bswap16_i32: case INDEX_op_bswap16_i64: @@ -3240,7 +3276,7 @@ static TCGConstraintSetIndex tcg_target_op_def(TCGOpc= ode op) case INDEX_op_movcond_i32: return C_O1_I4(r, r, ri, rI, r); case INDEX_op_movcond_i64: - return C_O1_I4(r, r, rJU, rI, r); + return C_O1_I4(r, r, rC, rI, r); =20 case INDEX_op_div2_i32: case INDEX_op_div2_i64: --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522598; cv=none; d=zohomail.com; s=zohoarc; b=JPbmLmVEEg8HT5mVDfgcFasEG2r5GlmEmtuevePOX/QB86hIqkudRe38ZxKexGXg3ziaOErmZatj6OilujAGiaHI/rGDHLcjrsKHb0jUyvFbrbnB+Ijo90tHToVrAvi5e85tgkuf3VTHZ4qZ/PCn4n9w58Y6T0oZZ6ww78qC+bM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522598; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=by0cc1tjgAQ3NXOZmpHrI8dH3XD+VzEqf1LjHfHAgq8=; b=MrAq4ityiETmBHGD9tPP35NPS4rcmpWrUq48CaLXQ0B9jvKnUaUB0xVsBY70/8tHpzu0XqbbhWUkaxIBog+AsOPCIcgLGV5MiJhSxKthGmfjjganf3G9AWjdmdkVvdm9Am/Y0JXxTU8wicDT/IuT9yXwhLqdVG2a17WmZvpoVmg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522598967454.0976039980816; Sat, 28 Oct 2023 12:49:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpG7-0005F7-3Z; Sat, 28 Oct 2023 15:46:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpG3-0004wr-AC for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:46:08 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFo-0004Ar-Gh for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:46:07 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1cc30bf9e22so5500275ad.1 for ; Sat, 28 Oct 2023 12:45:51 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522351; x=1699127151; 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=by0cc1tjgAQ3NXOZmpHrI8dH3XD+VzEqf1LjHfHAgq8=; b=hkEESmV7vYev7gJtnbkEx/57LVTJ2Kw4lx86iZqvx71NsL9LR9GSINd415/bg7CDCx 5ojmuPqHZIOOdl+A2tyZ4SWLnJazZfDji3PKZHYSM4WoQ+zFdL/D/llwsGPOAvJgLvzh x6xjPUHt3Ay0xgGtdT1iRLMYqvk0fJMEiaWNcz3yTD8qB2ZAYS8aIM6rLn8v4SsGZy+W hMnUOIy2afmHoV+6iS5vMCEezvzMjZ02zWoYZSENJJzkrwajtLD0WW1vwEjNbQGHVDYA Ka3kSB7byolOPOpF+ndy1oNQdDY1HyJcwPRSYs3cO39UzqhFM8tjQdJL0A7Opd0KU3TD 0OXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522351; x=1699127151; 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=by0cc1tjgAQ3NXOZmpHrI8dH3XD+VzEqf1LjHfHAgq8=; b=VAapb941BiC/ZLPxlhmIbp1XdYqwVCoHNwZcpkawiC6VgW/BryWWaeGY/Mv6DTtCV9 Fp7kSKWM7MbZuZRt/1R5xSEjuRFQ5MttpVCaKSr2OzaW7b/UHq6R34alcqyt8h3/mepu +qcOVuTkfEJ5mHivISRiLqSYghZ3hqIOgbVocUbcsVLmfcQ/gOEgICRuykmhm/0eB6aS K9ECWcYFmDUYv4kqBpWPtTWkbQ2YLiWOjNReUdyw49CfUoO5Bu3y6cXs+vhvKwN89Whh aItw11poriZsv/odH98RWv2CYoygXAAJhw6dLgW+ffQwXpEKTi1Vk6QLofm0oO/ZrSFi DzZQ== X-Gm-Message-State: AOJu0Yw2+82KiH7CD5e4ekJDJSNOKXkHptEbUoPMIla07OSTqDTnPvMM P4YNPX6W3hTiuaMFwbb8u9pzHi1nVCKboFA0YCY= X-Google-Smtp-Source: AGHT+IHiNvmipd7A2GLRkuj582cLvCWM4pWzjwVWX1bM0oOzrJT/1F06t1ssdMxu/u/gmxdxPVaAlQ== X-Received: by 2002:a17:902:d50b:b0:1c8:75d9:f7dc with SMTP id b11-20020a170902d50b00b001c875d9f7dcmr11215644plg.28.1698522351034; Sat, 28 Oct 2023 12:45:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 30/35] tcg/s390x: Support TCG_COND_TST{EQ,NE} Date: Sat, 28 Oct 2023 12:45:17 -0700 Message-Id: <20231028194522.245170-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522599994100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- tcg/s390x/tcg-target.c.inc | 139 +++++++++++++++++++++++++------------ 1 file changed, 96 insertions(+), 43 deletions(-) diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc index 86ec737768..cb1693c9cf 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -112,6 +112,9 @@ typedef enum S390Opcode { RI_OILH =3D 0xa50a, RI_OILL =3D 0xa50b, RI_TMLL =3D 0xa701, + RI_TMLH =3D 0xa700, + RI_TMHL =3D 0xa703, + RI_TMHH =3D 0xa702, =20 RIEb_CGRJ =3D 0xec64, RIEb_CLGRJ =3D 0xec65, @@ -404,10 +407,15 @@ static TCGReg tcg_target_call_oarg_reg(TCGCallReturnK= ind kind, int slot) #define S390_CC_NEVER 0 #define S390_CC_ALWAYS 15 =20 +#define S390_TM_EQ 8 /* CC =3D=3D 0 */ +#define S390_TM_NE 7 /* CC in {1,2,3} */ + /* Condition codes that result from a COMPARE and COMPARE LOGICAL. */ -static const uint8_t tcg_cond_to_s390_cond[] =3D { +static const uint8_t tcg_cond_to_s390_cond[16] =3D { [TCG_COND_EQ] =3D S390_CC_EQ, [TCG_COND_NE] =3D S390_CC_NE, + [TCG_COND_TSTEQ] =3D S390_CC_EQ, + [TCG_COND_TSTNE] =3D S390_CC_NE, [TCG_COND_LT] =3D S390_CC_LT, [TCG_COND_LE] =3D S390_CC_LE, [TCG_COND_GT] =3D S390_CC_GT, @@ -421,9 +429,11 @@ static const uint8_t tcg_cond_to_s390_cond[] =3D { /* Condition codes that result from a LOAD AND TEST. Here, we have no unsigned instruction variation, however since the test is vs zero we can re-map the outcomes appropriately. */ -static const uint8_t tcg_cond_to_ltr_cond[] =3D { +static const uint8_t tcg_cond_to_ltr_cond[16] =3D { [TCG_COND_EQ] =3D S390_CC_EQ, [TCG_COND_NE] =3D S390_CC_NE, + [TCG_COND_TSTEQ] =3D S390_CC_ALWAYS, + [TCG_COND_TSTNE] =3D S390_CC_NEVER, [TCG_COND_LT] =3D S390_CC_LT, [TCG_COND_LE] =3D S390_CC_LE, [TCG_COND_GT] =3D S390_CC_GT, @@ -542,10 +552,13 @@ static bool risbg_mask(uint64_t c) static bool tcg_target_const_match(int64_t val, int ct, TCGType type, TCGCond cond, int vece) { + uint64_t uval =3D val; + if (ct & TCG_CT_CONST) { return true; } if (type =3D=3D TCG_TYPE_I32) { + uval =3D (uint32_t)val; val =3D (int32_t)val; } =20 @@ -567,6 +580,15 @@ static bool tcg_target_const_match(int64_t val, int ct, case TCG_COND_GTU: ct |=3D TCG_CT_CONST_U32; /* CLGFI */ break; + case TCG_COND_TSTNE: + case TCG_COND_TSTEQ: + if (is_const_p16(uval) >=3D 0) { + return true; /* TMxx */ + } + if (risbg_mask(uval)) { + return true; /* RISBG */ + } + break; default: g_assert_not_reached(); } @@ -588,10 +610,6 @@ static bool tcg_target_const_match(int64_t val, int ct, if (ct & TCG_CT_CONST_INV) { val =3D ~val; } - /* - * Note that is_const_p16 is a subset of is_const_p32, - * so we don't need both constraints. - */ if ((ct & TCG_CT_CONST_P32) && is_const_p32(val) >=3D 0) { return true; } @@ -868,6 +886,9 @@ static const S390Opcode oi_insns[4] =3D { static const S390Opcode lif_insns[2] =3D { RIL_LLILF, RIL_LLIHF, }; +static const S390Opcode tm_insns[4] =3D { + RI_TMLL, RI_TMLH, RI_TMHL, RI_TMHH +}; =20 /* load a register with an immediate value */ static void tcg_out_movi(TCGContext *s, TCGType type, @@ -1228,6 +1249,36 @@ static int tgen_cmp2(TCGContext *s, TCGType type, TC= GCond c, TCGReg r1, TCGCond inv_c =3D tcg_invert_cond(c); S390Opcode op; =20 + if (is_tst_cond(c)) { + tcg_debug_assert(!need_carry); + + if (!c2const) { + if (type =3D=3D TCG_TYPE_I32) { + tcg_out_insn(s, RRFa, NRK, TCG_REG_R0, r1, c2); + } else { + tcg_out_insn(s, RRFa, NGRK, TCG_REG_R0, r1, c2); + } + goto exit; + } + + if (type =3D=3D TCG_TYPE_I32) { + c2 =3D (uint32_t)c2; + } + + int i =3D is_const_p16(c2); + if (i >=3D 0) { + tcg_out_insn_RI(s, tm_insns[i], r1, c2 >> (i * 16)); + *inv_cc =3D TCG_COND_TSTEQ ? S390_TM_NE : S390_TM_EQ; + return *inv_cc ^ 15; + } + + if (risbg_mask(c2)) { + tgen_andi_risbg(s, TCG_REG_R0, r1, c2); + goto exit; + } + g_assert_not_reached(); + } + if (c2const) { if (c2 =3D=3D 0) { if (!(is_unsigned && need_carry)) { @@ -1553,46 +1604,49 @@ static void tgen_brcond(TCGContext *s, TCGType type= , TCGCond c, TCGReg r1, TCGArg c2, int c2const, TCGLabel *l) { int cc; - bool is_unsigned =3D is_unsigned_cond(c); - bool in_range; - S390Opcode opc; =20 - cc =3D tcg_cond_to_s390_cond[c]; + if (!is_tst_cond(c)) { + bool is_unsigned =3D is_unsigned_cond(c); + bool in_range; + S390Opcode opc; =20 - if (!c2const) { - opc =3D (type =3D=3D TCG_TYPE_I32 - ? (is_unsigned ? RIEb_CLRJ : RIEb_CRJ) - : (is_unsigned ? RIEb_CLGRJ : RIEb_CGRJ)); - tgen_compare_branch(s, opc, cc, r1, c2, l); - return; - } + cc =3D tcg_cond_to_s390_cond[c]; =20 - /* - * COMPARE IMMEDIATE AND BRANCH RELATIVE has an 8-bit immediate field. - * If the immediate we've been given does not fit that range, we'll - * fall back to separate compare and branch instructions using the - * larger comparison range afforded by COMPARE IMMEDIATE. - */ - if (type =3D=3D TCG_TYPE_I32) { - if (is_unsigned) { - opc =3D RIEc_CLIJ; - in_range =3D (uint32_t)c2 =3D=3D (uint8_t)c2; - } else { - opc =3D RIEc_CIJ; - in_range =3D (int32_t)c2 =3D=3D (int8_t)c2; + if (!c2const) { + opc =3D (type =3D=3D TCG_TYPE_I32 + ? (is_unsigned ? RIEb_CLRJ : RIEb_CRJ) + : (is_unsigned ? RIEb_CLGRJ : RIEb_CGRJ)); + tgen_compare_branch(s, opc, cc, r1, c2, l); + return; } - } else { - if (is_unsigned) { - opc =3D RIEc_CLGIJ; - in_range =3D (uint64_t)c2 =3D=3D (uint8_t)c2; + + /* + * COMPARE IMMEDIATE AND BRANCH RELATIVE has an 8-bit immediate fi= eld. + * If the immediate we've been given does not fit that range, we'll + * fall back to separate compare and branch instructions using the + * larger comparison range afforded by COMPARE IMMEDIATE. + */ + if (type =3D=3D TCG_TYPE_I32) { + if (is_unsigned) { + opc =3D RIEc_CLIJ; + in_range =3D (uint32_t)c2 =3D=3D (uint8_t)c2; + } else { + opc =3D RIEc_CIJ; + in_range =3D (int32_t)c2 =3D=3D (int8_t)c2; + } } else { - opc =3D RIEc_CGIJ; - in_range =3D (int64_t)c2 =3D=3D (int8_t)c2; + if (is_unsigned) { + opc =3D RIEc_CLGIJ; + in_range =3D (uint64_t)c2 =3D=3D (uint8_t)c2; + } else { + opc =3D RIEc_CGIJ; + in_range =3D (int64_t)c2 =3D=3D (int8_t)c2; + } + } + if (in_range) { + tgen_compare_imm_branch(s, opc, cc, r1, c2, l); + return; } - } - if (in_range) { - tgen_compare_imm_branch(s, opc, cc, r1, c2, l); - return; } =20 cc =3D tgen_cmp(s, type, c, r1, c2, c2const, false); @@ -1871,11 +1925,10 @@ static TCGLabelQemuLdst *prepare_host_addr(TCGConte= xt *s, HostAddress *h, ldst->oi =3D oi; ldst->addrlo_reg =3D addr_reg; =20 - /* We are expecting a_bits to max out at 7, much lower than TM= LL. */ tcg_debug_assert(a_mask <=3D 0xffff); tcg_out_insn(s, RI, TMLL, addr_reg, a_mask); =20 - tcg_out16(s, RI_BRC | (7 << 4)); /* CC in {1,2,3} */ + tcg_out16(s, RI_BRC | (S390_TM_NE << 4)); ldst->label_ptr[0] =3D s->code_ptr++; } =20 @@ -1956,7 +2009,7 @@ static void tcg_out_qemu_ldst_i128(TCGContext *s, TCG= Reg datalo, TCGReg datahi, l2 =3D gen_new_label(); =20 tcg_out_insn(s, RI, TMLL, addr_reg, 15); - tgen_branch(s, 7, l1); /* CC in {1,2,3} */ + tgen_branch(s, S390_TM_NE, l1); } =20 tcg_debug_assert(!need_bswap); --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522577; cv=none; d=zohomail.com; s=zohoarc; b=EAuRCWrsWvjB156wYikSd3HMgr1IFYtJHj9cSKMN+/XZ+JxESnlped/myRqumjEWR+oL6AsPaVDIABONb+pBF6BoEbiq6wFpS4nG7HvIBQ9qX/7yS8Khraj9Plw3HD8tEHpBU1rY5krciYbdhnq4MbZYSSJzyLGs4OLwPWMfh0g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522577; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pEO6SLhS+OilG+TaX+qmXlK9OgBRNvjKZJDuVMclfD4=; b=JfKXrtubIBJfdShZ7xiqv8954KBEJbU77Tz9GNu/nPQJGY8ruVxKoiCqzrpG3qW8gU5D2lCt2daOqyRwYfKO24l1PbT8rob1DwBhgFox1o1Eze8WMl7PTHlmesPjrvQfNVnORYzlkkGjfXAFf5piT3UIFOk93eZ329AZJnXrKR0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522577566968.8028778806356; Sat, 28 Oct 2023 12:49:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpG2-0004w1-7v; Sat, 28 Oct 2023 15:46:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFs-0004oH-1o for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:56 -0400 Received: from mail-oo1-xc29.google.com ([2607:f8b0:4864:20::c29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFq-0004Ay-FI for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:55 -0400 Received: by mail-oo1-xc29.google.com with SMTP id 006d021491bc7-581de3e691dso1845428eaf.3 for ; Sat, 28 Oct 2023 12:45:52 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522352; x=1699127152; 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=pEO6SLhS+OilG+TaX+qmXlK9OgBRNvjKZJDuVMclfD4=; b=tDQ4HbnlE9V0M/8o6p/OttI1+kn23kt+fv31QguUy5t663k/dPU1aKWiwk4jfQ1pp1 7KUvcxoWlgHj6rboxozdb9ynfDennqhKw83F8qhyJYimx35Zou59GUaklibWesvkAxTp 5Xd6laoCwYbLLZ/0r3VbnYYp+rOqg+ZcViBJioHe4hR5F/g4PXSFYSttVI4XKZQntTwH SAdcPAuinjfzO+57itS2t+CPZYp4q9NSy/iooaG1wXSXiMZc4vgIYzqsXOkFgNFbWjIN ek771W6sTsxWboDRMX91ScqFZwcDC/U6Xsl+fyzn42dUCi9/j7ENIaWxJwftw6MhLysa lGow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522352; x=1699127152; 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=pEO6SLhS+OilG+TaX+qmXlK9OgBRNvjKZJDuVMclfD4=; b=CsX+6klj+KSfCXfI9Ij6Knb/YW3Ipc4bKyDqf1iEXMQ/eNV6dRn1WbKFOXeXsFgUYO miHRGwZxPMpOx4S7jKIAtUN4jML7m20jQvZkpdgPSO2qONFcXvGyF09GAgEyRVduGrax JhrlAk2FOQX2sTaTsWql2usKy9KGEIrZpnzqM6tZatSGYBzc5A8Fu0lA2Z0WsjFP2Ns2 tgGOS8szM2w9jjp1ANEjwVkH9cOLkVZ92lqiX4SRXTWfKGHQGq8xSHeBN5lr5C26Nikd +O1vKeFP8BlovOU12KDws0nLGWyouxoEJeYdpn1s1F8LV1avQlXbEYARSWtzXfY6XAdU c+YQ== X-Gm-Message-State: AOJu0YzeqCPWRJzFMqdurQ399kla+vHMtI4jZF2wuYPKbwXK0IvPq1Ds /fpYlhGB/aYbrkaak/VH5k4oG/x2eV37w3Lpxeg= X-Google-Smtp-Source: AGHT+IFdT80eJ5wwn3fv3h1rbsglMluN1RSYlwWyRgaFMvZm1h1aBjTofz/eVGPCCIRFwgNuvgUUkQ== X-Received: by 2002:a05:6359:6b82:b0:168:d0d4:d8e6 with SMTP id ta2-20020a0563596b8200b00168d0d4d8e6mr6362041rwb.16.1698522351761; Sat, 28 Oct 2023 12:45:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 31/35] tcg/tci: Support TCG_COND_TST{EQ,NE} Date: Sat, 28 Oct 2023 12:45:18 -0700 Message-Id: <20231028194522.245170-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::c29; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc29.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522579486100007 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/tci.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tcg/tci.c b/tcg/tci.c index 4640902c88..5e1c4a491d 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -228,6 +228,12 @@ static bool tci_compare32(uint32_t u0, uint32_t u1, TC= GCond condition) case TCG_COND_GTU: result =3D (u0 > u1); break; + case TCG_COND_TSTEQ: + result =3D (u0 & u1) =3D=3D 0; + break; + case TCG_COND_TSTNE: + result =3D (u0 & u1) !=3D 0; + break; default: g_assert_not_reached(); } @@ -270,6 +276,12 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TC= GCond condition) case TCG_COND_GTU: result =3D (u0 > u1); break; + case TCG_COND_TSTEQ: + result =3D (u0 & u1) =3D=3D 0; + break; + case TCG_COND_TSTNE: + result =3D (u0 & u1) !=3D 0; + break; default: g_assert_not_reached(); } @@ -1043,6 +1055,8 @@ static const char *str_c(TCGCond c) [TCG_COND_GEU] =3D "geu", [TCG_COND_LEU] =3D "leu", [TCG_COND_GTU] =3D "gtu", + [TCG_COND_TSTEQ] =3D "tsteq", + [TCG_COND_TSTNE] =3D "tstne", }; =20 assert((unsigned)c < ARRAY_SIZE(cond)); --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522461; cv=none; d=zohomail.com; s=zohoarc; b=QwCvi29BjG/JFBS5avaAwUEPQ7hl2llKV7Tqgm/Mp4K52zFiiSL42QfLj0al4Z+xPWNyokmYzZvCPFB+oeMfHEJgZJ4oPVWpZBo6CFnAABVSU/VJ7TrLenaVy1Y8IcOb21WXtGqVaiUNZF8rYFw4C1Oa4/PYVICJ7Qx/YHRy3EQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522461; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Qt73rqnYlScESAX1GLvymJtn101eThzhHh8tymn5hTE=; b=PqN6GbBf2CZcLm8SlZHMe/teiv5pVZkHQkM2VDILLlZsA5HTdm3vb2kTle37L5Vi2VwZksI3mRznwFT2s2qKYfUVVDWynMC8+TtUCoaERJt3LGnL8QPTeFza+a5dkiQMUcD9zJkuYsSv9Gax9xzVCWioM/GxC2YDlSdLYPFCvHM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169852246129745.99975384705465; Sat, 28 Oct 2023 12:47:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpFw-0004qJ-8F; Sat, 28 Oct 2023 15:46:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFr-0004o0-Mf for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:55 -0400 Received: from mail-yb1-xb34.google.com ([2607:f8b0:4864:20::b34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFp-0004B9-Lx for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:55 -0400 Received: by mail-yb1-xb34.google.com with SMTP id 3f1490d57ef6-d852b28ec3bso2493597276.2 for ; Sat, 28 Oct 2023 12:45:53 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522352; x=1699127152; 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=Qt73rqnYlScESAX1GLvymJtn101eThzhHh8tymn5hTE=; b=MZlh9eRV43aKOQk61y/h0q5ScuSemak6og2tworHN50N/qsSAwy6u1jyG3XCIZOm4u DredOxSHTXrc9GK/CWkdgdb6OgZONZhMJPm97fl21XeWF7CZLFpUhpSa4nlma44SWYgv s1uLdG7wWxnGwgpDeGWpIWpiMlFJWhVMfg5tmVWkAoEtLlXr52sXac6wOWFyx9wc2Pi/ x14JPQfWOJ6pTf1KdyPGRbujjp0v5dyueM/nnETMD2aTHfxZpti3jy6TwHttBLyZ68kU p1trdi6sBGi/Jq/usKhbD9XwAdEx3ENxrDmyWHX1cBfm7Pt58u0LjyBHecMwxt3+sDDk JRBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522352; x=1699127152; 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=Qt73rqnYlScESAX1GLvymJtn101eThzhHh8tymn5hTE=; b=jt3sxG9hv5UKvo8B2a5GPvMus/UnMwhtH8hQHpfWu51ysvkNsyvuMCkfZ5N87xj1QM LE44Cfp1t7w9coWbcPryaMRLb8tpAE+0wFr+IAgGnKNJmvqa+ELoLiPNe3EaRKXTnwmE YC4zGihW4n3fCJbCa97yo/k/wirHImTgCXiDDK59kaeGE9BnVSNakQrNegcVSyNJfcXV QhokGLc53r3i6Z8CeA3GmmzubcdecoFYrBR0eRJadYyWmkFSSFiM0yjAQdTe4bDyzrVt z03SRhBz62M10Un1XGeJaT+54PgccGUdoCwKgZV6EmFKBalgsr+jgL61PCZnCUmWIAqB dQXw== X-Gm-Message-State: AOJu0Yw+RbdjB2NyXUb1G1GH2Hh6bUGifdQ1HjEy8Q2ClP7K8YrdWoMV 2QInryd9x8q9lU8BfMShCVWKZE1hsImJC2cFyy8= X-Google-Smtp-Source: AGHT+IFLkyTJMMC/fClf1+60ijE+Q1vkkcAx0T0KZ4mHNafRa9DI2X9m7RJC7HpoyO13GvLBQeNrUw== X-Received: by 2002:a25:a2c9:0:b0:d9a:fe8c:c298 with SMTP id c9-20020a25a2c9000000b00d9afe8cc298mr5188166ybn.31.1698522352509; Sat, 28 Oct 2023 12:45:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 32/35] target/alpha: Use TCG_COND_TST{EQ,NE} for BLB{C,S} Date: Sat, 28 Oct 2023 12:45:19 -0700 Message-Id: <20231028194522.245170-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::b34; envelope-from=richard.henderson@linaro.org; helo=mail-yb1-xb34.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522462916100007 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/alpha/translate.c | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/target/alpha/translate.c b/target/alpha/translate.c index 32333081d8..49e6a7b62d 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -453,13 +453,13 @@ static DisasJumpType gen_bdirect(DisasContext *ctx, i= nt ra, int32_t disp) } =20 static DisasJumpType gen_bcond_internal(DisasContext *ctx, TCGCond cond, - TCGv cmp, int32_t disp) + TCGv cmp, uint64_t imm, int32_t di= sp) { uint64_t dest =3D ctx->base.pc_next + (disp << 2); TCGLabel *lab_true =3D gen_new_label(); =20 if (use_goto_tb(ctx, dest)) { - tcg_gen_brcondi_i64(cond, cmp, 0, lab_true); + tcg_gen_brcondi_i64(cond, cmp, imm, lab_true); =20 tcg_gen_goto_tb(0); tcg_gen_movi_i64(cpu_pc, ctx->base.pc_next); @@ -472,27 +472,20 @@ static DisasJumpType gen_bcond_internal(DisasContext = *ctx, TCGCond cond, =20 return DISAS_NORETURN; } else { - TCGv_i64 z =3D load_zero(ctx); + TCGv_i64 i =3D tcg_constant_i64(imm); TCGv_i64 d =3D tcg_constant_i64(dest); TCGv_i64 p =3D tcg_constant_i64(ctx->base.pc_next); =20 - tcg_gen_movcond_i64(cond, cpu_pc, cmp, z, d, p); + tcg_gen_movcond_i64(cond, cpu_pc, cmp, i, d, p); return DISAS_PC_UPDATED; } } =20 static DisasJumpType gen_bcond(DisasContext *ctx, TCGCond cond, int ra, - int32_t disp, int mask) + int32_t disp) { - if (mask) { - TCGv tmp =3D tcg_temp_new(); - DisasJumpType ret; - - tcg_gen_andi_i64(tmp, load_gpr(ctx, ra), 1); - ret =3D gen_bcond_internal(ctx, cond, tmp, disp); - return ret; - } - return gen_bcond_internal(ctx, cond, load_gpr(ctx, ra), disp); + return gen_bcond_internal(ctx, cond, load_gpr(ctx, ra), + is_tst_cond(cond), disp); } =20 /* Fold -0.0 for comparison with COND. */ @@ -533,7 +526,7 @@ static DisasJumpType gen_fbcond(DisasContext *ctx, TCGC= ond cond, int ra, DisasJumpType ret; =20 gen_fold_mzero(cond, cmp_tmp, load_fpr(ctx, ra)); - ret =3D gen_bcond_internal(ctx, cond, cmp_tmp, disp); + ret =3D gen_bcond_internal(ctx, cond, cmp_tmp, 0, disp); return ret; } =20 @@ -2827,35 +2820,35 @@ static DisasJumpType translate_one(DisasContext *ct= x, uint32_t insn) break; case 0x38: /* BLBC */ - ret =3D gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 1); + ret =3D gen_bcond(ctx, TCG_COND_TSTEQ, ra, disp21); break; case 0x39: /* BEQ */ - ret =3D gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 0); + ret =3D gen_bcond(ctx, TCG_COND_EQ, ra, disp21); break; case 0x3A: /* BLT */ - ret =3D gen_bcond(ctx, TCG_COND_LT, ra, disp21, 0); + ret =3D gen_bcond(ctx, TCG_COND_LT, ra, disp21); break; case 0x3B: /* BLE */ - ret =3D gen_bcond(ctx, TCG_COND_LE, ra, disp21, 0); + ret =3D gen_bcond(ctx, TCG_COND_LE, ra, disp21); break; case 0x3C: /* BLBS */ - ret =3D gen_bcond(ctx, TCG_COND_NE, ra, disp21, 1); + ret =3D gen_bcond(ctx, TCG_COND_TSTNE, ra, disp21); break; case 0x3D: /* BNE */ - ret =3D gen_bcond(ctx, TCG_COND_NE, ra, disp21, 0); + ret =3D gen_bcond(ctx, TCG_COND_NE, ra, disp21); break; case 0x3E: /* BGE */ - ret =3D gen_bcond(ctx, TCG_COND_GE, ra, disp21, 0); + ret =3D gen_bcond(ctx, TCG_COND_GE, ra, disp21); break; case 0x3F: /* BGT */ - ret =3D gen_bcond(ctx, TCG_COND_GT, ra, disp21, 0); + ret =3D gen_bcond(ctx, TCG_COND_GT, ra, disp21); break; invalid_opc: ret =3D gen_invalid(ctx); --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522465820517.562566561098; Sat, 28 Oct 2023 12:47:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpG4-000504-Uh; Sat, 28 Oct 2023 15:46:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFs-0004pC-QI for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:56 -0400 Received: from mail-il1-x12d.google.com ([2607:f8b0:4864:20::12d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFq-0004BS-Gc for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:56 -0400 Received: by mail-il1-x12d.google.com with SMTP id e9e14a558f8ab-3577ce73552so9702725ab.2 for ; Sat, 28 Oct 2023 12:45:54 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522353; x=1699127153; 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=EHAeumhj/k6eiqLtdrKjjL6mwObgsX5DY/BFSjKBF5I=; b=rJPO4EBxbkxoiPD9zN0NMAUZLNB8dVOTIdGQH48d75MezMMIN72BqO/4Otjjz5LjPv YuRl1AZAzxbHfd8TMIfEDCEvybrQaeG6YoEs37KsIhJGVTl0HtVGOG0Aj67VnzxODl2U 3eloe0LEubNg96bp8jCVlrHfwkzmBTUm2fbCoj9Ts4D6TFQkrDDfi1RF5Xj6d4HosR2z tJiqZZTPw1rM5dInVrNapVKBUSDYyVLLuEcDjJ+/iGrFnOGyoZFEKGSR7ZCZRN5Swi5s rr3fLHI0CqRLrr2I2SihGNTUzWPJ/fMDvkCbCM20vKIm3Bb0JXDKl7WSpwq5ixTkF9KM fOYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522353; x=1699127153; 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=EHAeumhj/k6eiqLtdrKjjL6mwObgsX5DY/BFSjKBF5I=; b=dyJbIEG/BIaHBFH7WdArxe+TIsZAbjvYC5nRjs4Gk9JaffqBQ4qXylZKpXKjDMM6hz Oda6WGNnL/wu8l3Vw6qGZmIZMDKd3W2SAl7H9hqQf+iCHt0SozAtq0hanRIMxpeVP63s 6DaAi4m74k7+Zodtbb1aPWpNgY165NJgVxeyYxuT/j7o0xpywQHer9s4gGPmxGJYTbiL 73U7rIX/dbBgMVilrHCX0CXQeTsUJV8eCArIA7m9Io2wZQbFG/Tyx5Ati2mVbs0Rfdv+ JMjOHjzZHVbCn/sePvsxAmIcuTvR2JATkN3FNZdyqTtH1pXAt4FuDR/+mFsvZkyibvRY k/9g== X-Gm-Message-State: AOJu0Yz7Lfp+WVailmTKtuoTQwUdtSkKWHEBia+dBpjQrc1MD0r4stVG wR0ly3k1ZFIjTZ60RGJe5Zar8iEhYoOWIRSU6bE= X-Google-Smtp-Source: AGHT+IF9x8ITcdhYE6zynW+aFMxHEZorA8qXJ20hPsU9RuBq58tGp2+bQkjy2501wzm4Ys9YPMI13g== X-Received: by 2002:a92:cdae:0:b0:34c:e6e6:80d5 with SMTP id g14-20020a92cdae000000b0034ce6e680d5mr8454609ild.26.1698522353510; Sat, 28 Oct 2023 12:45:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 33/35] target/alpha: Use TCG_COND_TST{EQ, NE} for CMOVLB{C, S} Date: Sat, 28 Oct 2023 12:45:20 -0700 Message-Id: <20231028194522.245170-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::12d; envelope-from=richard.henderson@linaro.org; helo=mail-il1-x12d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1698522467022100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/alpha/translate.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/target/alpha/translate.c b/target/alpha/translate.c index 49e6a7b62d..c7daf46de7 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -1676,16 +1676,12 @@ static DisasJumpType translate_one(DisasContext *ct= x, uint32_t insn) break; case 0x14: /* CMOVLBS */ - tmp =3D tcg_temp_new(); - tcg_gen_andi_i64(tmp, va, 1); - tcg_gen_movcond_i64(TCG_COND_NE, vc, tmp, load_zero(ctx), + tcg_gen_movcond_i64(TCG_COND_TSTNE, vc, va, tcg_constant_i64(1= ), vb, load_gpr(ctx, rc)); break; case 0x16: /* CMOVLBC */ - tmp =3D tcg_temp_new(); - tcg_gen_andi_i64(tmp, va, 1); - tcg_gen_movcond_i64(TCG_COND_EQ, vc, tmp, load_zero(ctx), + tcg_gen_movcond_i64(TCG_COND_TSTEQ, vc, va, tcg_constant_i64(1= ), vb, load_gpr(ctx, rc)); break; case 0x20: --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698522389; cv=none; d=zohomail.com; s=zohoarc; b=G1atyAVdNogLSbh+0UIClohjipOddSf5kKAM3fu7n12z6IVC5cWSdtWJo7hJwzdf9bio9LlYDZdGlagD+kM9Eb2pUtofS00rO5NqLTqIZmT64PmHOLeGgdDA4zmtSJ0xQPDmtcWdjeuoPwh7YZY60+omCtGeFugO/RVJ7wQuOsY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698522389; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jVGlwsfbm4sLINQJ1C25FK0LHbR26UwjjqtCg2xAyg8=; b=kIkc8k2DqW7Z5jS4Ugz2K3unfiFSfy0TOvvVE1T/rvuRBG93uPWF/Av1xo6jKHgYCnGYrslTZ8qn9XOPQlTmVHUkAExI/xtu3hN9OK+1IngBqTbxPHkfNs2C19bb2tOT7hzni16pdvlAsWAkLY+X2oB6ox03imiHbtHl3KJZE1c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522389358260.2825296942649; Sat, 28 Oct 2023 12:46:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpG9-0005Xu-MM; Sat, 28 Oct 2023 15:46:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFu-0004pj-6f for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:58 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFr-0004Bd-Ew for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:56 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6bd0e1b1890so2765381b3a.3 for ; Sat, 28 Oct 2023 12:45:55 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522354; x=1699127154; 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=jVGlwsfbm4sLINQJ1C25FK0LHbR26UwjjqtCg2xAyg8=; b=PA+rCgEf9DOIvJgR9vXeAZx0v1wkvPaDPb9AWIGuo8nqX41BmaSaPzTe1YZhiMYHiJ rfmc31p7FlYFouFfT6RARbmXIaTfM5o4FGg/nVn1zlUpNx1BVWE4Tdxtt+EQ2qL12+PE A0S9NvbeRt4Os/+a0EyIuTi8LKbUUcEoJnkctku+Bu1g3Jfyi26ZaEUL54MI1jF5v2VJ l6t25RpZKTqHfKdI4nGySCHIoBY7Wu5whAUxVQi+26U5AKaNnEX5vJdI1Uukl8R6Q9WK mwowR8nNklgVam0lB3AJaKIAzQssayDRApTknQPkh4gGJKsD4cXA8pKIgNklKoD6JNXL TCzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522354; x=1699127154; 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=jVGlwsfbm4sLINQJ1C25FK0LHbR26UwjjqtCg2xAyg8=; b=Al74QNpr6nTUQtgs/csuQdi2IWNlSPu0+sgLUWZnrYuvdGKUjqI3QR+/dBHjQFV6ZT CBHu0Vt7WH10qhqiDg8z+5OaZOPn+ijtnXTS3eWocdEoAcpbiMXjE4hHucsFJv+qVydX ceFunGfffhHKZwKbCVTOAEhh1ZUYrYrQbbzw6+OX33JmFiLdRblBEUTOvGqgXiBK2ZhG DBJSJNuk87gjjE1XqnrHkokWB9uARdir5BJD50EAlQ8LpWciYN/t9WGJ0TZ0BJYaG4oH OTNui0JxBb4B4AI1K24R7ej45NP6fzhOZO4UKKTCbF7luVn21aNtaj4EcxeIcptFCekQ PbKw== X-Gm-Message-State: AOJu0YyX0LzQkZmv5vmlCHaPCWfbSEZvhCP4hYK5P8e8o2mdUfI0OAkp Nf63lBhm47R+qpa2dwprcVDPDYyqowUzglXv+aw= X-Google-Smtp-Source: AGHT+IHAHpU31ROKlXQWUTH9AWJyHrQ/WG8uQhFZGtlZCCl6GBDFlb0aCwSppGfUQClEYDaLLbWJdA== X-Received: by 2002:a05:6a20:918d:b0:17a:eddb:ac65 with SMTP id v13-20020a056a20918d00b0017aeddbac65mr6266375pzd.9.1698522354229; Sat, 28 Oct 2023 12:45:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 34/35] target/alpha: Use TCG_COND_TSTNE for gen_fold_mzero Date: Sat, 28 Oct 2023 12:45:21 -0700 Message-Id: <20231028194522.245170-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698522390064100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/alpha/translate.c | 49 +++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/target/alpha/translate.c b/target/alpha/translate.c index c7daf46de7..c68c2bcd21 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -490,56 +490,53 @@ static DisasJumpType gen_bcond(DisasContext *ctx, TCG= Cond cond, int ra, =20 /* Fold -0.0 for comparison with COND. */ =20 -static void gen_fold_mzero(TCGCond cond, TCGv dest, TCGv src) +static TCGv_i64 gen_fold_mzero(TCGCond *pcond, uint64_t *pimm, TCGv_i64 sr= c) { - uint64_t mzero =3D 1ull << 63; + TCGv_i64 tmp; =20 - switch (cond) { + *pimm =3D 0; + switch (*pcond) { case TCG_COND_LE: case TCG_COND_GT: /* For <=3D or >, the -0.0 value directly compares the way we want= . */ - tcg_gen_mov_i64(dest, src); - break; + return src; =20 case TCG_COND_EQ: case TCG_COND_NE: - /* For =3D=3D or !=3D, we can simply mask off the sign bit and com= pare. */ - tcg_gen_andi_i64(dest, src, mzero - 1); - break; + /* For =3D=3D or !=3D, we can compare without the sign bit. */ + *pcond =3D *pcond =3D=3D TCG_COND_EQ ? TCG_COND_TSTEQ : TCG_COND_T= STNE; + *pimm =3D INT64_MAX; + return src; =20 case TCG_COND_GE: case TCG_COND_LT: /* For >=3D or <, map -0.0 to +0.0. */ - tcg_gen_movcond_i64(TCG_COND_NE, dest, src, tcg_constant_i64(mzero= ), - src, tcg_constant_i64(0)); - break; + tmp =3D tcg_temp_new_i64(); + tcg_gen_movcond_i64(TCG_COND_EQ, tmp, + src, tcg_constant_i64(INT64_MIN), + tcg_constant_i64(0), src); + return tmp; =20 default: - abort(); + g_assert_not_reached(); } } =20 static DisasJumpType gen_fbcond(DisasContext *ctx, TCGCond cond, int ra, int32_t disp) { - TCGv cmp_tmp =3D tcg_temp_new(); - DisasJumpType ret; - - gen_fold_mzero(cond, cmp_tmp, load_fpr(ctx, ra)); - ret =3D gen_bcond_internal(ctx, cond, cmp_tmp, 0, disp); - return ret; + uint64_t imm; + TCGv_i64 tmp =3D gen_fold_mzero(&cond, &imm, load_fpr(ctx, ra)); + return gen_bcond_internal(ctx, cond, tmp, imm, disp); } =20 static void gen_fcmov(DisasContext *ctx, TCGCond cond, int ra, int rb, int= rc) { - TCGv_i64 va, vb, z; - - z =3D load_zero(ctx); - vb =3D load_fpr(ctx, rb); - va =3D tcg_temp_new(); - gen_fold_mzero(cond, va, load_fpr(ctx, ra)); - - tcg_gen_movcond_i64(cond, dest_fpr(ctx, rc), va, z, vb, load_fpr(ctx, = rc)); + uint64_t imm; + TCGv_i64 tmp =3D gen_fold_mzero(&cond, &imm, load_fpr(ctx, ra)); + tcg_gen_movcond_i64(cond, dest_fpr(ctx, rc), + tmp, tcg_constant_i64(imm), + load_fpr(ctx, rb), load_fpr(ctx, rc)); } =20 #define QUAL_RM_N 0x080 /* Round mode nearest even */ --=20 2.34.1 From nobody Wed Nov 27 11:50:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698522630445339.15049391260436; Sat, 28 Oct 2023 12:50:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwpGA-0005d1-Fx; Sat, 28 Oct 2023 15:46:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwpFu-0004pk-8r for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:58 -0400 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 1qwpFs-0004Bj-GC for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:57 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1c9b95943beso28624975ad.1 for ; Sat, 28 Oct 2023 12:45:56 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522355; x=1699127155; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9Wfu8qLoAolc0Teqm8g6ViWX6SdHYrms61Q6QJWJ8CE=; b=txJ3BR9GxO/nPgVyEprmVm34bTun7nZqppblCz3XUPfhHqwyqLOGWcPW8eNZfh/b8J xJDDYdlQqMReVH4jz9cMYGnQ6DVojXxJN12zZ6zQFMnDqvPr8Dj5hnmbC6X7jChwHwvS 153Q1QFM9Z8R6CFcovzysLrlSJK4smgRhql8c/0csB2Sa3wdeQaIIsLM3oSurtWxwu7R rOiuRruAGPy7hgrOqwaJEs/KpleBqZzRwhNtGftbNVfD9KpwgMzvZc5Ee63U1R3YuPa7 czlb2XHstvCzMP89tWgZjgIC1ewA6fb4QQ5RnrNNSm2Od3zRB4kXHqS8xnvDwUaNvv2Y COzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522355; x=1699127155; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9Wfu8qLoAolc0Teqm8g6ViWX6SdHYrms61Q6QJWJ8CE=; b=u+PLEcc1SZIPGlUP/NI9nx7r8zOgjbG2rn7XTl77CcTVqUyVB7L0w+Y3ZGSXQCNDwF zJAZsmNUFrW6u2+V0GpYnLDMx6YgwxstYh3yu2MTggFvFcE1UC22cWFw1v2j5e5GnrYA NP28laLY0GCYhc8gwdAd1U9R6joLOMe6mr4j0qpBXDPkMfRZFUY/uVOHyrVtGKFIdT7x MGCH0x677NcjcTKIFpQSxyQWrJOyxL+FCd8sEQ/k2Z/FOHz2L/58TdiCeDi42weK/+yf kCx2iH7AK64nBOoLIzCR9m+ned9HDFSzvSP4KJjWjl7EeLDYUEQ1fB9k6OnbYIWRJoLj RFFg== X-Gm-Message-State: AOJu0YzT1/Vhelv4iCzzpRE377nwfQbKUO+c+i9Qh+rw9NLJNcn5S4nb N7cTukJOJOhti45JIHE9rCgSY39muZKLeVz9TVo= X-Google-Smtp-Source: AGHT+IGDbm2rU/dnzzxd2BynDdT9+Gqq0kw5eRRZkyz9vaXDjgu7uxpPcUls4aFA7wDdT4Q1RvBfHg== X-Received: by 2002:a17:902:f681:b0:1c9:dff1:6ddd with SMTP id l1-20020a170902f68100b001c9dff16dddmr6743831plg.35.1698522354947; Sat, 28 Oct 2023 12:45:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 35/35] target/m68k: Use TCG_COND_TST{EQ, NE} in gen_fcc_cond Date: Sat, 28 Oct 2023 12:45:22 -0700 Message-Id: <20231028194522.245170-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1698522632529100011 Content-Type: text/plain; charset="utf-8" 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 4a0b0b2703..f30b92f2d4 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -5129,46 +5129,44 @@ undef: static void gen_fcc_cond(DisasCompare *c, DisasContext *s, int cond) { TCGv fpsr; + int imm =3D 0; =20 - c->v2 =3D tcg_constant_i32(0); /* TODO: Raise BSUN exception. */ fpsr =3D tcg_temp_new(); gen_load_fcr(s, fpsr, M68K_FPSR); + c->v1 =3D fpsr; + switch (cond) { case 0: /* False */ case 16: /* Signaling False */ - c->v1 =3D c->v2; c->tcond =3D TCG_COND_NEVER; break; case 1: /* EQual Z */ case 17: /* Signaling EQual Z */ - c->v1 =3D tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_Z); - c->tcond =3D TCG_COND_NE; + imm =3D FPSR_CC_Z; + c->tcond =3D TCG_COND_TSTNE; break; case 2: /* Ordered Greater Than !(A || Z || N) */ case 18: /* Greater Than !(A || Z || N) */ - c->v1 =3D tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, - FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N); - c->tcond =3D TCG_COND_EQ; + imm =3D FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N; + c->tcond =3D TCG_COND_TSTEQ; break; case 3: /* Ordered Greater than or Equal Z || !(A || N) */ case 19: /* Greater than or Equal Z || !(A || N) */ c->v1 =3D tcg_temp_new(); tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A); tcg_gen_shli_i32(c->v1, c->v1, ctz32(FPSR_CC_N) - ctz32(FPSR_CC_A)= ); - tcg_gen_andi_i32(fpsr, fpsr, FPSR_CC_Z | FPSR_CC_N); tcg_gen_or_i32(c->v1, c->v1, fpsr); tcg_gen_xori_i32(c->v1, c->v1, FPSR_CC_N); - c->tcond =3D TCG_COND_NE; + imm =3D FPSR_CC_Z | FPSR_CC_N; + c->tcond =3D TCG_COND_TSTNE; break; case 4: /* Ordered Less Than !(!N || A || Z); */ case 20: /* Less Than !(!N || A || Z); */ c->v1 =3D tcg_temp_new(); tcg_gen_xori_i32(c->v1, fpsr, FPSR_CC_N); - tcg_gen_andi_i32(c->v1, c->v1, FPSR_CC_N | FPSR_CC_A | FPSR_CC_Z); - c->tcond =3D TCG_COND_EQ; + imm =3D FPSR_CC_N | FPSR_CC_A | FPSR_CC_Z; + c->tcond =3D TCG_COND_TSTEQ; break; case 5: /* Ordered Less than or Equal Z || (N && !A) */ case 21: /* Less than or Equal Z || (N && !A) */ @@ -5176,49 +5174,45 @@ static void gen_fcc_cond(DisasCompare *c, DisasCont= ext *s, int cond) tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A); tcg_gen_shli_i32(c->v1, c->v1, ctz32(FPSR_CC_N) - ctz32(FPSR_CC_A)= ); tcg_gen_andc_i32(c->v1, fpsr, c->v1); - tcg_gen_andi_i32(c->v1, c->v1, FPSR_CC_Z | FPSR_CC_N); - c->tcond =3D TCG_COND_NE; + imm =3D FPSR_CC_Z | FPSR_CC_N; + c->tcond =3D TCG_COND_TSTNE; break; case 6: /* Ordered Greater or Less than !(A || Z) */ case 22: /* Greater or Less than !(A || Z) */ - c->v1 =3D tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A | FPSR_CC_Z); - c->tcond =3D TCG_COND_EQ; + imm =3D FPSR_CC_A | FPSR_CC_Z; + c->tcond =3D TCG_COND_TSTEQ; break; case 7: /* Ordered !A */ case 23: /* Greater, Less or Equal !A */ - c->v1 =3D tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A); - c->tcond =3D TCG_COND_EQ; + imm =3D FPSR_CC_A; + c->tcond =3D TCG_COND_TSTEQ; break; case 8: /* Unordered A */ case 24: /* Not Greater, Less or Equal A */ - c->v1 =3D tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A); - c->tcond =3D TCG_COND_NE; + imm =3D FPSR_CC_A; + c->tcond =3D TCG_COND_TSTNE; break; case 9: /* Unordered or Equal A || Z */ case 25: /* Not Greater or Less then A || Z */ - c->v1 =3D tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A | FPSR_CC_Z); - c->tcond =3D TCG_COND_NE; + imm =3D FPSR_CC_A | FPSR_CC_Z; + c->tcond =3D TCG_COND_TSTNE; break; case 10: /* Unordered or Greater Than A || !(N || Z)) */ case 26: /* Not Less or Equal A || !(N || Z)) */ c->v1 =3D tcg_temp_new(); tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_Z); tcg_gen_shli_i32(c->v1, c->v1, ctz32(FPSR_CC_N) - ctz32(FPSR_CC_Z)= ); - tcg_gen_andi_i32(fpsr, fpsr, FPSR_CC_A | FPSR_CC_N); tcg_gen_or_i32(c->v1, c->v1, fpsr); tcg_gen_xori_i32(c->v1, c->v1, FPSR_CC_N); - c->tcond =3D TCG_COND_NE; + imm =3D FPSR_CC_A | FPSR_CC_N; + c->tcond =3D TCG_COND_TSTNE; break; case 11: /* Unordered or Greater or Equal A || Z || !N */ case 27: /* Not Less Than A || Z || !N */ c->v1 =3D tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N); - tcg_gen_xori_i32(c->v1, c->v1, FPSR_CC_N); - c->tcond =3D TCG_COND_NE; + tcg_gen_xori_i32(c->v1, fpsr, FPSR_CC_N); + imm =3D FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N; + c->tcond =3D TCG_COND_TSTNE; break; case 12: /* Unordered or Less Than A || (N && !Z) */ case 28: /* Not Greater than or Equal A || (N && !Z) */ @@ -5226,27 +5220,25 @@ static void gen_fcc_cond(DisasCompare *c, DisasCont= ext *s, int cond) tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_Z); tcg_gen_shli_i32(c->v1, c->v1, ctz32(FPSR_CC_N) - ctz32(FPSR_CC_Z)= ); tcg_gen_andc_i32(c->v1, fpsr, c->v1); - tcg_gen_andi_i32(c->v1, c->v1, FPSR_CC_A | FPSR_CC_N); - c->tcond =3D TCG_COND_NE; + imm =3D FPSR_CC_A | FPSR_CC_N; + c->tcond =3D TCG_COND_TSTNE; break; case 13: /* Unordered or Less or Equal A || Z || N */ case 29: /* Not Greater Than A || Z || N */ - c->v1 =3D tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N); - c->tcond =3D TCG_COND_NE; + imm =3D FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N; + c->tcond =3D TCG_COND_TSTNE; break; case 14: /* Not Equal !Z */ case 30: /* Signaling Not Equal !Z */ - c->v1 =3D tcg_temp_new(); - tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_Z); - c->tcond =3D TCG_COND_EQ; + imm =3D FPSR_CC_Z; + c->tcond =3D TCG_COND_TSTEQ; break; case 15: /* True */ case 31: /* Signaling True */ - c->v1 =3D c->v2; c->tcond =3D TCG_COND_ALWAYS; break; } + c->v2 =3D tcg_constant_i32(imm); } =20 static void gen_fjmpcc(DisasContext *s, int cond, TCGLabel *l1) --=20 2.34.1