From nobody Sat Nov 23 17:48:20 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730128782; cv=none; d=zohomail.com; s=zohoarc; b=IEyCQqL6VelKyqnbdwmPH+c1elUJpQ9MtTrhCp2AFrEqK2huMsW1YrQeBD6TF/8cjZCyoKaxCHNKKUtiyT3+QRquxFtDCoAb1RVUCwFAfm7qi0JJvFgCFS8lna/hEJn14v1/q1jzb4jNDDnXxRl656DyFOLu0pMKdjp//rHRGX8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730128782; 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=o5sg1ofJZAEmJb7UHkIAx7/U5KIn00yWoaP0I20s9hQ=; b=ht999Hs4dbq3xo36ElU/WBCeeHQKgrVt7bkMTB3Yr292SeBzc7r+lpWQJmDRJcCiCH/8mW14UNE99mZfBvwxQIu6VbrlGgzS8QgAV1E0Uq/x0GXmbFXMDAFXa0eDu/2qKlk/HR1DZKtnHKmn1KPH0tr+0a/5cPg0D5CL7/G5Yyg= 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 173012878289310.934323119481064; Mon, 28 Oct 2024 08:19:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5RWS-00087H-LT; Mon, 28 Oct 2024 11:19:12 -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 1t5RWP-00086h-K7 for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5RWM-0000jV-Lr for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:08 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-387-AJRjnk7ON3-5ifFwPHAXqQ-1; Mon, 28 Oct 2024 11:19:03 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-37d662dd3c8so2358224f8f.1 for ; Mon, 28 Oct 2024 08:19:03 -0700 (PDT) Received: from [192.168.10.3] ([151.49.226.83]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38058b91f50sm9744049f8f.94.2024.10.28.08.18.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 08:18:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730128745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o5sg1ofJZAEmJb7UHkIAx7/U5KIn00yWoaP0I20s9hQ=; b=XGYGhn2scKbx/MfGFJ8JFiw6g/2700OE2WEN68uCBfEX7jVUai5mZ3xEpTK9ih1/zJM6CK 1kGKcCmLMpPx7bS5CdjLcr0LOBQyllkUZkQYx2fWs9tpaUzs2H4MHTNWS9XGoNDLZ0PM+T xfBolIzvbRXpYtZ83iERQG8N8hWClqQ= X-MC-Unique: AJRjnk7ON3-5ifFwPHAXqQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730128742; x=1730733542; 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=o5sg1ofJZAEmJb7UHkIAx7/U5KIn00yWoaP0I20s9hQ=; b=pRkI9cmLDnZ8XFGf8EjTwHXSn1bTzQFCe5LqcAi3StOIVz45ndBvswmKVfKjQ7P9Vc gERV4BDERuV+90yaw6qCsYxBvg5F0HsFU8Rni9SwvhZT4eb1r3bPGTdfpCy2A57xaTO2 wHrdLEALZlDvFPyThRAS3rlx5YbwEwusDTQrYwmKnHOg7xAQWMUp242ll8UnjlWhhfMw zfDGfTl1T8L0IKTL039qXV3nMtzujPQR3zsth/FmVuwn47UdLKVmH9hJBCgo+4YlvskL kWSPw22jFwc5csSuieUx+fopP+drX/P2FKYFYVvcxV4XRAXVvd2J1Y1xFSg+qJkJmTFV e6Vg== X-Gm-Message-State: AOJu0YyJJRnUNffbUeL/xM4/ySRjemmns8W6ujMTwSm4682FRuaOTcoa VPyg3QXtZBMBmHlqghUU0E/A4kSrvKweSFTaQhnLrH9GDUwQ6h8MV2QS7oTsNbKURlRusVaGPe+ N/tgRhAnClO0xcrA7ba6zwAeiKaznv5Kvu7FkOcTBi59s0+GdjVGSbrCTZKKn9mA0xlaPtT5zS3 OO669Vef76tm4QsVU65zeCA1bPSjACHrASFl5qtrw= X-Received: by 2002:a05:6000:1a48:b0:37d:3e5b:feac with SMTP id ffacd0b85a97d-38061213262mr6609668f8f.59.1730128741878; Mon, 28 Oct 2024 08:19:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF32n/Q6nOsPYGSMYib7uRTokRjrMOygZkCo4T68MpHJhsbp8sj+DkGdRAHHDpdqSgn3KKp3Q== X-Received: by 2002:a05:6000:1a48:b0:37d:3e5b:feac with SMTP id ffacd0b85a97d-38061213262mr6609645f8f.59.1730128741375; Mon, 28 Oct 2024 08:19:01 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PATCH 01/14] target/i386: use tcg_gen_ext_tl when applicable Date: Mon, 28 Oct 2024 16:18:38 +0100 Message-ID: <20241028151851.376355-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241028151851.376355-1-pbonzini@redhat.com> References: <20241028151851.376355-1-pbonzini@redhat.com> 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=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730128784745116600 Content-Type: text/plain; charset="utf-8" Prefer it to gen_ext_tl in the common case where the destination is known. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index ef190416b49..dc308f31041 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -883,16 +883,16 @@ static CCPrepare gen_prepare_eflags_c(DisasContext *s= , TCGv reg) case CC_OP_SUBB ... CC_OP_SUBQ: /* (DATA_TYPE)CC_SRCT < (DATA_TYPE)CC_SRC */ size =3D s->cc_op - CC_OP_SUBB; - gen_ext_tl(s->cc_srcT, s->cc_srcT, size, false); - gen_ext_tl(cpu_cc_src, cpu_cc_src, size, false); + tcg_gen_ext_tl(s->cc_srcT, s->cc_srcT, size); + tcg_gen_ext_tl(cpu_cc_src, cpu_cc_src, size); return (CCPrepare) { .cond =3D TCG_COND_LTU, .reg =3D s->cc_srcT, .reg2 =3D cpu_cc_src, .use_reg2 =3D true }; =20 case CC_OP_ADDB ... CC_OP_ADDQ: /* (DATA_TYPE)CC_DST < (DATA_TYPE)CC_SRC */ size =3D s->cc_op - CC_OP_ADDB; - gen_ext_tl(cpu_cc_dst, cpu_cc_dst, size, false); - gen_ext_tl(cpu_cc_src, cpu_cc_src, size, false); + tcg_gen_ext_tl(cpu_cc_dst, cpu_cc_dst, size); + tcg_gen_ext_tl(cpu_cc_src, cpu_cc_src, size); return (CCPrepare) { .cond =3D TCG_COND_LTU, .reg =3D cpu_cc_dst, .reg2 =3D cpu_cc_src, .use_reg2 =3D true }; =20 @@ -1041,8 +1041,8 @@ static CCPrepare gen_prepare_cc(DisasContext *s, int = b, TCGv reg) size =3D s->cc_op - CC_OP_SUBB; switch (jcc_op) { case JCC_BE: - gen_ext_tl(s->cc_srcT, s->cc_srcT, size, false); - gen_ext_tl(cpu_cc_src, cpu_cc_src, size, false); + tcg_gen_ext_tl(s->cc_srcT, s->cc_srcT, size); + tcg_gen_ext_tl(cpu_cc_src, cpu_cc_src, size); cc =3D (CCPrepare) { .cond =3D TCG_COND_LEU, .reg =3D s->cc_sr= cT, .reg2 =3D cpu_cc_src, .use_reg2 =3D true }; break; @@ -1052,8 +1052,8 @@ static CCPrepare gen_prepare_cc(DisasContext *s, int = b, TCGv reg) case JCC_LE: cond =3D TCG_COND_LE; fast_jcc_l: - gen_ext_tl(s->cc_srcT, s->cc_srcT, size, true); - gen_ext_tl(cpu_cc_src, cpu_cc_src, size, true); + tcg_gen_ext_tl(s->cc_srcT, s->cc_srcT, size | MO_SIGN); + tcg_gen_ext_tl(cpu_cc_src, cpu_cc_src, size | MO_SIGN); cc =3D (CCPrepare) { .cond =3D cond, .reg =3D s->cc_srcT, .reg2 =3D cpu_cc_src, .use_reg2 =3D true }; break; --=20 2.47.0 From nobody Sat Nov 23 17:48:20 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730128800; cv=none; d=zohomail.com; s=zohoarc; b=ZrcSmFtt2bGi7k3UsAfO8xYcbqNbAua1EwDmh8FUuqt1NEkVU5JPIKrWH2x33rGED6PE/+vh6NY00LSW11ynvxWta0LPC4unAyf+efrFMCT3ItLNFcPnICcbGfAk1qc4R7IrNhyvdKJEEHaiIubc5i+usJcb0++M88CbGJVFjsk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730128800; 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=BWcfg2aupe5UaZvSXBPNOsSy5nqMqX/xbZPHsRPq/yw=; b=i83aD9ICpkPyuzwhMosZqi8pXzfT4hFrbJ7PQxvnBiGv79oPhpbEnw6XdPJlpBqeEEILLszEjdWJ5wuE4A4VllF9a7B9IHDF/yTYrs9mmY3RN4LM/KTTMkuErZLPdcKw5z0QNfVN2GK/f5Bc6xXLgjwM4Le+2WVK2V/MvcF/zNo= 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 1730128800183752.1914427440306; Mon, 28 Oct 2024 08:20:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5RWT-00087g-Q3; Mon, 28 Oct 2024 11:19: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 1t5RWR-000879-GR for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5RWP-0000kB-Us for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:11 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-342-92xPeURMNim3jKsG1x8t-g-1; Mon, 28 Oct 2024 11:19:06 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4316ac69e6dso34480925e9.0 for ; Mon, 28 Oct 2024 08:19:06 -0700 (PDT) Received: from [192.168.10.3] ([151.49.226.83]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43193594ff3sm111869205e9.12.2024.10.28.08.19.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 08:19:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730128749; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BWcfg2aupe5UaZvSXBPNOsSy5nqMqX/xbZPHsRPq/yw=; b=EqcMaV/0VGfU7JlhkZD80TMzGPxzC+85Qk5M3WkI+vgeQ8gllvSUbsDOYRx4tTACNbm2OR 0BR22FhRU0tFYfUzAO0vBSRETkeY2nylQ7XwWR71U745zQQ7aRodj594hYw6Mi+duG+CXI n88+hY1ZiDRYyHXMp15n4aek+Cn0DYU= X-MC-Unique: 92xPeURMNim3jKsG1x8t-g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730128744; x=1730733544; 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=BWcfg2aupe5UaZvSXBPNOsSy5nqMqX/xbZPHsRPq/yw=; b=r4pIEsOUTJQSap2Lkkm85kALjwFQd3eLQGKGZB0bjhBDNz/MYffI8vXTVYUNcI93eZ DvaXtAzpxjWZ5bG3wyKK0VVyLc3NEIaaP8G2V1FG9WJJsm1jDnyWwU+s7HOq2cUVLm1R xvlUCiz8/mio/aONs9/wQKCz4qk1xti7h5has51dEzgcbpjssTmOuH/VjjfOazuXK8z6 Y1mAIKGYIWq/ZBtDVbAWeA+L2Ffv2Pkd5ifN6M0hiZCL3RJGe8V+kxa+zM9CdkYoYW4Z gEz3pI030uYB79hg52tBIO2AqNt7V0/YU0toO6iHPrdPqfokZkJ4CfV3pK/fu0gc0tck hT4g== X-Gm-Message-State: AOJu0YxyQXn+dVLf5xm2PEswvcrGF6FHQMA2lcT73gyfy5d8WDcgiCP1 m61F1nRgq4LudG1p0E9++wqmdmo3vqTiOK3kV525aZZd3jocAI6wSPIJdioMo8v9rhqsiZWGwL5 IzrGI6f82YFJabzxAhrohXC0mUUFDIJ1vrKgbMMAw6ywAZgyDdIVhyFjo1p9M37+7kvwRuDIumK Y0IkMxrYdeRrGt1CFQ3iXoNdTX+asLSoZf4JK+vp4= X-Received: by 2002:a05:600c:5253:b0:431:46fe:4cc1 with SMTP id 5b1f17b1804b1-4319aca42bemr78561095e9.10.1730128744561; Mon, 28 Oct 2024 08:19:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGpnzqoSD1fQYM7XxRtrvJGC3rYFxs1HKBKS9UoSHO7uiXWV4wMD/juc9P8S9uHzdDQI9VTbQ== X-Received: by 2002:a05:600c:5253:b0:431:46fe:4cc1 with SMTP id 5b1f17b1804b1-4319aca42bemr78560835e9.10.1730128744045; Mon, 28 Oct 2024 08:19:04 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PATCH 02/14] target/i386: Tidy cc_op_str usage Date: Mon, 28 Oct 2024 16:18:39 +0100 Message-ID: <20241028151851.376355-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241028151851.376355-1-pbonzini@redhat.com> References: <20241028151851.376355-1-pbonzini@redhat.com> 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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730128800617116600 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Make const. Use the read-only strings directly; do not copy them into an on-stack buffer with snprintf. Allow for holes in the cc_op_str array, now present with CC_OP_POPCNT. Fixes: 460231ad369 ("target/i386: give CC_OP_POPCNT low bits corresponding = to MO_TL") Signed-off-by: Richard Henderson Link: https://lore.kernel.org/r/20240701025115.1265117-2-richard.henderson@= linaro.org Signed-off-by: Paolo Bonzini --- target/i386/cpu-dump.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/target/i386/cpu-dump.c b/target/i386/cpu-dump.c index 3bb8e440916..dc6723aedee 100644 --- a/target/i386/cpu-dump.c +++ b/target/i386/cpu-dump.c @@ -27,7 +27,7 @@ /***********************************************************/ /* x86 debug */ =20 -static const char *cc_op_str[CC_OP_NB] =3D { +static const char * const cc_op_str[] =3D { [CC_OP_DYNAMIC] =3D "DYNAMIC", =20 [CC_OP_EFLAGS] =3D "EFLAGS", @@ -347,7 +347,6 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, int flag= s) X86CPU *cpu =3D X86_CPU(cs); CPUX86State *env =3D &cpu->env; int eflags, i, nb; - char cc_op_name[32]; static const char *seg_name[6] =3D { "ES", "CS", "SS", "DS", "FS", "GS= " }; =20 eflags =3D cpu_compute_eflags(env); @@ -456,10 +455,16 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, int fl= ags) env->dr[6], env->dr[7]); } if (flags & CPU_DUMP_CCOP) { - if ((unsigned)env->cc_op < CC_OP_NB) - snprintf(cc_op_name, sizeof(cc_op_name), "%s", cc_op_str[env->= cc_op]); - else - snprintf(cc_op_name, sizeof(cc_op_name), "[%d]", env->cc_op); + const char *cc_op_name =3D NULL; + char cc_op_buf[32]; + + if ((unsigned)env->cc_op < ARRAY_SIZE(cc_op_str)) { + cc_op_name =3D cc_op_str[env->cc_op]; + } + if (cc_op_name =3D=3D NULL) { + snprintf(cc_op_buf, sizeof(cc_op_buf), "[%d]", env->cc_op); + cc_op_name =3D cc_op_buf; + } #ifdef TARGET_X86_64 if (env->hflags & HF_CS64_MASK) { qemu_fprintf(f, "CCS=3D%016" PRIx64 " CCD=3D%016" PRIx64 " CCO= =3D%s\n", --=20 2.47.0 From nobody Sat Nov 23 17:48:20 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730128885; cv=none; d=zohomail.com; s=zohoarc; b=jyStGavUiwmGQPZujyJHMYmZJTRBReJBO387wdoe+34z0aEijmIMpWTOKKCUxxastzi40Eq6SE0m+dueXd4bjUxEoEuQMyubWP1hvJlv7UDQtdWrUB5nuB1Q/AG539HFHw0pvTq3THhK7c22WPqA4zXUhAM3C4HpC+7JKy4HOiE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730128885; 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=Ta5bS5NbEQAqbf6xMbCTMInS113bUn9DSzBqHZNGXpY=; b=I8Vd9AC+ZuuBwycw2OA0s8lRdlRXoE+R80ZaYNBLMb4e4gs4+YiS9h0xaVQkyftlXmMRAnqiQKArNbpSM7qP16kjHC46kzob9In8tBkjKXdhjYSNfeDXGWl8QwMEKXhVukpjcqCwhveGfgWcMbs58sevP+snywMCVR5Dnf3vBrw= 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 1730128885683180.66961076493385; Mon, 28 Oct 2024 08:21:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5RWV-00088Q-HO; Mon, 28 Oct 2024 11:19:15 -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 1t5RWT-00087Z-GH for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5RWR-0000l1-RW for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:13 -0400 Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-563-KS8vZNwUMlejoNsBhXLqFg-1; Mon, 28 Oct 2024 11:19:10 -0400 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-539fbbadca7so3737154e87.3 for ; Mon, 28 Oct 2024 08:19:09 -0700 (PDT) Received: from [192.168.10.3] ([151.49.226.83]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38058b3bb57sm9761086f8f.38.2024.10.28.08.19.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 08:19:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730128751; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ta5bS5NbEQAqbf6xMbCTMInS113bUn9DSzBqHZNGXpY=; b=AvwaciX/x30qf1JBixtsS3W/nNu/Jh8DomStFaZuaRJsL/YU161NkL8RdGVVOkuSyrB5pE +R6d7i+dp9oyw0bJbZivfINihanDE3vxBVkLE9PvHT8hwBLCRb8bfs0YnWFpJDZWSYw/X4 RC+k/vd5UNxTKJikgnxRq3159c1Byqw= X-MC-Unique: KS8vZNwUMlejoNsBhXLqFg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730128747; x=1730733547; 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=Ta5bS5NbEQAqbf6xMbCTMInS113bUn9DSzBqHZNGXpY=; b=AydYgTL2qAZfmIBMrgsEEJiMee8MwxBtJkVt14K3pySaUlhKO9IHbTSCD3wwuqsjeu gU3HUe+PRi/FITKnlDS3I/aZeivV4ywEr6zXtB8ja0vUZ03MGnk5TL5rK5Qj1U7Ej4xO MQkLYQ4BOwnht49xmxREaD2hlj2FT5hu5X/if5bCUsiGjY6Na0xAF9wBzBGjhFEeoReK D4g2AUncztDanDgxffUa/4Ep/arlt32liHFGOxnefgbE/RSOrARc323lhF834QL7rzIB LLJok7h1d5GBxDLI6yR9iw7G7n+njHvzCqo6ycDFMFmgVvxqwarPS8szlDHkKGa2rTm3 kz3A== X-Gm-Message-State: AOJu0YylFeU0lPXBotEZaiNG+IvECy2IF7QRc0zrfNY+kN10X+ByBroi GvD06vWU04w+hOVwqehKI5tvvOYBbytykIzVuIVresHm/8/oMv96EFgo06qVEEFFfVLg+FfN1dh OkbQxjXTSgdIERe+ZoJYckXMl5YKtejev8aFaBfwWccXJuS4UcVjSbry5JsHGtVIbc9lAB81YLc iPjz1xGYxbOR7GTNMEnC8hDH2GjRJfDIQUrHvcKkg= X-Received: by 2002:a05:6512:3f07:b0:535:6a4d:ed74 with SMTP id 2adb3069b0e04-53b34b370d4mr4074820e87.51.1730128747237; Mon, 28 Oct 2024 08:19:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGAKqsJN6Tzd9N+SRqNC2dpxVOGUpL89zCdQDCrsg5ovEh/1JYCQCr9M6fMPCj/8wtY67/OSQ== X-Received: by 2002:a05:6512:3f07:b0:535:6a4d:ed74 with SMTP id 2adb3069b0e04-53b34b370d4mr4074783e87.51.1730128746592; Mon, 28 Oct 2024 08:19:06 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PATCH 03/14] target/i386: remove CC_OP_CLR Date: Mon, 28 Oct 2024 16:18:40 +0100 Message-ID: <20241028151851.376355-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241028151851.376355-1-pbonzini@redhat.com> References: <20241028151851.376355-1-pbonzini@redhat.com> 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=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730128887129116600 Content-Type: text/plain; charset="utf-8" Just use CC_OP_EFLAGS; it is not that likely that the flags computed by CC_OP_CLR survive the end of the basic block, in which case there is no need to spill cc_op_src. cc_op_src now does need spilling if the XOR is followed by a memory operation, but this only costs 0.2% extra TCG ops. They will be recouped by simplifications in how QEMU evaluates ZF at runtime, which are even greater with this change. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 1 - target/i386/cpu-dump.c | 1 - target/i386/tcg/cc_helper.c | 3 --- target/i386/tcg/translate.c | 10 ---------- target/i386/tcg/emit.c.inc | 15 ++++----------- 5 files changed, 4 insertions(+), 26 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index e4c947b478b..c89db50eddc 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1297,7 +1297,6 @@ typedef enum { CC_OP_ADCX, /* CC_DST =3D C, CC_SRC =3D rest. */ CC_OP_ADOX, /* CC_SRC2 =3D O, CC_SRC =3D rest. */ CC_OP_ADCOX, /* CC_DST =3D C, CC_SRC2 =3D O, CC_SRC =3D rest. */ - CC_OP_CLR, /* Z and P set, all other flags clear. */ =20 CC_OP_MULB, /* modify all flags, C, O =3D (CC_SRC !=3D 0) */ CC_OP_MULW, diff --git a/target/i386/cpu-dump.c b/target/i386/cpu-dump.c index dc6723aedee..a72ed93bd2f 100644 --- a/target/i386/cpu-dump.c +++ b/target/i386/cpu-dump.c @@ -91,7 +91,6 @@ static const char * const cc_op_str[] =3D { [CC_OP_BMILGQ] =3D "BMILGQ", =20 [CC_OP_POPCNT] =3D "POPCNT", - [CC_OP_CLR] =3D "CLR", }; =20 static void diff --git a/target/i386/tcg/cc_helper.c b/target/i386/tcg/cc_helper.c index dbddaa2fcb3..40583c04cf9 100644 --- a/target/i386/tcg/cc_helper.c +++ b/target/i386/tcg/cc_helper.c @@ -104,8 +104,6 @@ target_ulong helper_cc_compute_all(target_ulong dst, ta= rget_ulong src1, =20 case CC_OP_EFLAGS: return src1; - case CC_OP_CLR: - return CC_Z | CC_P; case CC_OP_POPCNT: return dst ? 0 : CC_Z; =20 @@ -243,7 +241,6 @@ target_ulong helper_cc_compute_c(target_ulong dst, targ= et_ulong src1, case CC_OP_LOGICW: case CC_OP_LOGICL: case CC_OP_LOGICQ: - case CC_OP_CLR: case CC_OP_POPCNT: return 0; =20 diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index dc308f31041..a20fbb019c8 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -309,7 +309,6 @@ static const uint8_t cc_op_live[CC_OP_NB] =3D { [CC_OP_ADCX] =3D USES_CC_DST | USES_CC_SRC, [CC_OP_ADOX] =3D USES_CC_SRC | USES_CC_SRC2, [CC_OP_ADCOX] =3D USES_CC_DST | USES_CC_SRC | USES_CC_SRC2, - [CC_OP_CLR] =3D 0, [CC_OP_POPCNT] =3D USES_CC_DST, }; =20 @@ -803,10 +802,6 @@ static void gen_mov_eflags(DisasContext *s, TCGv reg) tcg_gen_mov_tl(reg, cpu_cc_src); return; } - if (s->cc_op =3D=3D CC_OP_CLR) { - tcg_gen_movi_tl(reg, CC_Z | CC_P); - return; - } =20 dst =3D cpu_cc_dst; src1 =3D cpu_cc_src; @@ -897,7 +892,6 @@ static CCPrepare gen_prepare_eflags_c(DisasContext *s, = TCGv reg) .reg2 =3D cpu_cc_src, .use_reg2 =3D true }; =20 case CC_OP_LOGICB ... CC_OP_LOGICQ: - case CC_OP_CLR: case CC_OP_POPCNT: return (CCPrepare) { .cond =3D TCG_COND_NEVER }; =20 @@ -969,7 +963,6 @@ static CCPrepare gen_prepare_eflags_s(DisasContext *s, = TCGv reg) case CC_OP_ADCOX: return (CCPrepare) { .cond =3D TCG_COND_TSTNE, .reg =3D cpu_cc_src, .imm =3D CC_S }; - case CC_OP_CLR: case CC_OP_POPCNT: return (CCPrepare) { .cond =3D TCG_COND_NEVER }; default: @@ -988,7 +981,6 @@ static CCPrepare gen_prepare_eflags_o(DisasContext *s, = TCGv reg) case CC_OP_ADCOX: return (CCPrepare) { .cond =3D TCG_COND_NE, .reg =3D cpu_cc_src2, .no_setcond =3D true }; - case CC_OP_CLR: case CC_OP_POPCNT: return (CCPrepare) { .cond =3D TCG_COND_NEVER }; case CC_OP_MULB ... CC_OP_MULQ: @@ -1013,8 +1005,6 @@ static CCPrepare gen_prepare_eflags_z(DisasContext *s= , TCGv reg) case CC_OP_ADCOX: return (CCPrepare) { .cond =3D TCG_COND_TSTNE, .reg =3D cpu_cc_src, .imm =3D CC_Z }; - case CC_OP_CLR: - return (CCPrepare) { .cond =3D TCG_COND_ALWAYS }; default: { MemOp size =3D (s->cc_op - CC_OP_ADDB) & 3; diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index fd17a9b1eca..790307dbba8 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -1452,19 +1452,12 @@ static void gen_bt_flags(DisasContext *s, X86Decode= dInsn *decode, TCGv src, TCGv * C is the result of the test, Z is unchanged, and the others * are all undefined. */ - switch (s->cc_op) { - case CC_OP_DYNAMIC: - case CC_OP_CLR: - case CC_OP_EFLAGS: - case CC_OP_ADCX: - case CC_OP_ADOX: - case CC_OP_ADCOX: + if (s->cc_op =3D=3D CC_OP_DYNAMIC || CC_OP_HAS_EFLAGS(s->cc_op)) { /* Generate EFLAGS and replace the C bit. */ cf =3D tcg_temp_new(); tcg_gen_setcond_tl(TCG_COND_TSTNE, cf, src, mask); prepare_update_cf(decode, s, cf); - break; - default: + } else { /* * Z was going to be computed from the non-zero status of CC_DST. * We can get that same Z value (and the new C value) by leaving @@ -1475,7 +1468,6 @@ static void gen_bt_flags(DisasContext *s, X86DecodedI= nsn *decode, TCGv src, TCGv decode->cc_dst =3D cpu_cc_dst; decode->cc_op =3D ((s->cc_op - CC_OP_MULB) & 3) + CC_OP_SARB; tcg_gen_shr_tl(decode->cc_src, src, s->T1); - break; } } =20 @@ -4724,7 +4716,8 @@ static void gen_XOR(DisasContext *s, X86DecodedInsn *= decode) decode->op[2].unit =3D=3D X86_OP_INT && decode->op[1].n =3D=3D decode->op[2].n) { tcg_gen_movi_tl(s->T0, 0); - decode->cc_op =3D CC_OP_CLR; + decode->cc_op =3D CC_OP_EFLAGS; + decode->cc_src =3D tcg_constant_tl(CC_Z | CC_P); } else { MemOp ot =3D decode->op[1].ot; =20 --=20 2.47.0 From nobody Sat Nov 23 17:48:20 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730128892; cv=none; d=zohomail.com; s=zohoarc; b=KnGCNzPIKlfzfCj4iuFeeNhZLD/IMbPUZjuMA6qHOnUJb9FR6qVkffnoXYayWKRsqkxQmvgWR2NaSE+mjs420Pm8kQIwkDrOwJzvl7uIBbnZkB9yWNlAKwo3/XvHl2xadlJQY6eGhAx15bMvTq63jsHaChVd+EORW2vqcWcRiRE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730128892; 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=+8Ycd/z4FSPPHkMPrNjkGaE9+9ckB94sy40JwoCKvsU=; b=B/ehvAv9bVsPWXNNgXujlPSsEFUlPqm0o0xnxzoxCbutuNVIy+mwCjfu69tqzCnde337Q1n6dWFKP3cPXGI2rAWT0zSGfoLX1dOuMuRRtydxQsFDnQy51Gu8ftrKuhBmewYlHrWLgWJ6uZTtNOaPJJYNyK9Lvm5QI1ocrKuPucc= 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 1730128892524171.21215698981428; Mon, 28 Oct 2024 08:21:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5RWW-00088U-3l; Mon, 28 Oct 2024 11:19:16 -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 1t5RWU-000881-6U for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5RWS-0000lU-Nb for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:13 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-589-0hOPG-MMMzmhPwXmff9BiA-1; Mon, 28 Oct 2024 11:19:10 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-37d4922d8c7so2507929f8f.1 for ; Mon, 28 Oct 2024 08:19:10 -0700 (PDT) Received: from [192.168.10.3] ([151.49.226.83]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4319360c10asm112627335e9.43.2024.10.28.08.19.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 08:19:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730128752; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+8Ycd/z4FSPPHkMPrNjkGaE9+9ckB94sy40JwoCKvsU=; b=a1OjoLLN+jN0/8jDTNH6hJ+V/zGDi5IQ+x7J3Ano8EbLta7q0BDUDqjGTwCnOW3SlhPn84 RhvBoUk/gBMi8rgk7d3UtPPM4NloXYMUJjMJzYzUoYDTs/+D8HMpFWRiRxAHg6VY1NIoU/ 8htWLoiLvPzLi7lXIrqWBFSSGCrt+cI= X-MC-Unique: 0hOPG-MMMzmhPwXmff9BiA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730128748; x=1730733548; 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=+8Ycd/z4FSPPHkMPrNjkGaE9+9ckB94sy40JwoCKvsU=; b=Td7fATlVkptJgKusW+TAZE0UtihVa2upBUyNssNFtw1SBZO1mXbuPssiK0WBO5Qthp 7tsdiIJzh6+KNF3USsH83NYQVYhZY6zvUp4/KK/dBXU0Zv/GGeKnCC8lzr8FM5kfEEvq VRuFDOJD3WqNAZ25O0B7X+Co2mLHjutrCzqfdTMviN/hvL/qLLDL+vnayqXSeNeyMl3/ kggStq0CrznZyN77WUXab1e+NNX1XX2k6OzIn/qyJHegqojhhRHFhCJLCCr1IlS3Jdv1 Z4Vj2Iq2FrrWBjVjUD1eDExklGMlbuKYa7iU9QH6FdlLEYeIh3rmAcLk0xoH9d40NKcE Mm7Q== X-Gm-Message-State: AOJu0YxT9veivJiX9sx8+j2tPPEJ9HKiRKtNEgti76h5VjST+Wzy6NS1 L+AExSI5pUghho3lBVWZHUB624gHckPX9cd/z4kPzk/uzsBZlXrgWBTmb4f0/zhr4CAmJnmjrPd F21w6dENG86LN76VszjAxrBBG7RK8EpMxbmi6Qbepo2YdJ7m5eJSlesFoOFXFZKKRPXECrbPCzO Qgimt8nAvxNUEynf0zBa35WdlSSZhe6z1vcgvpzGU= X-Received: by 2002:a5d:49c2:0:b0:37d:373c:ed24 with SMTP id ffacd0b85a97d-380610f41damr6656490f8f.4.1730128748390; Mon, 28 Oct 2024 08:19:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGEEjSrjEHizHea+uFW5482drizHedRKHRKEeieHXAGcfBZcHdQ2AlopOgzGtEs3xZTF+OpOg== X-Received: by 2002:a5d:49c2:0:b0:37d:373c:ed24 with SMTP id ffacd0b85a97d-380610f41damr6656469f8f.4.1730128747994; Mon, 28 Oct 2024 08:19:07 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PATCH 04/14] target/i386: Rearrange CCOp Date: Mon, 28 Oct 2024 16:18:41 +0100 Message-ID: <20241028151851.376355-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241028151851.376355-1-pbonzini@redhat.com> References: <20241028151851.376355-1-pbonzini@redhat.com> 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=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730128893151116600 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Give the first few enumerators explicit integer constants, align the BWLQ enumerators. This will be used to simplify ((op - CC_OP_*B) & 3). Signed-off-by: Richard Henderson Link: https://lore.kernel.org/r/20240701025115.1265117-4-richard.henderson@= linaro.org Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index c89db50eddc..b605f592521 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1292,11 +1292,10 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU = *cpu, FeatureWord w); * are only needed for conditional branches. */ typedef enum { - CC_OP_DYNAMIC, /* must use dynamic code to get cc_op */ - CC_OP_EFLAGS, /* all cc are explicitly computed, CC_SRC =3D flags */ - CC_OP_ADCX, /* CC_DST =3D C, CC_SRC =3D rest. */ - CC_OP_ADOX, /* CC_SRC2 =3D O, CC_SRC =3D rest. */ - CC_OP_ADCOX, /* CC_DST =3D C, CC_SRC2 =3D O, CC_SRC =3D rest. */ + CC_OP_EFLAGS =3D 0, /* all cc are explicitly computed, CC_SRC =3D fla= gs */ + CC_OP_ADCX =3D 1, /* CC_DST =3D C, CC_SRC =3D rest. */ + CC_OP_ADOX =3D 2, /* CC_SRC2 =3D O, CC_SRC =3D rest. */ + CC_OP_ADCOX =3D 3, /* CC_DST =3D C, CC_SRC2 =3D O, CC_SRC =3D rest. = */ =20 CC_OP_MULB, /* modify all flags, C, O =3D (CC_SRC !=3D 0) */ CC_OP_MULW, @@ -1369,9 +1368,12 @@ typedef enum { CC_OP_POPCNTQ__, CC_OP_POPCNT =3D sizeof(target_ulong) =3D=3D 8 ? CC_OP_POPCNTQ__ : CC_= OP_POPCNTL__, =20 + CC_OP_DYNAMIC, /* must use dynamic code to get cc_op */ CC_OP_NB, } CCOp; -QEMU_BUILD_BUG_ON(CC_OP_NB >=3D 128); + +/* See X86DecodedInsn.cc_op, using int8_t. */ +QEMU_BUILD_BUG_ON(CC_OP_DYNAMIC > INT8_MAX); =20 typedef struct SegmentCache { uint32_t selector; --=20 2.47.0 From nobody Sat Nov 23 17:48:20 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730128909; cv=none; d=zohomail.com; s=zohoarc; b=g93nJak3P1fUA85IwUcQdqv11pZ2FjITGMYNCMikf/Sc0JLIQSHdHHpTX0gebN3JFK97SXy39tP+v89XrDgEQKc3BdJ+ZXfzsWh26bV1x/FzyTFWq8vu9WQHZ3BYcD4lgjk/BN6ja+eBROfOWVQujh08Bh7EJVdHLMuzMdJLDU0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730128909; 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=QvJLaUXFnx51Ug+obYoa6k7VHJ36CTBZhnV1VhVECZk=; b=BrRZbY8OIiTAhJpXNNHs0auWebPo3HF9SPf4XKNj6vwZ5M/zIgQUQXI3QJwEiE5UXb3Ls6EUdLfURXQGNZCno6WHF82mj4s4lj21Ty5OwQ+KTWPe6iJlXXeOsV4VqtJUAc7DplWrJ6VliE+mJ1fcWWZp/vDa7Ddlrzrl9QGFHfY= 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 1730128909725809.6453245987221; Mon, 28 Oct 2024 08:21:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5RWa-00089X-BF; Mon, 28 Oct 2024 11:19:20 -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 1t5RWY-00088u-VY for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5RWW-0000mg-RW for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:18 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-605-NJhPNrGmP4GcSjaGosR5mA-1; Mon, 28 Oct 2024 11:19:14 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4317391101aso32293685e9.2 for ; Mon, 28 Oct 2024 08:19:14 -0700 (PDT) Received: from [192.168.10.3] ([151.49.226.83]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38058b70e0fsm9781488f8f.73.2024.10.28.08.19.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 08:19:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730128756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QvJLaUXFnx51Ug+obYoa6k7VHJ36CTBZhnV1VhVECZk=; b=WC2132QXhNVqMBGsVO06eYQR9FIU2hh2Mxp61xN/b0UMALrsl2iOhRp0cixxzLRa0hO1aD OEpf8GyW7tObR3RrgEjBKZntGWttVBgxfiYm8dj9nDYaWsKMOcQU7kXs2IIIDTprYAT/Zr OwNOXazciMm7tA7KXi4/7AxoPSLpfSs= X-MC-Unique: NJhPNrGmP4GcSjaGosR5mA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730128752; x=1730733552; 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=QvJLaUXFnx51Ug+obYoa6k7VHJ36CTBZhnV1VhVECZk=; b=FAnJOhArcvUDb/jMLiJBTXf2AWJRQUIrIYf0PgG/ivABe1AUPiN4+ZWc59lAVS+q5f 8rEJd+9IXLoZXUZdJ+ifBXTYwz5ZhwrBqf1P/y7O6UJpLPRg0F6gZ0gQ1CBugQNiDFeQ LjuyGK6SLrYsSWcMHOX2AtSwlqIapf1tdM1ITr9NrH+M/hC88xkaFhBTQ3WERaKdRznr FSkhjFmzBS//FRNcftEfMfTY/QIHRQKawhdwAfwM2pEOSkLndo2awghH1vIY8CA55sw2 aLZVFbNlLmnn2wGGbdcoYQQJMG5K52Y2d4POA0QsbOjENBajvnBdatzcf+p+9b/nTe8r kZqA== X-Gm-Message-State: AOJu0YwOj7SAHELsfLQFF6ej3VS2Yua+Y9JeFeOvPKUsm9YNCZTcBYjm M5hbO3fLmzDo8blNaZ1jqZVbrCArukUoGkXucNIMiiAdW1HtZWjF/qdJRZUcTVXpcqQ4SRcHgzC T6MAuggWIcQAFogJCK6ujhvI4BMeHTakz7T+PLrGEEj846QPvgQf5rFQLHjNFbrPtxFSqKjvSFJ JNg6Zv+L6Wv/Lq/V8ivkEwNAw6okBVCNLGuvQJdcs= X-Received: by 2002:a05:600c:3488:b0:431:5ce5:4864 with SMTP id 5b1f17b1804b1-4319ad36982mr60265175e9.35.1730128752106; Mon, 28 Oct 2024 08:19:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEocXgIrvmk9qEpKHhxRXYTmcg5Z1ZUXqnmrS+bgw2ieN40w5YY32c/BHjrzgR/VD+gqVWaFA== X-Received: by 2002:a05:600c:3488:b0:431:5ce5:4864 with SMTP id 5b1f17b1804b1-4319ad36982mr60264945e9.35.1730128751610; Mon, 28 Oct 2024 08:19:11 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PATCH 05/14] target/i386: Introduce cc_op_size Date: Mon, 28 Oct 2024 16:18:42 +0100 Message-ID: <20241028151851.376355-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241028151851.376355-1-pbonzini@redhat.com> References: <20241028151851.376355-1-pbonzini@redhat.com> 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=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730128911640116600 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Replace arithmetic on cc_op with a helper function. Assert that the op has a size and that it is valid for the configuration. Signed-off-by: Richard Henderson Link: https://lore.kernel.org/r/20240701025115.1265117-6-richard.henderson@= linaro.org Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 17 ++++++++++++++++- target/i386/tcg/translate.c | 17 +++++++---------- target/i386/tcg/emit.c.inc | 5 +++-- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index b605f592521..e598fe3de9a 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -24,6 +24,7 @@ #include "cpu-qom.h" #include "kvm/hyperv-proto.h" #include "exec/cpu-defs.h" +#include "exec/memop.h" #include "hw/i386/topology.h" #include "qapi/qapi-types-common.h" #include "qemu/cpu-float.h" @@ -1297,7 +1298,9 @@ typedef enum { CC_OP_ADOX =3D 2, /* CC_SRC2 =3D O, CC_SRC =3D rest. */ CC_OP_ADCOX =3D 3, /* CC_DST =3D C, CC_SRC2 =3D O, CC_SRC =3D rest. = */ =20 - CC_OP_MULB, /* modify all flags, C, O =3D (CC_SRC !=3D 0) */ + /* Low 2 bits =3D MemOp constant for the size */ +#define CC_OP_FIRST_BWLQ CC_OP_MULB + CC_OP_MULB =3D 4, /* modify all flags, C, O =3D (CC_SRC !=3D 0) */ CC_OP_MULW, CC_OP_MULL, CC_OP_MULQ, @@ -1367,6 +1370,7 @@ typedef enum { CC_OP_POPCNTL__, CC_OP_POPCNTQ__, CC_OP_POPCNT =3D sizeof(target_ulong) =3D=3D 8 ? CC_OP_POPCNTQ__ : CC_= OP_POPCNTL__, +#define CC_OP_LAST_BWLQ CC_OP_POPCNTQ__ =20 CC_OP_DYNAMIC, /* must use dynamic code to get cc_op */ CC_OP_NB, @@ -1375,6 +1379,17 @@ typedef enum { /* See X86DecodedInsn.cc_op, using int8_t. */ QEMU_BUILD_BUG_ON(CC_OP_DYNAMIC > INT8_MAX); =20 +static inline MemOp cc_op_size(CCOp op) +{ + MemOp size =3D op & 3; + + QEMU_BUILD_BUG_ON(CC_OP_FIRST_BWLQ & 3); + assert(op >=3D CC_OP_FIRST_BWLQ && op <=3D CC_OP_LAST_BWLQ); + assert(size <=3D MO_TL); + + return size; +} + typedef struct SegmentCache { uint32_t selector; target_ulong base; diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index a20fbb019c8..46062002c02 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -885,7 +885,7 @@ static CCPrepare gen_prepare_eflags_c(DisasContext *s, = TCGv reg) =20 case CC_OP_ADDB ... CC_OP_ADDQ: /* (DATA_TYPE)CC_DST < (DATA_TYPE)CC_SRC */ - size =3D s->cc_op - CC_OP_ADDB; + size =3D cc_op_size(s->cc_op); tcg_gen_ext_tl(cpu_cc_dst, cpu_cc_dst, size); tcg_gen_ext_tl(cpu_cc_src, cpu_cc_src, size); return (CCPrepare) { .cond =3D TCG_COND_LTU, .reg =3D cpu_cc_dst, @@ -902,7 +902,7 @@ static CCPrepare gen_prepare_eflags_c(DisasContext *s, = TCGv reg) =20 case CC_OP_SHLB ... CC_OP_SHLQ: /* (CC_SRC >> (DATA_BITS - 1)) & 1 */ - size =3D s->cc_op - CC_OP_SHLB; + size =3D cc_op_size(s->cc_op); return gen_prepare_sign_nz(cpu_cc_src, size); =20 case CC_OP_MULB ... CC_OP_MULQ: @@ -910,11 +910,11 @@ static CCPrepare gen_prepare_eflags_c(DisasContext *s= , TCGv reg) .reg =3D cpu_cc_src }; =20 case CC_OP_BMILGB ... CC_OP_BMILGQ: - size =3D s->cc_op - CC_OP_BMILGB; + size =3D cc_op_size(s->cc_op); return gen_prepare_val_nz(cpu_cc_src, size, true); =20 case CC_OP_BLSIB ... CC_OP_BLSIQ: - size =3D s->cc_op - CC_OP_BLSIB; + size =3D cc_op_size(s->cc_op); return gen_prepare_val_nz(cpu_cc_src, size, false); =20 case CC_OP_ADCX: @@ -966,10 +966,7 @@ static CCPrepare gen_prepare_eflags_s(DisasContext *s,= TCGv reg) case CC_OP_POPCNT: return (CCPrepare) { .cond =3D TCG_COND_NEVER }; default: - { - MemOp size =3D (s->cc_op - CC_OP_ADDB) & 3; - return gen_prepare_sign_nz(cpu_cc_dst, size); - } + return gen_prepare_sign_nz(cpu_cc_dst, cc_op_size(s->cc_op)); } } =20 @@ -1007,7 +1004,7 @@ static CCPrepare gen_prepare_eflags_z(DisasContext *s= , TCGv reg) .imm =3D CC_Z }; default: { - MemOp size =3D (s->cc_op - CC_OP_ADDB) & 3; + MemOp size =3D cc_op_size(s->cc_op); return gen_prepare_val_nz(cpu_cc_dst, size, true); } } @@ -1028,7 +1025,7 @@ static CCPrepare gen_prepare_cc(DisasContext *s, int = b, TCGv reg) switch (s->cc_op) { case CC_OP_SUBB ... CC_OP_SUBQ: /* We optimize relational operators for the cmp/jcc case. */ - size =3D s->cc_op - CC_OP_SUBB; + size =3D cc_op_size(s->cc_op); switch (jcc_op) { case JCC_BE: tcg_gen_ext_tl(s->cc_srcT, s->cc_srcT, size); diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index 790307dbba8..45ac5edb1ae 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -1466,7 +1466,7 @@ static void gen_bt_flags(DisasContext *s, X86DecodedI= nsn *decode, TCGv src, TCGv */ decode->cc_src =3D tcg_temp_new(); decode->cc_dst =3D cpu_cc_dst; - decode->cc_op =3D ((s->cc_op - CC_OP_MULB) & 3) + CC_OP_SARB; + decode->cc_op =3D CC_OP_SARB + cc_op_size(s->cc_op); tcg_gen_shr_tl(decode->cc_src, src, s->T1); } } @@ -3346,7 +3346,8 @@ static bool gen_eflags_adcox(DisasContext *s, X86Deco= dedInsn *decode, bool want_ * bit, we might as well fish CF out of EFLAGS and save a shift. */ if (want_carry && (!need_flags || s->cc_op =3D=3D CC_OP_SHLB + MO_= TL)) { - tcg_gen_shri_tl(decode->cc_dst, cpu_cc_src, (8 << (s->cc_op - = CC_OP_SHLB)) - 1); + MemOp size =3D cc_op_size(s->cc_op); + tcg_gen_shri_tl(decode->cc_dst, cpu_cc_src, (8 << size) - 1); got_cf =3D true; } gen_mov_eflags(s, decode->cc_src); --=20 2.47.0 From nobody Sat Nov 23 17:48:20 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730128846; cv=none; d=zohomail.com; s=zohoarc; b=l0ZDdGK09NtwLqBURi7e/p0kldSFcEvqGQFSJNZCpSO4smOtSu4hvoUz7BBT1vE+UX0eX4s/42hiAHBQTy8nrE6UdCD9LV7VvachlIKbqdd44KEoXnfh3/oKB5eVRqDEcf6wAqlTZmsdXHXu348y4E3z0K7EpfLMnOR1cGcxdhM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730128846; 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=FBu80ghROOFVl+ODQDotB85rk6JKcA8U1vloiGHevjg=; b=ZvAod/XqlYhHCRJt+2Prefe22tFrfnA7iN6h1Jb08Mje/Ph4D6h8lnT+9nygOCISR6Z9HPHmI9/Rz1trZiCT89UaplRZvfl1QM0wLWO7ILTS2xssRJnZSIW1yWxZw1Q7kfcQHRmyNwFIU984y+dKg78CKHDF29hx2mlcBAr4Umg= 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 1730128846940219.76466175958205; Mon, 28 Oct 2024 08:20:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5RWd-0008A8-JA; Mon, 28 Oct 2024 11:19:23 -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 1t5RWa-00089a-NX for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5RWZ-0000nN-4Z for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:20 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-336-b9hYyFb0NNuL4FJ48dljVA-1; Mon, 28 Oct 2024 11:19:17 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4315afcae6cso24794685e9.0 for ; Mon, 28 Oct 2024 08:19:17 -0700 (PDT) Received: from [192.168.10.3] ([151.49.226.83]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43193573d47sm114822155e9.3.2024.10.28.08.19.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 08:19:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730128758; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FBu80ghROOFVl+ODQDotB85rk6JKcA8U1vloiGHevjg=; b=JYrRF9KYBe6O3/np56z7jZiVqFaqE7JC79hf95ximBnF2gUT1MAfM4D9RINERrhwZx4CsE uuy1z3vSIcMIbovNOPTlSmkTw14yHiKzE59RpA5lWMlzfg4E9UdVx2b/r949D40V16Yfmq UJVL8TmQP5fuXizqVZrTdGNCnejiSYA= X-MC-Unique: b9hYyFb0NNuL4FJ48dljVA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730128755; x=1730733555; 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=FBu80ghROOFVl+ODQDotB85rk6JKcA8U1vloiGHevjg=; b=P5W5n/otp2O3OjYXZ5HQbvWocsn8RON2tWzgL29PNgjvQWbWCkMgm/u90zKIy+3de+ daY7xmomftbbQn1q4vg5TiqUru9FpbsHBJdy2oLZi8CPooNpaZE6QfkHtWMk3kbk8nll oXYrpZ4vLoIOS1IpoXDn/6hyNcP777YAyslBmEjuZCzyvK/nEV54dc6RFdVTA2aT6Z6Q RrlXbsrZj878tfDXVhVQ/LdGGv0ZFjgLcFBiERWKX1oXceMfiecndmKRIIFe2IxtDcpj n05tDkusTd1cb+5A/W20AznHaIbT46kRWvwgoZNKbb+tZrACtzIuWtJ+FGRKoUc+9o39 GTBg== X-Gm-Message-State: AOJu0Yx8HfoZGbGCly+z/Lseq3YvbYURVjC9golOh2dCx1nSSFv35OHV WGUh9VdoZ+OE2ADM1ZJ6Q/efcmSWFY02O8oSjTZ8IZtXJflfERJnhFdQlD8uDF/fdQeLPLM40lJ Kk+shiD9QNcYgZwLtn+69+GmZBQVEI8FGmq2ZAe8HnMoIKfm/Wnb67bMD8IV1cLkVHtmvXZE1ae 6Ke0oR2dIasIbKTeE1cuIew1ytJpAAW4mPuMki5Lo= X-Received: by 2002:a05:600c:3b23:b0:431:4fbd:f571 with SMTP id 5b1f17b1804b1-431b2ae97dcmr1632945e9.13.1730128755202; Mon, 28 Oct 2024 08:19:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGrBPBG+IgbO8ONr2ZhgVQBlUo0TnP6WvXxcLd7W2oBihLwAlr9bQkFfqwCX53GtPdsAgg5eg== X-Received: by 2002:a05:600c:3b23:b0:431:4fbd:f571 with SMTP id 5b1f17b1804b1-431b2ae97dcmr1632695e9.13.1730128754779; Mon, 28 Oct 2024 08:19:14 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PATCH 06/14] target/i386: Wrap cc_op_live with a validity check Date: Mon, 28 Oct 2024 16:18:43 +0100 Message-ID: <20241028151851.376355-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241028151851.376355-1-pbonzini@redhat.com> References: <20241028151851.376355-1-pbonzini@redhat.com> 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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730128848991116600 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Assert that op is known and that cc_op_live_ is populated. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 1 - target/i386/tcg/translate.c | 21 ++++++++++++++++++--- target/i386/tcg/decode-new.c.inc | 2 +- target/i386/tcg/emit.c.inc | 4 ++-- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index e598fe3de9a..afe6643db83 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1373,7 +1373,6 @@ typedef enum { #define CC_OP_LAST_BWLQ CC_OP_POPCNTQ__ =20 CC_OP_DYNAMIC, /* must use dynamic code to get cc_op */ - CC_OP_NB, } CCOp; =20 /* See X86DecodedInsn.cc_op, using int8_t. */ diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 46062002c02..1a9a2fe709e 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -291,7 +291,7 @@ enum { }; =20 /* Bit set if the global variable is live after setting CC_OP to X. */ -static const uint8_t cc_op_live[CC_OP_NB] =3D { +static const uint8_t cc_op_live_[] =3D { [CC_OP_DYNAMIC] =3D USES_CC_DST | USES_CC_SRC | USES_CC_SRC2, [CC_OP_EFLAGS] =3D USES_CC_SRC, [CC_OP_MULB ... CC_OP_MULQ] =3D USES_CC_DST | USES_CC_SRC, @@ -312,6 +312,21 @@ static const uint8_t cc_op_live[CC_OP_NB] =3D { [CC_OP_POPCNT] =3D USES_CC_DST, }; =20 +static uint8_t cc_op_live(CCOp op) +{ + uint8_t result; + assert(op >=3D 0 && op < ARRAY_SIZE(cc_op_live_)); + + /* + * Check that the array is fully populated. A zero entry would corres= pond + * to a fixed value of EFLAGS, which can be obtained with CC_OP_EFLAGS + * as well. + */ + result =3D cc_op_live_[op]; + assert(result); + return result; +} + static void set_cc_op_1(DisasContext *s, CCOp op, bool dirty) { int dead; @@ -321,7 +336,7 @@ static void set_cc_op_1(DisasContext *s, CCOp op, bool = dirty) } =20 /* Discard CC computation that will no longer be used. */ - dead =3D cc_op_live[s->cc_op] & ~cc_op_live[op]; + dead =3D cc_op_live(s->cc_op) & ~cc_op_live(op); if (dead & USES_CC_DST) { tcg_gen_discard_tl(cpu_cc_dst); } @@ -808,7 +823,7 @@ static void gen_mov_eflags(DisasContext *s, TCGv reg) src2 =3D cpu_cc_src2; =20 /* Take care to not read values that are not live. */ - live =3D cc_op_live[s->cc_op] & ~USES_CC_SRCT; + live =3D cc_op_live(s->cc_op) & ~USES_CC_SRCT; dead =3D live ^ (USES_CC_DST | USES_CC_SRC | USES_CC_SRC2); if (dead) { TCGv zero =3D tcg_constant_tl(0); diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index 48bf730cd3e..cda32ee6784 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -2865,7 +2865,7 @@ static void disas_insn(DisasContext *s, CPUState *cpu) tcg_gen_mov_i32(cpu_cc_op, decode.cc_op_dynamic); } set_cc_op(s, decode.cc_op); - cc_live =3D cc_op_live[decode.cc_op]; + cc_live =3D cc_op_live(decode.cc_op); } else { cc_live =3D 0; } diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index 45ac5edb1ae..785ff63f2ac 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -3777,13 +3777,13 @@ static void gen_shift_dynamic_flags(DisasContext *s= , X86DecodedInsn *decode, TCG decode->cc_op_dynamic =3D tcg_temp_new_i32(); =20 assert(decode->cc_dst =3D=3D s->T0); - if (cc_op_live[s->cc_op] & USES_CC_DST) { + if (cc_op_live(s->cc_op) & USES_CC_DST) { decode->cc_dst =3D tcg_temp_new(); tcg_gen_movcond_tl(TCG_COND_EQ, decode->cc_dst, count, tcg_constan= t_tl(0), cpu_cc_dst, s->T0); } =20 - if (cc_op_live[s->cc_op] & USES_CC_SRC) { + if (cc_op_live(s->cc_op) & USES_CC_SRC) { tcg_gen_movcond_tl(TCG_COND_EQ, decode->cc_src, count, tcg_constan= t_tl(0), cpu_cc_src, decode->cc_src); } --=20 2.47.0 From nobody Sat Nov 23 17:48:20 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730128782; cv=none; d=zohomail.com; s=zohoarc; b=IURvxzVDMfJE6nQTrRfxl7e9Y7+39WPD08UxU9r+a2O7SPcrMnQO56ImAKF1M9Fs7DDeMVUFmay5f0EfOoeEC8J6U2+C74WhnyE1GiFB9HQ63qo18JkYJvzNsupo11SiHzKRjKBVP5HtI5ijWnwJDrqHqxtaw6eXgaqksHuHeEk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730128782; 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=2wg9v6d6YDJZE1VNEyI3a6xEnT1ZEEyCNwPgTQH2WY0=; b=Nttoov0YW4FI81vLsuKaR2/nb9EQUwLWlgrlzjEbeFoE/qi+gvBXb9qLJEsV5aP0eQLF0XUuwKT3iZNGgG3yWxmUaEkX+rn5bL+6rHYChy1+Yt53aC7RPls6k0cgL1nYi9S/zNAGsgxYzbCiwKwfYj+K68zxXdayJATJq8zP2bQ= 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 1730128782429150.5843607749522; Mon, 28 Oct 2024 08:19:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5RWi-0008As-R1; Mon, 28 Oct 2024 11:19:29 -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 1t5RWd-0008AC-HL for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5RWc-0000o7-5M for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:23 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-356-bUwLsPCvNtWqtSK84xsgWw-1; Mon, 28 Oct 2024 11:19:19 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-37d5ca192b8so2446485f8f.1 for ; Mon, 28 Oct 2024 08:19:19 -0700 (PDT) Received: from [192.168.10.3] ([151.49.226.83]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b5706c3sm142666855e9.34.2024.10.28.08.19.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 08:19:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730128761; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2wg9v6d6YDJZE1VNEyI3a6xEnT1ZEEyCNwPgTQH2WY0=; b=iM24Qmrtlqs1klXLREAvltyBJK2aUgpmlYil0x2Dg83xqcS91Q+MP2djWWZv30UwpCv15I 8ZoQE3YetZah0tLa7z2gMBVNxEWwYV8PAzVyTohTdjOKCykUUMm7NJP01OEEZ+39thUZBw yxkLRTfS2Woaw/+ARS30uapQcNC9nhc= X-MC-Unique: bUwLsPCvNtWqtSK84xsgWw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730128757; x=1730733557; 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=2wg9v6d6YDJZE1VNEyI3a6xEnT1ZEEyCNwPgTQH2WY0=; b=SUsgK8mhXruOMFDneW2xhXIKngV9hhwOt1gtIRhAICMwdiybsxvNFVvTuWI5Vk1AuI S03sYjcJxV3FXRSCJvYK90UvzlmFhcWeW5xmOAh5BdmX+u1xu3XDeg+zifQGaOlxInYR FTXFpTbeIWGjCdCJZv/mVfQO3c1fduwFOgRjKrPII3t9pJJmca8UYzjQF2blXWEBexeN nfSr9lEISPJEZq4mac6IImLhgu4zcFz9+eDntG4viKkNRRJvxjLL0+ePtOw3MK5KNvKB lPNh983Kg+s3RT9ezJYA59I8BQzlLVjL9/4otCMH9Nq2GHH1zmZpzE7LnQjNP7VSSKAQ MwqQ== X-Gm-Message-State: AOJu0YwCTVUZtq919GOebc5HqKcEj69mly/mxHUSeyzPVjbayLoalKqF 7wz9qEQ4XgO4k7AIcihGjyqeXOyVlb95Qt8Yls5Cb3hrhoneLtgijfv4bpFrPeSnqANplFyWV2o GfoU5VFuEHwzF85iLCRt12oFpTY+wJjGW0MvkiHiPwmwxY7Nd1d9/vN2uHOhnUf7HpAcDcf92LT 5PefoD3NLjy3LP8iqjfBeRqubgDP3A2svrg2uUHl0= X-Received: by 2002:adf:f805:0:b0:37d:43a8:dee0 with SMTP id ffacd0b85a97d-38080e51f07mr185659f8f.17.1730128757515; Mon, 28 Oct 2024 08:19:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEnIu6ss1lUBH3y7nRXz2CVcJNDzwC3ZJGlbKtsHcLcmuQW3cBh9PDqiIrZ69x89oVElkqH0w== X-Received: by 2002:adf:f805:0:b0:37d:43a8:dee0 with SMTP id ffacd0b85a97d-38080e51f07mr185631f8f.17.1730128757072; Mon, 28 Oct 2024 08:19:17 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PATCH 07/14] target/i386: optimize computation of ZF from CC_OP_DYNAMIC Date: Mon, 28 Oct 2024 16:18:44 +0100 Message-ID: <20241028151851.376355-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241028151851.376355-1-pbonzini@redhat.com> References: <20241028151851.376355-1-pbonzini@redhat.com> 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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730128784637116600 Content-Type: text/plain; charset="utf-8" Most uses of CC_OP_DYNAMIC are for CMP/JB/JE or similar sequences. We can optimize many of them to avoid computation of the flags. This eliminates both TCG ops to set up the new cc_op, and helper instructions because evaluating just ZF is much cheaper. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/helper.h | 1 + target/i386/tcg/cc_helper.c | 13 +++++++++++++ target/i386/tcg/translate.c | 10 +++++++--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/target/i386/helper.h b/target/i386/helper.h index eeb8df56eaa..3f67098f11f 100644 --- a/target/i386/helper.h +++ b/target/i386/helper.h @@ -1,5 +1,6 @@ DEF_HELPER_FLAGS_4(cc_compute_all, TCG_CALL_NO_RWG_SE, tl, tl, tl, tl, int) DEF_HELPER_FLAGS_4(cc_compute_c, TCG_CALL_NO_RWG_SE, tl, tl, tl, tl, int) +DEF_HELPER_FLAGS_3(cc_compute_nz, TCG_CALL_NO_RWG_SE, tl, tl, tl, int) =20 DEF_HELPER_3(write_eflags, void, env, tl, i32) DEF_HELPER_1(read_eflags, tl, env) diff --git a/target/i386/tcg/cc_helper.c b/target/i386/tcg/cc_helper.c index 40583c04cf9..1b83775a914 100644 --- a/target/i386/tcg/cc_helper.c +++ b/target/i386/tcg/cc_helper.c @@ -95,6 +95,19 @@ static target_ulong compute_all_adcox(target_ulong dst, = target_ulong src1, return (src1 & ~(CC_C | CC_O)) | (dst * CC_C) | (src2 * CC_O); } =20 +target_ulong helper_cc_compute_nz(target_ulong dst, target_ulong src1, + int op) +{ + if (CC_OP_HAS_EFLAGS(op)) { + return ~src1 & CC_Z; + } else { + MemOp size =3D cc_op_size(op); + target_ulong mask =3D MAKE_64BIT_MASK(0, 8 << size); + + return dst & mask; + } +} + target_ulong helper_cc_compute_all(target_ulong dst, target_ulong src1, target_ulong src2, int op) { diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 1a9a2fe709e..5e326ab1aff 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -1008,15 +1008,19 @@ static CCPrepare gen_prepare_eflags_o(DisasContext = *s, TCGv reg) static CCPrepare gen_prepare_eflags_z(DisasContext *s, TCGv reg) { switch (s->cc_op) { - case CC_OP_DYNAMIC: - gen_compute_eflags(s); - /* FALLTHRU */ case CC_OP_EFLAGS: case CC_OP_ADCX: case CC_OP_ADOX: case CC_OP_ADCOX: return (CCPrepare) { .cond =3D TCG_COND_TSTNE, .reg =3D cpu_cc_src, .imm =3D CC_Z }; + case CC_OP_DYNAMIC: + gen_update_cc_op(s); + if (!reg) { + reg =3D tcg_temp_new(); + } + gen_helper_cc_compute_nz(reg, cpu_cc_dst, cpu_cc_src, cpu_cc_op); + return (CCPrepare) { .cond =3D TCG_COND_EQ, .reg =3D reg, .imm =3D= 0 }; default: { MemOp size =3D cc_op_size(s->cc_op); --=20 2.47.0 From nobody Sat Nov 23 17:48:20 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730128881; cv=none; d=zohomail.com; s=zohoarc; b=FAH+TeRWu7M97rkxCleCTUwE8TLvXXWkuMHUcQZSqGIQ3AjORE5Bk1/mM3+7Mkkk4aEzWKSlozvU8ZLybCuqUAYocLMxCB/7GTOjltx3LW+jjhH1fGbsN7+Y9hydWNaxsEuvT0WqdVozAM5X+li6C6Yb3AkEG0Bon4PsVhwsoT0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730128881; 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=gI8QJXLbvQlRAcKrirWFR61Xh1xeLANavYLMQJ90kOI=; b=EWikt24ip2b/mD0SMCC8g9kyhJhJn0G9tVOph74isC1w3t8HFYWLEIHGxqnDKrLuNAniVt9CLrXPaIabNSX37f36wd9z0zcYqStoBkljSy/nmIUGyb6wyyOY9DblJpx0I7CfBCX/cZJRtN8HNFcw3kOls5932GgaFXu1RxoexPU= 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 1730128881882808.3976399315198; Mon, 28 Oct 2024 08:21:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5RWx-0008Ln-P8; Mon, 28 Oct 2024 11:19: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 1t5RWh-0008B3-56 for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5RWe-0000oc-Ks for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:25 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-8-UaobQeZdM12ZgBq103wWJQ-1; Mon, 28 Oct 2024 11:19:22 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-37d45de8bbfso3199755f8f.3 for ; Mon, 28 Oct 2024 08:19:22 -0700 (PDT) Received: from [192.168.10.3] ([151.49.226.83]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38058b70bcdsm9856223f8f.82.2024.10.28.08.19.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 08:19:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730128764; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gI8QJXLbvQlRAcKrirWFR61Xh1xeLANavYLMQJ90kOI=; b=WqjgPASO/B654zD8vC6EO7XWCOCopGz05XGXRfLLzyhT4++y64th/mFUfLdbbK0jHAdDtl VCqkVEmYMdIlVn1+sm4tv4y8dhXLxPHMiLK+5NVtKfYfxufKS20BjccEmkhrZcAjdrE49S 3nqgikI7zFk0fsAw22EZG/ETD3gzLAQ= X-MC-Unique: UaobQeZdM12ZgBq103wWJQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730128760; x=1730733560; 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=gI8QJXLbvQlRAcKrirWFR61Xh1xeLANavYLMQJ90kOI=; b=xCkX7Z/82cj+GvyzpkUJsqcOyprEryFgvavqKSAwdyou7LFfYxse3wP8zsbU9gA8jp FbIp9XtB6L2EWyU4CcCOu8AJwcGMAm3avEZWqWxnusfFIyoY3zXjvH5tICY3nhME/wMw PlVOjJn7KUICUvZQxCy3cdo3By22Srhx2lKt9NT/tLD91aksSsEzzyTTWMkFhy1vb/2Z 0x3JZsfCgFxRFoFrFdOOE2fJztV6byySARTThQGChFHcsLUQ+9sxx0BZw+NMWpnwVMfM JwiRE2ZORxcXNmQ6aA5qwD2W/Oe2mVndvpWBdjSWzZ/8r32tPx1CvKM2C5e/UDxtVUYV //UA== X-Gm-Message-State: AOJu0Yw/rG1J23DLxYUEi0v19Oxr9oAKOyfdaGV9WG/W25OwIx2Lv9GS w19nE5/0tjFj05dBSsuSj8KPDcLSgCR04HdqCmn/2hrUEs9SxNfyOas+OkS69uM+bRtcMi+8ZZL 46kuRTN2MwXqjLtJObQVWGTzZg1Ev3Lf4pCuRfR8TAGpOM1d6CHpus+/1Z076FTThFWfpavmgR8 /ajHz7GpAJmBhTEZBc9u+fSje1p+//+DDPLGJx4m8= X-Received: by 2002:a05:6000:b11:b0:37d:4376:6e1d with SMTP id ffacd0b85a97d-38061227b35mr8278040f8f.41.1730128760331; Mon, 28 Oct 2024 08:19:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtaqk5zLmvKhP/bE7I0RxmTQt4atuAaSDSfnv95kWFUtqcyTMwA3dOOXLp9GQU/E21g9B//Q== X-Received: by 2002:a05:6000:b11:b0:37d:4376:6e1d with SMTP id ffacd0b85a97d-38061227b35mr8278019f8f.41.1730128759930; Mon, 28 Oct 2024 08:19:19 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PATCH 08/14] target/i386: optimize TEST+Jxx sequences Date: Mon, 28 Oct 2024 16:18:45 +0100 Message-ID: <20241028151851.376355-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241028151851.376355-1-pbonzini@redhat.com> References: <20241028151851.376355-1-pbonzini@redhat.com> 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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730128883391116600 Content-Type: text/plain; charset="utf-8" Mostly used for TEST+JG and TEST+JLE, but it is easy to cover also JBE/JA and JL/JGE; shaves about 0.5% TCG ops. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 5e326ab1aff..d3bbcf7317c 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -1069,6 +1069,28 @@ static CCPrepare gen_prepare_cc(DisasContext *s, int= b, TCGv reg) } break; =20 + case CC_OP_LOGICB ... CC_OP_LOGICQ: + /* Mostly used for test+jump */ + size =3D s->cc_op - CC_OP_LOGICB; + switch (jcc_op) { + case JCC_BE: + /* CF =3D 0, becomes jz/je */ + jcc_op =3D JCC_Z; + goto slow_jcc; + case JCC_L: + /* OF =3D 0, becomes js/jns */ + jcc_op =3D JCC_S; + goto slow_jcc; + case JCC_LE: + /* SF or ZF, becomes signed <=3D 0 */ + tcg_gen_ext_tl(cpu_cc_dst, cpu_cc_dst, size | MO_SIGN); + cc =3D (CCPrepare) { .cond =3D TCG_COND_LE, .reg =3D cpu_cc_ds= t }; + break; + default: + goto slow_jcc; + } + break; + default: slow_jcc: /* This actually generates good code for JC, JZ and JS. */ --=20 2.47.0 From nobody Sat Nov 23 17:48:20 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730128901; cv=none; d=zohomail.com; s=zohoarc; b=fgt95ljYtejJaW29f0pjfsVvnhwIQP538Ws6jbvT8YW3ePVihRjJSezB2Wu6v0dk58YhlQXLEutu9dfb5C9m3SY11Dh8PIKKzab/V3EzgmFsQB6n8MsK4NK3wqpfANTF/JSvFRrhWsbGgX/iMaqlMZbN+UkEtcSGTjn9l4vQWVc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730128901; 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=is5CdaaNMr3Jm3fsNDTy10/40GRNhVSMMooCmQjIYFY=; b=ak22HiR9V0vv8H+VmIGbSjZneAG6BGylUC+ocSENWyjj3HOP0jvWsu6LkAwX+xBHx0ClYlfxKF0jI4P1oUuEM5ErhhUYk8gXIHx49gwOsOVe/cg08ID5DIy01Sv2orZcoJHAvoKN2cm2eS7TaX03OsTJq9Xn21cgFdrjyQEjnU0= 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 1730128901194145.05050154199705; Mon, 28 Oct 2024 08:21:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5RWy-0008RK-BN; Mon, 28 Oct 2024 11:19: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 1t5RWk-0008BL-9Y for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5RWi-0000p6-V4 for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:30 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-481-4ryQ3RkxNbS7wqxBl9xrqw-1; Mon, 28 Oct 2024 11:19:26 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-37d52ca258eso2406051f8f.3 for ; Mon, 28 Oct 2024 08:19:26 -0700 (PDT) Received: from [192.168.10.3] ([151.49.226.83]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38058b712bfsm9749464f8f.79.2024.10.28.08.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 08:19:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730128767; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=is5CdaaNMr3Jm3fsNDTy10/40GRNhVSMMooCmQjIYFY=; b=b4jZDM+Co0p4W8ja9G6GPkVWTqhEfUbuagCtJBhIQr4mIpmyUJTu7EgKGw3q0vIecKz41h oXrmP9a0mxjytJnAGlrBvK+OJ1ijE3/XyiCfDATTCA2DE7XkXYNURF8IcwW8ZFQ3bsSLyV fj3ZQPdphgZs7ft1Y8JWk+BWo043rY4= X-MC-Unique: 4ryQ3RkxNbS7wqxBl9xrqw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730128764; x=1730733564; 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=is5CdaaNMr3Jm3fsNDTy10/40GRNhVSMMooCmQjIYFY=; b=gDbQ13SFY+xxGDWxS5f6+iBj8rNF3KOGzhTTzfqP5x3lBL5yaiOIjyfECYdWlLdh09 EfZ5nhvo+AGlwKi+RZtRsh3EB5ldCl7YjV3eyAUVLq+OLBFMx9n+e8Hu/U8CodBYuefD XOg7zMse8UXL3yMGIArWHSC6VrjvpIq3iEtgtbd8K/W32oMem65VpOPoJSRGskGkBRs1 TVxjifP+CCVFlyAvIFxEP2uJbA8lhHiWe6TxYqi4sUSHif6O+vP/uZ1tsDCEJ5kLNiEK HW2n797cDUV+76cVBTbRxWiwRLyEcTeDCd3Z0OwHgg/mJmEa9UC5r620sSVN7C3xHoLh vrsw== X-Gm-Message-State: AOJu0YwUnccFYQBgvwzr1eKEFquy8wMJZPodIhG0EKq4VjvQF5cK8lqf 4KJO1za4otQJgzvGYr1gDnQsJY9/WGRtaFdgYQxRl2vG5nq3VNtetQeqw+3OXqRviapXM3IkvSa D+zSAL3xe29wRn/tC8eu1Qz9ou/sKBUgX4ChHiVVb0p5obIvzf1gCqeR3yIoePtwLGqUT+nETU+ BRxi1UmVFzNIuCfwVEhAl6pQOwCbR3mYPVle4ghB8= X-Received: by 2002:a5d:58f1:0:b0:37d:3735:8fe7 with SMTP id ffacd0b85a97d-380611455b2mr5810636f8f.32.1730128764395; Mon, 28 Oct 2024 08:19:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHzZpyYI5Gl8v9BD143GwksOOoRaoML/fIhXwrVE6AJv6Z/dvI/tr8+MHKoH3DBPdKF5oo15Q== X-Received: by 2002:a5d:58f1:0:b0:37d:3735:8fe7 with SMTP id ffacd0b85a97d-380611455b2mr5810618f8f.32.1730128763933; Mon, 28 Oct 2024 08:19:23 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PATCH 09/14] target/i386: add a few more trivial CCPrepare cases Date: Mon, 28 Oct 2024 16:18:46 +0100 Message-ID: <20241028151851.376355-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241028151851.376355-1-pbonzini@redhat.com> References: <20241028151851.376355-1-pbonzini@redhat.com> 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=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730128903191116600 Content-Type: text/plain; charset="utf-8" Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index d3bbcf7317c..6e89d4faef1 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -993,6 +993,7 @@ static CCPrepare gen_prepare_eflags_o(DisasContext *s, = TCGv reg) case CC_OP_ADCOX: return (CCPrepare) { .cond =3D TCG_COND_NE, .reg =3D cpu_cc_src2, .no_setcond =3D true }; + case CC_OP_LOGICB ... CC_OP_LOGICQ: case CC_OP_POPCNT: return (CCPrepare) { .cond =3D TCG_COND_NEVER }; case CC_OP_MULB ... CC_OP_MULQ: @@ -1021,6 +1022,8 @@ static CCPrepare gen_prepare_eflags_z(DisasContext *s= , TCGv reg) } gen_helper_cc_compute_nz(reg, cpu_cc_dst, cpu_cc_src, cpu_cc_op); return (CCPrepare) { .cond =3D TCG_COND_EQ, .reg =3D reg, .imm =3D= 0 }; + case CC_OP_POPCNT: + return (CCPrepare) { .cond =3D TCG_COND_EQ, .reg =3D cpu_cc_dst }; default: { MemOp size =3D cc_op_size(s->cc_op); --=20 2.47.0 From nobody Sat Nov 23 17:48:20 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730128800; cv=none; d=zohomail.com; s=zohoarc; b=NNY3zK2Y512pglRxJuj3/ixxm+zEJkkPayEWMpySqa8m6ZczxZ8PPGHFIVnpDaOcIwg8kh6W/Pd2/E8A8aCkIhKsgOdxZ/2fvTsGmrLm2I7hoOZ544ZUDwRGNqi/cCqq/oRD41SDZ9MuRVoHltZO+Rj09Xq2lTohdE6kT0N+ljI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730128800; 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=8tMRIuMzrz5AYgWyltwp7b/wxA+vnT9YlYCqkEpP2Rc=; b=a1zUn6E2xaEu1K5opXS4wyPcVSrs2Pc4DewIgbveJGZg+cMc5VrLqnT69FV/9VvzzBnI/wDe1jyL0sSONkpRzjBl70SpFcvurQpxhRxiVpx5Y6BgrscFTWEWFKHlptmIzv/uwCwIEMflcZ7ukUMrwUi15bhYDDyW4tjciuhKBsI= 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 1730128800849688.223348549382; Mon, 28 Oct 2024 08:20:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5RX0-00005z-9q; Mon, 28 Oct 2024 11:19:46 -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 1t5RWp-0008Bk-1Q for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5RWm-0000ph-H1 for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:33 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-74-MW4MJRO3OD6lv778VLaphw-1; Mon, 28 Oct 2024 11:19:29 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4315f48bd70so29533075e9.2 for ; Mon, 28 Oct 2024 08:19:28 -0700 (PDT) Received: from [192.168.10.3] ([151.49.226.83]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38058b3c7f6sm9780221f8f.41.2024.10.28.08.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 08:19:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730128770; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8tMRIuMzrz5AYgWyltwp7b/wxA+vnT9YlYCqkEpP2Rc=; b=RYdtevgafYWTwBnjz65zBAXqpUGPouONFNAg1buvaKlCsRFRZZ0p9DGv+bW2/l6lv19YVm SaVlGJZKPdwcRSTsdYZZ47hOXA5SYCxgra2fj4SmIc9ApSgX0kGFYivgNgS6GvrdJvmH8r ZabMnDuEZdqXtPaCzZIhToOjOxcTVJg= X-MC-Unique: MW4MJRO3OD6lv778VLaphw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730128767; x=1730733567; 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=8tMRIuMzrz5AYgWyltwp7b/wxA+vnT9YlYCqkEpP2Rc=; b=XycqhJq++BZY1CmPk/H8tyUwMAWJpsK8O10FZdnBABaYYoX35xd/WelZjbMgnoFnk7 /rNSakHdgFBMaRYrNlB1jVhomhye52x79OJlPHmeBT2A5M2V4b4qN3S6lDdhMC0OCw8j dGqUaCDQnlIOsxXxGPgHYCWpObltG5J/usOKse9RCKbssE7s4OqcpKxfCEt2gRMnYJ9g ZxLYt3/MFZJbhM8obHHtfQODs5f+yi1BUZfgCeev/arJ3nQAGQ8T1AgTyWrQ83vo1gT8 AOzu3tgERaaQF11SpY1+3sqhstSSUipov9etXVkbsFrO2ayvFuWIU8+mCX7kTBTL8UIW w28Q== X-Gm-Message-State: AOJu0Yw+Twy+CuPiTUojOzSI79iZ2tNXriC7MkoJKtDDkvEySmiOO6jD R5KmWR6s08j/zQ00/tElHTlUaJmVWx3BABFsWBYiqi0Xp4iVVlo7kpN7vBufXU2EtJwAGELVR5w lNmZNP3UhK+XIuMTZpNOSCXgsH1bSdBKFuH/0V2SI/gTliHt/EwBOcUTyHN0rvw6MDV7uk2JLVJ JbaU6SWMP/YBciANVyhnS5unoIpTyqDrwt4Y/xSDs= X-Received: by 2002:a05:600c:3c9a:b0:431:5194:1687 with SMTP id 5b1f17b1804b1-4319acb12bamr56916905e9.18.1730128767346; Mon, 28 Oct 2024 08:19:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFkSoaq1Unsjd7Ai1DZix5lDZCQMJorN7SvYDXdKXKCeZ02mKGl/t41Wd+ML+8DjzwtCkt7uQ== X-Received: by 2002:a05:600c:3c9a:b0:431:5194:1687 with SMTP id 5b1f17b1804b1-4319acb12bamr56916715e9.18.1730128766881; Mon, 28 Oct 2024 08:19:26 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PATCH 10/14] target/i386: add a note about gen_jcc1 Date: Mon, 28 Oct 2024 16:18:47 +0100 Message-ID: <20241028151851.376355-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241028151851.376355-1-pbonzini@redhat.com> References: <20241028151851.376355-1-pbonzini@redhat.com> 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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730128802596116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/tcg/translate.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 6e89d4faef1..5d729e68c98 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -1193,6 +1193,10 @@ static inline void gen_jcc1(DisasContext *s, int b, = TCGLabel *l1) { CCPrepare cc =3D gen_prepare_cc(s, b, NULL); =20 + /* + * Note that this must be _after_ gen_prepare_cc, because it + * can change the cc_op from CC_OP_DYNAMIC to CC_OP_EFLAGS! + */ gen_update_cc_op(s); if (cc.use_reg2) { tcg_gen_brcond_tl(cc.cond, cc.reg, cc.reg2, l1); --=20 2.47.0 From nobody Sat Nov 23 17:48:20 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730128953; cv=none; d=zohomail.com; s=zohoarc; b=gr7jfGwQSbNuZisw8OEejiJ8KHE/q21dPeBhBbMVngqHSG6WyqqD1SkM+PZbOA50wAMJugIcz4sz6Y1WgPUdM9Em8iiOpMc1W2GMuCNMfdQp2u7C5EPuZdWZXAv4d7sEP4PUAqvu9lvmLMF1LgPgDDgf+CuKvMnTwpunKzeNMHA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730128953; 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=JiVqWkstUV/F0IFzwEgI64OSPFJg4cv0MklXzVnGPTs=; b=I7+oMXPnN9wrPjyg8axLCd3pxgK5OvgNkQqZQm/hTxorV9pRgZssFF3aYDOppaxxO1yn69KJsslSX/e5HGFS8uG8J0usXy8vWl6a7clonSKCXpDO9xrqIUPJrZthY5QSzAiW1HQ7o34baqyZg4f28c/eNVj/JDF9DP8DjrOMyxI= 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 173012895313893.58902111641123; Mon, 28 Oct 2024 08:22:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5RX1-0000FX-JK; Mon, 28 Oct 2024 11:19:47 -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 1t5RWq-0008Bm-J5 for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5RWo-0000ps-J6 for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:36 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-7-RXuGY9RZOoy40Fftb_uPAg-1; Mon, 28 Oct 2024 11:19:30 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4315b7b0c16so34417695e9.1 for ; Mon, 28 Oct 2024 08:19:30 -0700 (PDT) Received: from [192.168.10.3] ([151.49.226.83]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43193595c6asm111686435e9.18.2024.10.28.08.19.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 08:19:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730128772; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JiVqWkstUV/F0IFzwEgI64OSPFJg4cv0MklXzVnGPTs=; b=KoFqhsLnFD+yGpuCOLdYgtz3AAIWzq/mveCV7fUJqi4lm8PgBK29mlRqzuvi1JB6cnyO2i py5dY4l3rBxHt0T6H6Y2P/2pJWNvZQsvx/253Xy56VQpQGHPevFn3JuwYWdfYKSLGpKCvf bRO+fiGodNbNr3+O/RgZH25dE00KfJk= X-MC-Unique: RXuGY9RZOoy40Fftb_uPAg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730128769; x=1730733569; 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=JiVqWkstUV/F0IFzwEgI64OSPFJg4cv0MklXzVnGPTs=; b=drRvmaR/bM/gzw6m+VN27WBkxaBz62LWYIGb5G1j6lLJUfo235PLdCwJf12VCyCTtd EHQXAmNPQMXwv5pjx2SbeprGRdu0YcBkHAftnfbR+VxLVLAL1/SkCb99tdBhkKBNG5ym FqXzsUui2ABVQ3qiyBsSZ7Vxqz3jj0q8440H7Q3lQr8Qss31G1s7l2tBwoXjShxu4p2H 8DNoZI+ANo1R/OdIBpcaRFtUT6UuJx3n+kTCF6bA5PQvhYoxHG/5cxn5rOGpXbV09CGb 036pT/69AkoW6ZnxT+bJfmYk/IaBGnvvBmjCxVA34DKsc+/yMWnR07eXuEeJPg1b4Wkh Bjug== X-Gm-Message-State: AOJu0YyVHF4DywyU6InL/QyL+3tYPxuHj8QD9GivkCsTXNUo3bpvhzH0 1M2GuVk4dcibwfpPbIJ3hgMFCL57LhVWk9y1EBK79kXOSjkhETtv1ROgQnCXgfZKfHyjcHcIR9Z 3YwYqlUtHWLcHmTvs1iZBMmZQY2zq5TVqlk2gl3gPy3QuCRNPCb77FfyXw6J25ABRB02sakTL3Z NNKTKJgX36NVMrblHKJmIStwGAxUaaqIvq5Hbl0u0= X-Received: by 2002:a05:600c:4e8b:b0:431:40ca:ce44 with SMTP id 5b1f17b1804b1-4319ad34a44mr66617535e9.30.1730128769113; Mon, 28 Oct 2024 08:19:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEpJjcDf1KXunpZ3F2x4M5OBAq2xIA+tSvyToXLYr4qveja7+ljn9fhKXDTufyIPoT/snkVOg== X-Received: by 2002:a05:600c:4e8b:b0:431:40ca:ce44 with SMTP id 5b1f17b1804b1-4319ad34a44mr66617245e9.30.1730128768522; Mon, 28 Oct 2024 08:19:28 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PATCH 11/14] target/i386: make flag variables unsigned Date: Mon, 28 Oct 2024 16:18:48 +0100 Message-ID: <20241028151851.376355-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241028151851.376355-1-pbonzini@redhat.com> References: <20241028151851.376355-1-pbonzini@redhat.com> 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=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730128953491116600 Content-Type: text/plain; charset="utf-8" This makes it easier for the compiler to understand which bits are set, and it also removes "cltq" instructions to canonicalize the output value as 32-bit signed. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg/cc_helper_template.h.inc | 46 ++++++++++++------------ 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/target/i386/tcg/cc_helper_template.h.inc b/target/i386/tcg/cc_= helper_template.h.inc index c5425e57cfb..4cbbc73c3cd 100644 --- a/target/i386/tcg/cc_helper_template.h.inc +++ b/target/i386/tcg/cc_helper_template.h.inc @@ -39,9 +39,9 @@ =20 /* dynamic flags computation */ =20 -static int glue(compute_all_add, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) +static uint32_t glue(compute_all_add, SUFFIX)(DATA_TYPE dst, DATA_TYPE src= 1) { - int cf, pf, af, zf, sf, of; + uint32_t cf, pf, af, zf, sf, of; DATA_TYPE src2 =3D dst - src1; =20 cf =3D dst < src1; @@ -58,10 +58,10 @@ static int glue(compute_c_add, SUFFIX)(DATA_TYPE dst, D= ATA_TYPE src1) return dst < src1; } =20 -static int glue(compute_all_adc, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1, +static uint32_t glue(compute_all_adc, SUFFIX)(DATA_TYPE dst, DATA_TYPE src= 1, DATA_TYPE src3) { - int cf, pf, af, zf, sf, of; + uint32_t cf, pf, af, zf, sf, of; DATA_TYPE src2 =3D dst - src1 - src3; =20 cf =3D (src3 ? dst <=3D src1 : dst < src1); @@ -79,9 +79,9 @@ static int glue(compute_c_adc, SUFFIX)(DATA_TYPE dst, DAT= A_TYPE src1, return src3 ? dst <=3D src1 : dst < src1; } =20 -static int glue(compute_all_sub, SUFFIX)(DATA_TYPE dst, DATA_TYPE src2) +static uint32_t glue(compute_all_sub, SUFFIX)(DATA_TYPE dst, DATA_TYPE src= 2) { - int cf, pf, af, zf, sf, of; + uint32_t cf, pf, af, zf, sf, of; DATA_TYPE src1 =3D dst + src2; =20 cf =3D src1 < src2; @@ -100,10 +100,10 @@ static int glue(compute_c_sub, SUFFIX)(DATA_TYPE dst,= DATA_TYPE src2) return src1 < src2; } =20 -static int glue(compute_all_sbb, SUFFIX)(DATA_TYPE dst, DATA_TYPE src2, +static uint32_t glue(compute_all_sbb, SUFFIX)(DATA_TYPE dst, DATA_TYPE src= 2, DATA_TYPE src3) { - int cf, pf, af, zf, sf, of; + uint32_t cf, pf, af, zf, sf, of; DATA_TYPE src1 =3D dst + src2 + src3; =20 cf =3D (src3 ? src1 <=3D src2 : src1 < src2); @@ -123,9 +123,9 @@ static int glue(compute_c_sbb, SUFFIX)(DATA_TYPE dst, D= ATA_TYPE src2, return (src3 ? src1 <=3D src2 : src1 < src2); } =20 -static int glue(compute_all_logic, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) +static uint32_t glue(compute_all_logic, SUFFIX)(DATA_TYPE dst, DATA_TYPE s= rc1) { - int cf, pf, af, zf, sf, of; + uint32_t cf, pf, af, zf, sf, of; =20 cf =3D 0; pf =3D parity_table[(uint8_t)dst]; @@ -136,9 +136,9 @@ static int glue(compute_all_logic, SUFFIX)(DATA_TYPE ds= t, DATA_TYPE src1) return cf | pf | af | zf | sf | of; } =20 -static int glue(compute_all_inc, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) +static uint32_t glue(compute_all_inc, SUFFIX)(DATA_TYPE dst, DATA_TYPE src= 1) { - int cf, pf, af, zf, sf, of; + uint32_t cf, pf, af, zf, sf, of; DATA_TYPE src2; =20 cf =3D src1; @@ -152,9 +152,9 @@ static int glue(compute_all_inc, SUFFIX)(DATA_TYPE dst,= DATA_TYPE src1) return cf | pf | af | zf | sf | of; } =20 -static int glue(compute_all_dec, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) +static uint32_t glue(compute_all_dec, SUFFIX)(DATA_TYPE dst, DATA_TYPE src= 1) { - int cf, pf, af, zf, sf, of; + uint32_t cf, pf, af, zf, sf, of; DATA_TYPE src2; =20 cf =3D src1; @@ -168,9 +168,9 @@ static int glue(compute_all_dec, SUFFIX)(DATA_TYPE dst,= DATA_TYPE src1) return cf | pf | af | zf | sf | of; } =20 -static int glue(compute_all_shl, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) +static uint32_t glue(compute_all_shl, SUFFIX)(DATA_TYPE dst, DATA_TYPE src= 1) { - int cf, pf, af, zf, sf, of; + uint32_t cf, pf, af, zf, sf, of; =20 cf =3D (src1 >> (DATA_BITS - 1)) & CC_C; pf =3D parity_table[(uint8_t)dst]; @@ -187,9 +187,9 @@ static int glue(compute_c_shl, SUFFIX)(DATA_TYPE dst, D= ATA_TYPE src1) return (src1 >> (DATA_BITS - 1)) & CC_C; } =20 -static int glue(compute_all_sar, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) +static uint32_t glue(compute_all_sar, SUFFIX)(DATA_TYPE dst, DATA_TYPE src= 1) { - int cf, pf, af, zf, sf, of; + uint32_t cf, pf, af, zf, sf, of; =20 cf =3D src1 & 1; pf =3D parity_table[(uint8_t)dst]; @@ -204,9 +204,9 @@ static int glue(compute_all_sar, SUFFIX)(DATA_TYPE dst,= DATA_TYPE src1) /* NOTE: we compute the flags like the P4. On olders CPUs, only OF and CF are modified and it is slower to do that. Note as well that we don't truncate SRC1 for computing carry to DATA_TYPE. */ -static int glue(compute_all_mul, SUFFIX)(DATA_TYPE dst, target_long src1) +static uint32_t glue(compute_all_mul, SUFFIX)(DATA_TYPE dst, target_long s= rc1) { - int cf, pf, af, zf, sf, of; + uint32_t cf, pf, af, zf, sf, of; =20 cf =3D (src1 !=3D 0); pf =3D parity_table[(uint8_t)dst]; @@ -217,9 +217,9 @@ static int glue(compute_all_mul, SUFFIX)(DATA_TYPE dst,= target_long src1) return cf | pf | af | zf | sf | of; } =20 -static int glue(compute_all_bmilg, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) +static uint32_t glue(compute_all_bmilg, SUFFIX)(DATA_TYPE dst, DATA_TYPE s= rc1) { - int cf, pf, af, zf, sf, of; + uint32_t cf, pf, af, zf, sf, of; =20 cf =3D (src1 =3D=3D 0); pf =3D 0; /* undefined */ @@ -237,7 +237,7 @@ static int glue(compute_c_bmilg, SUFFIX)(DATA_TYPE dst,= DATA_TYPE src1) =20 static int glue(compute_all_blsi, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) { - int cf, pf, af, zf, sf, of; + uint32_t cf, pf, af, zf, sf, of; =20 cf =3D (src1 !=3D 0); pf =3D 0; /* undefined */ --=20 2.47.0 From nobody Sat Nov 23 17:48:20 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730128903; cv=none; d=zohomail.com; s=zohoarc; b=kuLipViaslwmMYoZBAU78V35pf9kebLV2mVLlbbAXLNaM7X+LhYYz2jxma2hqYOMz/axE6DjZjM++WQiF8+Z5CpNmu74mdrxbhJMeG8VH5eGx5w1wbx3FgxJUpvuHh2+7F1oJUzZGNWHln0Oxwg0TLQpIFR/nWri/jkztNCPN6Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730128903; 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=NmKhKEdS2mkx4S/7qSYmAFENKPtbe328YARDjOvKYh0=; b=ZVQ8MgFX1HanwLqNGChZXU8qF4nBmdbxD3/de1eK/yXlc2sUJV9NAMoN1ruuNkCQB09IUYEODpD7CFGWB/xGisE3nz2QBa0iZ7b+wuiXx0YyR5v8/hCPG72yOWur9VRkkSmuaeWljqVEi1Nck5MDsCAZG7LybqLJnlAEZpems60= 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 1730128903768116.80207975975156; Mon, 28 Oct 2024 08:21:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5RX1-0000CE-0M; Mon, 28 Oct 2024 11:19:47 -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 1t5RWs-0008Lc-FQ for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5RWq-0000rW-0t for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:37 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-59-9nZ7siPONyuo7hSgUMi2dA-1; Mon, 28 Oct 2024 11:19:34 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4316300bb15so31941775e9.2 for ; Mon, 28 Oct 2024 08:19:33 -0700 (PDT) Received: from [192.168.10.3] ([151.49.226.83]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43193573cd4sm113158445e9.5.2024.10.28.08.19.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 08:19:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730128775; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NmKhKEdS2mkx4S/7qSYmAFENKPtbe328YARDjOvKYh0=; b=Q/A2jrK3nj+Mi1hV3iaiC+KjlU+gEyHPKqh5UHHl4VtbDxne3rIQcBRlEnl7eJU4m+86aQ mSK6dap6dSbwGgrZltH/c9/zaXUBv8ySBrZZFxJhjg1uwaPlf82hBf2yOM4DE9CYcPpzrw mMinclabjizbUqoCGMaa7e4dgYzq6qc= X-MC-Unique: 9nZ7siPONyuo7hSgUMi2dA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730128772; x=1730733572; 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=NmKhKEdS2mkx4S/7qSYmAFENKPtbe328YARDjOvKYh0=; b=W1V/2sihd/9F1/1MjHdwmDZ9iqwAH5ooH6yFZTkoQxLAIouJC/b6+oUD6hGgInOrhj +ta61pDsox1y3BiToeF7DFe7EOmqHErEeL/vriNuVZ7vG5NCnPog8yjscGgOEsovctaV +TEG++Df10lzVUIE85RiaPEu8DuJ3e4aaCRrIBCTRMBqALYGPNeiiaH99/TegxanR3Hq dlp+bhbdlbb+qlqi+ThCv9Gv9/MdiGF+shOv7zDGU0RZn/XFeGpsJc2oF0yKeT4rZY2w K3hwwA8AYlzgv7+XWTegK+m+1ZjWYUHGK6uiG81xc5uKt/eZjjR8lDy7WgAz6vNUff9B Ng0w== X-Gm-Message-State: AOJu0YxuY4fT7yxuwSN9mUFL6ZuYtKs5vY3D80g6l8qQPO+UOLJsLaSz zjZwApCDJYtqNK+nNB8ocWL2JrE1MVNqHMmBRj98lCuKfvC9ICFlYfyEfs9y3B6nl1zWE+JG01a R0LE4KEYH9micl2bpkE5XTR3zADix3Fgx8JLBJFGbrDxOdUZdfTB2Q0mKkihzJ/7tivqP83+I4I eumXNIun7+/Vc+Ab7dOL62K5WOpDG/T3BPL1oeC7o= X-Received: by 2002:a05:600c:3ca3:b0:42f:823d:dde9 with SMTP id 5b1f17b1804b1-4319acbba20mr81364225e9.21.1730128772502; Mon, 28 Oct 2024 08:19:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEiNMa6DEwpmp3jkzn6CmqntXxtycjOsfKarpJouKKJCpjKj1j2czQvLjX9qkk3wslpjbP/ow== X-Received: by 2002:a05:600c:3ca3:b0:42f:823d:dde9 with SMTP id 5b1f17b1804b1-4319acbba20mr81363465e9.21.1730128771186; Mon, 28 Oct 2024 08:19:31 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PATCH 12/14] target/i386: use compiler builtin to compute PF Date: Mon, 28 Oct 2024 16:18:49 +0100 Message-ID: <20241028151851.376355-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241028151851.376355-1-pbonzini@redhat.com> References: <20241028151851.376355-1-pbonzini@redhat.com> 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=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730128905337116600 Content-Type: text/plain; charset="utf-8" This removes the 256 byte parity table from the executable. Suggested-by: Richard Henderson Signed-off-by: Paolo Bonzini --- include/qemu/host-utils.h | 9 ++++++ target/i386/tcg/helper-tcg.h | 6 +++- target/i386/tcg/cc_helper_template.h.inc | 20 +++++++------- target/i386/tcg/cc_helper.c | 35 ------------------------ target/i386/tcg/int_helper.c | 4 +-- 5 files changed, 26 insertions(+), 48 deletions(-) diff --git a/include/qemu/host-utils.h b/include/qemu/host-utils.h index ead97d354d6..4d28fa22cfa 100644 --- a/include/qemu/host-utils.h +++ b/include/qemu/host-utils.h @@ -313,6 +313,15 @@ static inline int ctpop8(uint8_t val) return __builtin_popcount(val); } =20 +/* + * parity8 - return the parity (1 =3D odd) of an 8-bit value. + * @val: The value to search + */ +static inline int parity8(uint8_t val) +{ + return __builtin_parity(val); +} + /** * ctpop16 - count the population of one bits in a 16-bit value. * @val: The value to search diff --git a/target/i386/tcg/helper-tcg.h b/target/i386/tcg/helper-tcg.h index 15d6c6f8b4f..696d6ef016f 100644 --- a/target/i386/tcg/helper-tcg.h +++ b/target/i386/tcg/helper-tcg.h @@ -21,6 +21,7 @@ #define I386_HELPER_TCG_H =20 #include "exec/exec-all.h" +#include "qemu/host-utils.h" =20 /* Maximum instruction code size */ #define TARGET_MAX_INSN_SIZE 16 @@ -87,7 +88,10 @@ G_NORETURN void x86_cpu_do_unaligned_access(CPUState *cs= , vaddr vaddr, #endif =20 /* cc_helper.c */ -extern const uint8_t parity_table[256]; +static inline unsigned int compute_pf(uint8_t x) +{ + return !parity8(x) * CC_P; +} =20 /* misc_helper.c */ void cpu_load_eflags(CPUX86State *env, int eflags, int update_mask); diff --git a/target/i386/tcg/cc_helper_template.h.inc b/target/i386/tcg/cc_= helper_template.h.inc index 4cbbc73c3cd..8af8b8539f9 100644 --- a/target/i386/tcg/cc_helper_template.h.inc +++ b/target/i386/tcg/cc_helper_template.h.inc @@ -45,7 +45,7 @@ static uint32_t glue(compute_all_add, SUFFIX)(DATA_TYPE d= st, DATA_TYPE src1) DATA_TYPE src2 =3D dst - src1; =20 cf =3D dst < src1; - pf =3D parity_table[(uint8_t)dst]; + pf =3D compute_pf(dst); af =3D (dst ^ src1 ^ src2) & CC_A; zf =3D (dst =3D=3D 0) * CC_Z; sf =3D lshift(dst, 8 - DATA_BITS) & CC_S; @@ -65,7 +65,7 @@ static uint32_t glue(compute_all_adc, SUFFIX)(DATA_TYPE d= st, DATA_TYPE src1, DATA_TYPE src2 =3D dst - src1 - src3; =20 cf =3D (src3 ? dst <=3D src1 : dst < src1); - pf =3D parity_table[(uint8_t)dst]; + pf =3D compute_pf(dst); af =3D (dst ^ src1 ^ src2) & 0x10; zf =3D (dst =3D=3D 0) << 6; sf =3D lshift(dst, 8 - DATA_BITS) & 0x80; @@ -85,7 +85,7 @@ static uint32_t glue(compute_all_sub, SUFFIX)(DATA_TYPE d= st, DATA_TYPE src2) DATA_TYPE src1 =3D dst + src2; =20 cf =3D src1 < src2; - pf =3D parity_table[(uint8_t)dst]; + pf =3D compute_pf(dst); af =3D (dst ^ src1 ^ src2) & CC_A; zf =3D (dst =3D=3D 0) * CC_Z; sf =3D lshift(dst, 8 - DATA_BITS) & CC_S; @@ -107,7 +107,7 @@ static uint32_t glue(compute_all_sbb, SUFFIX)(DATA_TYPE= dst, DATA_TYPE src2, DATA_TYPE src1 =3D dst + src2 + src3; =20 cf =3D (src3 ? src1 <=3D src2 : src1 < src2); - pf =3D parity_table[(uint8_t)dst]; + pf =3D compute_pf(dst); af =3D (dst ^ src1 ^ src2) & 0x10; zf =3D (dst =3D=3D 0) << 6; sf =3D lshift(dst, 8 - DATA_BITS) & 0x80; @@ -128,7 +128,7 @@ static uint32_t glue(compute_all_logic, SUFFIX)(DATA_TY= PE dst, DATA_TYPE src1) uint32_t cf, pf, af, zf, sf, of; =20 cf =3D 0; - pf =3D parity_table[(uint8_t)dst]; + pf =3D compute_pf(dst); af =3D 0; zf =3D (dst =3D=3D 0) * CC_Z; sf =3D lshift(dst, 8 - DATA_BITS) & CC_S; @@ -144,7 +144,7 @@ static uint32_t glue(compute_all_inc, SUFFIX)(DATA_TYPE= dst, DATA_TYPE src1) cf =3D src1; src1 =3D dst - 1; src2 =3D 1; - pf =3D parity_table[(uint8_t)dst]; + pf =3D compute_pf(dst); af =3D (dst ^ src1 ^ src2) & CC_A; zf =3D (dst =3D=3D 0) * CC_Z; sf =3D lshift(dst, 8 - DATA_BITS) & CC_S; @@ -160,7 +160,7 @@ static uint32_t glue(compute_all_dec, SUFFIX)(DATA_TYPE= dst, DATA_TYPE src1) cf =3D src1; src1 =3D dst + 1; src2 =3D 1; - pf =3D parity_table[(uint8_t)dst]; + pf =3D compute_pf(dst); af =3D (dst ^ src1 ^ src2) & CC_A; zf =3D (dst =3D=3D 0) * CC_Z; sf =3D lshift(dst, 8 - DATA_BITS) & CC_S; @@ -173,7 +173,7 @@ static uint32_t glue(compute_all_shl, SUFFIX)(DATA_TYPE= dst, DATA_TYPE src1) uint32_t cf, pf, af, zf, sf, of; =20 cf =3D (src1 >> (DATA_BITS - 1)) & CC_C; - pf =3D parity_table[(uint8_t)dst]; + pf =3D compute_pf(dst); af =3D 0; /* undefined */ zf =3D (dst =3D=3D 0) * CC_Z; sf =3D lshift(dst, 8 - DATA_BITS) & CC_S; @@ -192,7 +192,7 @@ static uint32_t glue(compute_all_sar, SUFFIX)(DATA_TYPE= dst, DATA_TYPE src1) uint32_t cf, pf, af, zf, sf, of; =20 cf =3D src1 & 1; - pf =3D parity_table[(uint8_t)dst]; + pf =3D compute_pf(dst); af =3D 0; /* undefined */ zf =3D (dst =3D=3D 0) * CC_Z; sf =3D lshift(dst, 8 - DATA_BITS) & CC_S; @@ -209,7 +209,7 @@ static uint32_t glue(compute_all_mul, SUFFIX)(DATA_TYPE= dst, target_long src1) uint32_t cf, pf, af, zf, sf, of; =20 cf =3D (src1 !=3D 0); - pf =3D parity_table[(uint8_t)dst]; + pf =3D compute_pf(dst); af =3D 0; /* undefined */ zf =3D (dst =3D=3D 0) * CC_Z; sf =3D lshift(dst, 8 - DATA_BITS) & CC_S; diff --git a/target/i386/tcg/cc_helper.c b/target/i386/tcg/cc_helper.c index 1b83775a914..f1940b40927 100644 --- a/target/i386/tcg/cc_helper.c +++ b/target/i386/tcg/cc_helper.c @@ -22,41 +22,6 @@ #include "exec/helper-proto.h" #include "helper-tcg.h" =20 -const uint8_t parity_table[256] =3D { - CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, - 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, - 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, - CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, - 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, - CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, - CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, - 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, - 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, - CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, - CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, - 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, - CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, - 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, - 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, - CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, - 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, - CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, - CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, - 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, - CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, - 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, - 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, - CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, - CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, - 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, - 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, - CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, - 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, - CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, - CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, - 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, -}; - #define SHIFT 0 #include "cc_helper_template.h.inc" #undef SHIFT diff --git a/target/i386/tcg/int_helper.c b/target/i386/tcg/int_helper.c index e1f92405282..1a02e9d8434 100644 --- a/target/i386/tcg/int_helper.c +++ b/target/i386/tcg/int_helper.c @@ -237,7 +237,7 @@ void helper_daa(CPUX86State *env) env->regs[R_EAX] =3D (env->regs[R_EAX] & ~0xff) | al; /* well, speed is not an issue here, so we compute the flags by hand */ eflags |=3D (al =3D=3D 0) << 6; /* zf */ - eflags |=3D parity_table[al]; /* pf */ + eflags |=3D compute_pf(al); eflags |=3D (al & 0x80); /* sf */ CC_SRC =3D eflags; CC_OP =3D CC_OP_EFLAGS; @@ -269,7 +269,7 @@ void helper_das(CPUX86State *env) env->regs[R_EAX] =3D (env->regs[R_EAX] & ~0xff) | al; /* well, speed is not an issue here, so we compute the flags by hand */ eflags |=3D (al =3D=3D 0) << 6; /* zf */ - eflags |=3D parity_table[al]; /* pf */ + eflags |=3D compute_pf(al); eflags |=3D (al & 0x80); /* sf */ CC_SRC =3D eflags; CC_OP =3D CC_OP_EFLAGS; --=20 2.47.0 From nobody Sat Nov 23 17:48:20 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730128880; cv=none; d=zohomail.com; s=zohoarc; b=YZT3vLyNYsaryMshRLqveTeAI6Jtz9FzUH3FWSFTzCiCoqEz3tMNwlQXO0+j89aG2OT4NvJjaECm6gI7n1nHlgpcgUo4PXxlZToWAN87/VbewGOJIwI1tgmOzOZjra9a128xOBCkFrfNv6tMyTHBBGAp+2TiAtmCQSotXUVSq/c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730128880; 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=UiNRCJcj6y5gkOMCLNt04TYjymilyV5BG77bHcu2074=; b=nwB7AwolFJCHQruaS1fc0FyaGD+03KE4cqDpJTAId3C/1qQnmcz7U2TCE8XNWN3yrMGP6kUieCgJaA9N/VMWwEu4ZTHqjZ+jjnyHymOkjsIfdboNNs5boKsHmQDWukcqdQ7v9AmNot86KbZDL7emqQCW9K79JjoI9cBGpQiGA8k= 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 173012888009645.11734687688272; Mon, 28 Oct 2024 08:21:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5RX2-0000JF-Uz; Mon, 28 Oct 2024 11:19:48 -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 1t5RWu-0008NI-Ez for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5RWs-0000rf-Ra for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:40 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-549-G5ZPMZmDMbaWJ8rB71LuZA-1; Mon, 28 Oct 2024 11:19:35 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-37d56061a4cso2434622f8f.2 for ; Mon, 28 Oct 2024 08:19:35 -0700 (PDT) Received: from [192.168.10.3] ([151.49.226.83]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38058bb433bsm9729282f8f.112.2024.10.28.08.19.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 08:19:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730128776; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UiNRCJcj6y5gkOMCLNt04TYjymilyV5BG77bHcu2074=; b=OcNU5SlYWN5wzqAG7wn9UYmpffu9YySVlE+25qJS/+k6p0W72mYFa7Nl60Ouk6NxVkQRoL 2SrsKgFYKNnGEs6K1t1GQuUEaKcXemYbrQdLAIuJIBoqqjetzkewJltdY+dPQSoqPwwOOc 0LTGsL6xfSzrmuSkOwNU7QXFcaxWhdE= X-MC-Unique: G5ZPMZmDMbaWJ8rB71LuZA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730128773; x=1730733573; 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=UiNRCJcj6y5gkOMCLNt04TYjymilyV5BG77bHcu2074=; b=LbeWW44eEs0nZ6z6r+l5j09Q2D0n/Vb47ZS05Unn56p8RPd2kZmuYxln+AaYmIY2eA g5tre3bbsLYEER/7fGsYmxzLf/NldzuZFJV8GWf09RCRL3dZBXjD8hTlMaHKC/FQ+Fl9 ao8NEVS3LaED7zbE1a5sG7F9vXRzR9I8tsbNDdhBu8lJ3WlLvTPWPtGgNSyF6EtgGTyC IsmwJH06F17lVTSwqOe3DNfX3Ke72Fud6ChH/71hqQXseZBaU8iZE0RoqcKymCYfkrqO oBPyfsNQeh/izxhAGOy3vkDmFWoOZ5aQvXHAlrJLV7XxC+b8yD6nCyV9q1uSNh2h0aHK JN6w== X-Gm-Message-State: AOJu0YwV1yrL32IRVwXvMZtE0lvSDDSJ2/J4vpw1zAnGf13cPUA/Hmpq AhhyW+0BOiDgNH98hhM7ummzoLIBfe0XgTotoMGmrLkTVJyj2X6Vd1Ys+oQzRhvp8gsixibGrfg ZmvdPKZbmHFzepwD5ljDspsatn8bOMTnHjDCdRHzlNFaI4X4RWyQDeiNQCPYx228a8dbCezcnLM FXDZEyej0MspKQfse69fL3Ez5lKODppRztNYYI6J0= X-Received: by 2002:a5d:4c46:0:b0:378:89be:1825 with SMTP id ffacd0b85a97d-380611f55a1mr5450283f8f.49.1730128773302; Mon, 28 Oct 2024 08:19:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE2O952Wyn20plbBwesyIVVMgDcqmoYAw5bUTLzjkYmZQAiA/AzU9Vu+DGR4Nq1xuIYHaURQw== X-Received: by 2002:a5d:4c46:0:b0:378:89be:1825 with SMTP id ffacd0b85a97d-380611f55a1mr5450262f8f.49.1730128772857; Mon, 28 Oct 2024 08:19:32 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PATCH 13/14] target/i386: use higher-precision arithmetic to compute CF Date: Mon, 28 Oct 2024 16:18:50 +0100 Message-ID: <20241028151851.376355-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241028151851.376355-1-pbonzini@redhat.com> References: <20241028151851.376355-1-pbonzini@redhat.com> 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=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730128881150116600 Content-Type: text/plain; charset="utf-8" If the operands of the arithmetic instruction fit within a half-register, it's easiest to use a comparison instruction to compute the carry. ` Signed-off-by: Paolo Bonzini --- target/i386/tcg/cc_helper_template.h.inc | 37 ++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/target/i386/tcg/cc_helper_template.h.inc b/target/i386/tcg/cc_= helper_template.h.inc index 8af8b8539f9..f29a6dfb77c 100644 --- a/target/i386/tcg/cc_helper_template.h.inc +++ b/target/i386/tcg/cc_helper_template.h.inc @@ -22,12 +22,17 @@ #if DATA_BITS =3D=3D 8 #define SUFFIX b #define DATA_TYPE uint8_t +#define WIDER_TYPE uint32_t #elif DATA_BITS =3D=3D 16 #define SUFFIX w #define DATA_TYPE uint16_t +#define WIDER_TYPE uint32_t #elif DATA_BITS =3D=3D 32 #define SUFFIX l #define DATA_TYPE uint32_t +#if HOST_LONG_BITS <=3D 64 +#define WIDER_TYPE uint64_t +#endif #elif DATA_BITS =3D=3D 64 #define SUFFIX q #define DATA_TYPE uint64_t @@ -62,9 +67,18 @@ static uint32_t glue(compute_all_adc, SUFFIX)(DATA_TYPE = dst, DATA_TYPE src1, DATA_TYPE src3) { uint32_t cf, pf, af, zf, sf, of; + +#ifdef WIDER_TYPE + WIDER_TYPE src13 =3D (WIDER_TYPE) src1 + (WIDER_TYPE) src3; + DATA_TYPE src2 =3D dst - src13; + + cf =3D dst < src13; +#else DATA_TYPE src2 =3D dst - src1 - src3; =20 cf =3D (src3 ? dst <=3D src1 : dst < src1); +#endif + pf =3D compute_pf(dst); af =3D (dst ^ src1 ^ src2) & 0x10; zf =3D (dst =3D=3D 0) << 6; @@ -76,7 +90,13 @@ static uint32_t glue(compute_all_adc, SUFFIX)(DATA_TYPE = dst, DATA_TYPE src1, static int glue(compute_c_adc, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1, DATA_TYPE src3) { +#ifdef WIDER_TYPE + WIDER_TYPE src13 =3D (WIDER_TYPE) src1 + (WIDER_TYPE) src3; + + return dst < src13; +#else return src3 ? dst <=3D src1 : dst < src1; +#endif } =20 static uint32_t glue(compute_all_sub, SUFFIX)(DATA_TYPE dst, DATA_TYPE src= 2) @@ -104,9 +124,18 @@ static uint32_t glue(compute_all_sbb, SUFFIX)(DATA_TYP= E dst, DATA_TYPE src2, DATA_TYPE src3) { uint32_t cf, pf, af, zf, sf, of; + +#ifdef WIDER_TYPE + WIDER_TYPE src23 =3D (WIDER_TYPE) src2 + (WIDER_TYPE) src3; + DATA_TYPE src1 =3D dst + src23; + + cf =3D src1 < src23; +#else DATA_TYPE src1 =3D dst + src2 + src3; =20 cf =3D (src3 ? src1 <=3D src2 : src1 < src2); +#endif + pf =3D compute_pf(dst); af =3D (dst ^ src1 ^ src2) & 0x10; zf =3D (dst =3D=3D 0) << 6; @@ -118,9 +147,16 @@ static uint32_t glue(compute_all_sbb, SUFFIX)(DATA_TYP= E dst, DATA_TYPE src2, static int glue(compute_c_sbb, SUFFIX)(DATA_TYPE dst, DATA_TYPE src2, DATA_TYPE src3) { +#ifdef WIDER_TYPE + WIDER_TYPE src23 =3D (WIDER_TYPE) src2 + (WIDER_TYPE) src3; + DATA_TYPE src1 =3D dst + src23; + + return src1 < src23; +#else DATA_TYPE src1 =3D dst + src2 + src3; =20 return (src3 ? src1 <=3D src2 : src1 < src2); +#endif } =20 static uint32_t glue(compute_all_logic, SUFFIX)(DATA_TYPE dst, DATA_TYPE s= rc1) @@ -258,3 +294,4 @@ static int glue(compute_c_blsi, SUFFIX)(DATA_TYPE dst, = DATA_TYPE src1) #undef DATA_TYPE #undef DATA_MASK #undef SUFFIX +#undef WIDER_TYPE --=20 2.47.0 From nobody Sat Nov 23 17:48:20 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730128953; cv=none; d=zohomail.com; s=zohoarc; b=nATl1IGIcVVdPxTlRpuFbYYLv36EqOElWHNIPuAK/G8+l+HsmiKf5QYKCf//cox+PWPxkuvitTizMMAFtWbcbPRM91KDyPHYIo11ySMx260AfCo6JPLfw80QMz1iCjCA1i8cOenK1Ngkgo6q1P3fgjIyrb0HIAMSzQH0hv4ZFjU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730128953; 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=i+7hpjh8zyx3zlcLNxjdL89izQCWDrDMLuGY9zVgw6o=; b=GEpzU8tLkfjQsdOQjaMf2gCwaBW59gG6/Y1iOGQEC9xSNLqzW9M9CAKgap8NUWa+TIBiBRJgTN7XfEKcBY+MLmmVaFFBWfkO3CeWc8bRscZtCbv62hrPKg2NDACKTn2avNoKT0HZuOxPt0pUmamYYLYkEfJ6rf4y+r2+i5ZZJfE= 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 1730128953200887.1893835253055; Mon, 28 Oct 2024 08:22:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5RX4-0000QZ-0k; Mon, 28 Oct 2024 11:19:50 -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 1t5RWy-0008SC-9y for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5RWu-0000s1-IR for qemu-devel@nongnu.org; Mon, 28 Oct 2024 11:19:42 -0400 Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-589-tKzgR1HOM-WglE8tA8xVrQ-1; Mon, 28 Oct 2024 11:19:38 -0400 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-539f067414fso3171525e87.2 for ; Mon, 28 Oct 2024 08:19:38 -0700 (PDT) Received: from [192.168.10.3] ([151.49.226.83]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b56ef06sm143691335e9.30.2024.10.28.08.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 08:19:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730128779; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i+7hpjh8zyx3zlcLNxjdL89izQCWDrDMLuGY9zVgw6o=; b=JseBk6tiSfrANck7a8rqxiv+ZS9LfSkXrDjbEL0GLCLJUrJZYX/DjsnPYVtXNDGEXW+Etr Yuh3tUYwNnHlzURWgKEt12us4MgVD7AOygbXldZqOpqkDQA9Oowknttauo/8OBMKHNKEZk WOFMIBAnOdk4GJOrujehVXYFq5mtGaA= X-MC-Unique: tKzgR1HOM-WglE8tA8xVrQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730128777; x=1730733577; 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=i+7hpjh8zyx3zlcLNxjdL89izQCWDrDMLuGY9zVgw6o=; b=DzDLaY+yPLv2GL1aSaBnWlz9JaZYrkpbVzqWqTszT0sPOZC7ZbI8pyZ8no5dgHl63U 4vTJG6iBBjkOO2yUd0sOPODY/6ylCE5P2EmVZnAmSDGjQ2rFFLXfLKh/ubE5YhO0Otpi VGJ6CH6GRaALKNYWkfmpDbm+2oxhhs816C7gF04gf80+B9SQw2z5gwlqbNvfgnKyyVZk icOSQfqt568bbGyZQMS46H8nbmStVi9kibuTtikU4ClMCPe1q2INFqD5ZyOXzNuVf8wS 2tZbn7oCn+aYiUTaBXnj5RwERxafSEERcjjWzuMp634bX8s9WhEnOsiAFPSMhUYUqR+K XF6w== X-Gm-Message-State: AOJu0YwMCdsa6a8Lu7X5FlIhVWSDoMoYllEWxZBAY6IXDL007VofXQfH 6Jj++L4VlDiSv7uv1I/iEmnbtmm0rUcWWHNUrMpqCu3ElhSsm9XKhT9isnELwykftaEk8qq/Z99 H3lcQFTs36/m/Xdn67P1sV25KGBPpjFUN9Ptaz6lGsykUnAnTspYfaEinbFlbHnRY0nouJH4cag n7L1Y4UMqUeprFkBNTrFope77OquIGRVkAQboE1dI= X-Received: by 2002:a05:6512:4022:b0:539:e333:1822 with SMTP id 2adb3069b0e04-53b348b7dc7mr3866866e87.4.1730128776525; Mon, 28 Oct 2024 08:19:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHt90scYUFvRudPh6eWb+hfE0Xbe8bpn1bFyiED3MEfMXz+HnhK4WNE6kaNpindxo6qdHPNeA== X-Received: by 2002:a05:6512:4022:b0:539:e333:1822 with SMTP id 2adb3069b0e04-53b348b7dc7mr3866839e87.4.1730128775987; Mon, 28 Oct 2024 08:19:35 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PATCH 14/14] target/i386: use + to put flags together Date: Mon, 28 Oct 2024 16:18:51 +0100 Message-ID: <20241028151851.376355-15-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241028151851.376355-1-pbonzini@redhat.com> References: <20241028151851.376355-1-pbonzini@redhat.com> 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=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.373, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1730128953467116600 Content-Type: text/plain; charset="utf-8" This gives greater opportunity for reassociation on x86 targets, since addition can use the LEA instruction. Signed-off-by: Paolo Bonzini --- target/i386/tcg/cc_helper_template.h.inc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/target/i386/tcg/cc_helper_template.h.inc b/target/i386/tcg/cc_= helper_template.h.inc index f29a6dfb77c..d7672c8840a 100644 --- a/target/i386/tcg/cc_helper_template.h.inc +++ b/target/i386/tcg/cc_helper_template.h.inc @@ -55,7 +55,7 @@ static uint32_t glue(compute_all_add, SUFFIX)(DATA_TYPE d= st, DATA_TYPE src1) zf =3D (dst =3D=3D 0) * CC_Z; sf =3D lshift(dst, 8 - DATA_BITS) & CC_S; of =3D lshift((src1 ^ src2 ^ -1) & (src1 ^ dst), 12 - DATA_BITS) & CC_= O; - return cf | pf | af | zf | sf | of; + return cf + pf + af + zf + sf + of; } =20 static int glue(compute_c_add, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) @@ -84,7 +84,7 @@ static uint32_t glue(compute_all_adc, SUFFIX)(DATA_TYPE d= st, DATA_TYPE src1, zf =3D (dst =3D=3D 0) << 6; sf =3D lshift(dst, 8 - DATA_BITS) & 0x80; of =3D lshift((src1 ^ src2 ^ -1) & (src1 ^ dst), 12 - DATA_BITS) & CC_= O; - return cf | pf | af | zf | sf | of; + return cf + pf + af + zf + sf + of; } =20 static int glue(compute_c_adc, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1, @@ -110,7 +110,7 @@ static uint32_t glue(compute_all_sub, SUFFIX)(DATA_TYPE= dst, DATA_TYPE src2) zf =3D (dst =3D=3D 0) * CC_Z; sf =3D lshift(dst, 8 - DATA_BITS) & CC_S; of =3D lshift((src1 ^ src2) & (src1 ^ dst), 12 - DATA_BITS) & CC_O; - return cf | pf | af | zf | sf | of; + return cf + pf + af + zf + sf + of; } =20 static int glue(compute_c_sub, SUFFIX)(DATA_TYPE dst, DATA_TYPE src2) @@ -141,7 +141,7 @@ static uint32_t glue(compute_all_sbb, SUFFIX)(DATA_TYPE= dst, DATA_TYPE src2, zf =3D (dst =3D=3D 0) << 6; sf =3D lshift(dst, 8 - DATA_BITS) & 0x80; of =3D lshift((src1 ^ src2) & (src1 ^ dst), 12 - DATA_BITS) & CC_O; - return cf | pf | af | zf | sf | of; + return cf + pf + af + zf + sf + of; } =20 static int glue(compute_c_sbb, SUFFIX)(DATA_TYPE dst, DATA_TYPE src2, @@ -169,7 +169,7 @@ static uint32_t glue(compute_all_logic, SUFFIX)(DATA_TY= PE dst, DATA_TYPE src1) zf =3D (dst =3D=3D 0) * CC_Z; sf =3D lshift(dst, 8 - DATA_BITS) & CC_S; of =3D 0; - return cf | pf | af | zf | sf | of; + return cf + pf + af + zf + sf + of; } =20 static uint32_t glue(compute_all_inc, SUFFIX)(DATA_TYPE dst, DATA_TYPE src= 1) @@ -185,7 +185,7 @@ static uint32_t glue(compute_all_inc, SUFFIX)(DATA_TYPE= dst, DATA_TYPE src1) zf =3D (dst =3D=3D 0) * CC_Z; sf =3D lshift(dst, 8 - DATA_BITS) & CC_S; of =3D (dst =3D=3D SIGN_MASK) * CC_O; - return cf | pf | af | zf | sf | of; + return cf + pf + af + zf + sf + of; } =20 static uint32_t glue(compute_all_dec, SUFFIX)(DATA_TYPE dst, DATA_TYPE src= 1) @@ -201,7 +201,7 @@ static uint32_t glue(compute_all_dec, SUFFIX)(DATA_TYPE= dst, DATA_TYPE src1) zf =3D (dst =3D=3D 0) * CC_Z; sf =3D lshift(dst, 8 - DATA_BITS) & CC_S; of =3D (dst =3D=3D SIGN_MASK - 1) * CC_O; - return cf | pf | af | zf | sf | of; + return cf + pf + af + zf + sf + of; } =20 static uint32_t glue(compute_all_shl, SUFFIX)(DATA_TYPE dst, DATA_TYPE src= 1) @@ -215,7 +215,7 @@ static uint32_t glue(compute_all_shl, SUFFIX)(DATA_TYPE= dst, DATA_TYPE src1) sf =3D lshift(dst, 8 - DATA_BITS) & CC_S; /* of is defined iff shift count =3D=3D 1 */ of =3D lshift(src1 ^ dst, 12 - DATA_BITS) & CC_O; - return cf | pf | af | zf | sf | of; + return cf + pf + af + zf + sf + of; } =20 static int glue(compute_c_shl, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) @@ -234,7 +234,7 @@ static uint32_t glue(compute_all_sar, SUFFIX)(DATA_TYPE= dst, DATA_TYPE src1) sf =3D lshift(dst, 8 - DATA_BITS) & CC_S; /* of is defined iff shift count =3D=3D 1 */ of =3D lshift(src1 ^ dst, 12 - DATA_BITS) & CC_O; - return cf | pf | af | zf | sf | of; + return cf + pf + af + zf + sf + of; } =20 /* NOTE: we compute the flags like the P4. On olders CPUs, only OF and @@ -250,7 +250,7 @@ static uint32_t glue(compute_all_mul, SUFFIX)(DATA_TYPE= dst, target_long src1) zf =3D (dst =3D=3D 0) * CC_Z; sf =3D lshift(dst, 8 - DATA_BITS) & CC_S; of =3D cf * CC_O; - return cf | pf | af | zf | sf | of; + return cf + pf + af + zf + sf + of; } =20 static uint32_t glue(compute_all_bmilg, SUFFIX)(DATA_TYPE dst, DATA_TYPE s= rc1) @@ -263,7 +263,7 @@ static uint32_t glue(compute_all_bmilg, SUFFIX)(DATA_TY= PE dst, DATA_TYPE src1) zf =3D (dst =3D=3D 0) * CC_Z; sf =3D lshift(dst, 8 - DATA_BITS) & CC_S; of =3D 0; - return cf | pf | af | zf | sf | of; + return cf + pf + af + zf + sf + of; } =20 static int glue(compute_c_bmilg, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) @@ -281,7 +281,7 @@ static int glue(compute_all_blsi, SUFFIX)(DATA_TYPE dst= , DATA_TYPE src1) zf =3D (dst =3D=3D 0) * CC_Z; sf =3D lshift(dst, 8 - DATA_BITS) & CC_S; of =3D 0; - return cf | pf | af | zf | sf | of; + return cf + pf + af + zf + sf + of; } =20 static int glue(compute_c_blsi, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) --=20 2.47.0