From patchwork Sun Oct 20 15:53:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13843121 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 40843D3C934 for ; Sun, 20 Oct 2024 15:55:58 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2YFN-0003Lc-IV; Sun, 20 Oct 2024 11:53:37 -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 1t2YFM-0003LD-46 for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:53: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 1t2YFK-0005PF-ON for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:53:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729439614; 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=EMwb4cqMtnHKGBA9xJPy57dYI46qDTx8J452fpJp7/c=; b=MVDOIY3ATvLJh9KPPo8BM002fgfKZBQ+5SnCtE7Hc/xRM79NiR7+L6oOmC7O2NjuoewD4H IbWIS3yoK1dU+cmdJ7hxUFRqrtoMqsPAYOhXSUZotu0x9N2l7bQfKDaOKSdgeUBNqNPIuv ekmrzNFM0a+nU1C3E2C0+pwd5mQR+bM= 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-264-KS3alombNPKMMT_qbc7-HA-1; Sun, 20 Oct 2024 11:53:31 -0400 X-MC-Unique: KS3alombNPKMMT_qbc7-HA-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4317391101aso457565e9.2 for ; Sun, 20 Oct 2024 08:53:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729439610; x=1730044410; 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=EMwb4cqMtnHKGBA9xJPy57dYI46qDTx8J452fpJp7/c=; b=jVdNOoWQKhUuwo2ptt0bjYoH3Bk6BuV7AfGHyGe/23COteVnViEA50GhJVbPJUoLiF dKzegxp2GZj9DopvQcvAtF7Xqnet1zshe5l2c9dVkvFUwN342FIU9EuLW/Y9JgJvRmKw x7sSz6Vt3/3B/j9Ge0raX5/oIOeIFlNEIt9+O6al3qvrBP8lFsUidCU9vYwKmnhRNVo7 BhOioEvuXUre1UNDuxVxqJz7krRb76Lx8ls8oINrVCXPOEITtYjQ5YEIlQ02Rtvn1dw9 xwaT/t2WKNX88Sq4a1MMtu+ULdwE8qmYsK/LrIv7EHg5neTr6US4HC+oo60C9Bi4roCa WRaw== X-Gm-Message-State: AOJu0YwP+ld+5e20V/1SevVhKTpcxvxVJMqGWThoIOkL5WkekjIh4v7e x7Xtg60o5Taz7tJ71nzba12Qg6cmS1P8MEjkdrCTjDkU42ydFXjhIvVAm6uv5fkFONGQVSNdDmt /0IqVJaJxvOeaEBHQlVKPqrPxHfgxR8N8FMH24lDhLXIdUhGe8G4T9vnVJ6AwQGa2jgzF7MZv3+ P/UM9Cm8BB4vQGwgpuDlwUw7s+THGCcvFAxHCTe6k= X-Received: by 2002:a05:600c:4ed2:b0:426:64a2:5362 with SMTP id 5b1f17b1804b1-4316163b8bbmr63952505e9.8.1729439609801; Sun, 20 Oct 2024 08:53:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQfHN5TXu0JflghqLSw/jVxhSR+lR6woc1hz0kzri/1mvHNFCwU+0Vc/pW1+SV2XtJ8LkFug== X-Received: by 2002:a05:600c:4ed2:b0:426:64a2:5362 with SMTP id 5b1f17b1804b1-4316163b8bbmr63952365e9.8.1729439609293; Sun, 20 Oct 2024 08:53:29 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f58ae9bsm27070935e9.21.2024.10.20.08.53.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 08:53:27 -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: Sun, 20 Oct 2024 17:53:11 +0200 Message-ID: <20241020155324.35273-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241020155324.35273-1-pbonzini@redhat.com> References: <20241020155324.35273-1-pbonzini@redhat.com> MIME-Version: 1.0 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: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.527, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Prefer it to gen_ext_tl in the common case where the destination is known. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- 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 = 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 = TCG_COND_LTU, .reg = s->cc_srcT, .reg2 = cpu_cc_src, .use_reg2 = true }; case CC_OP_ADDB ... CC_OP_ADDQ: /* (DATA_TYPE)CC_DST < (DATA_TYPE)CC_SRC */ size = 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 = TCG_COND_LTU, .reg = cpu_cc_dst, .reg2 = cpu_cc_src, .use_reg2 = true }; @@ -1041,8 +1041,8 @@ static CCPrepare gen_prepare_cc(DisasContext *s, int b, TCGv reg) size = 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 = (CCPrepare) { .cond = TCG_COND_LEU, .reg = s->cc_srcT, .reg2 = cpu_cc_src, .use_reg2 = true }; break; @@ -1052,8 +1052,8 @@ static CCPrepare gen_prepare_cc(DisasContext *s, int b, TCGv reg) case JCC_LE: cond = 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 = (CCPrepare) { .cond = cond, .reg = s->cc_srcT, .reg2 = cpu_cc_src, .use_reg2 = true }; break; From patchwork Sun Oct 20 15:53:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13843112 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EB035D3C92A for ; Sun, 20 Oct 2024 15:54:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2YFQ-0003MN-7n; Sun, 20 Oct 2024 11:53:40 -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 1t2YFP-0003MD-5G for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:53:39 -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 1t2YFN-0005PW-Px for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:53:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729439616; 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=1bX8SwrawXi6wPzSE0JjFJp8yDQGRij0ZpmKsQ3vth0=; b=OYZEtoLX5jSG+Udyhk4XySwLc/3kp7E+kE0vmXAvw3928ibO/H7Jkhet0TiM0rFjX9htE8 Bxzp0TTuzw8kX62nk97IqXQbc6XMc6EKFtmVYmaJDWHXgCCNdtcBU0lX67wJw4RR3KUBjU cZrAkJCmRmsONDobQVRAzBicvu3cj6U= 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-554-JmPDxycHOESEbqi20MlOkw-1; Sun, 20 Oct 2024 11:53:35 -0400 X-MC-Unique: JmPDxycHOESEbqi20MlOkw-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-37d563a1af4so1640969f8f.2 for ; Sun, 20 Oct 2024 08:53:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729439612; x=1730044412; 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=1bX8SwrawXi6wPzSE0JjFJp8yDQGRij0ZpmKsQ3vth0=; b=ms9DbI/fjmucyDY0q0ZhvnpiaTyBb+Y3zf3t0kKCd3u3ToJV2npInZzbAA2QLm9nVt PUvXT1SLpfUsKddTUYIZs8arG+S0pwe0Z7OCk8hdr2jKkYQTaWDhVsE4dIW5zl8N1zam f2HsuEB2wquMzhoy2Gux1jxskVIB8Gq0KGG2TaWWigSSE722E5wAwoUz2vpveVFaDenz z81sUvRXXuPFvCUjGmG/BEwcilstj5GqDcFIeFoxdUi3VgogRJNS9binfil43XkF+m+n OT1HMpNoL0tZrPxyrR1Qtql2ieoNgWalAf+PkOKFgHYbSSIwakV78qaCx5VZhJU8uZ3f BUuw== X-Gm-Message-State: AOJu0YyvKJMP7F6TPnXjpcjXHy27cKMTX/MG/ya6GxEnZlETnlr0Ri/E Sk4h73ig2PLDfCADxBXEs3sEozYEgOsOJASfzse3Pw+rgS8ya7YHi/EptkTJrHJKDhI8FFZcB14 xw3uCUBSwGhBTWpbl6743+9qntI5POQ1bAWI7UgsdGmd0K3sGu6KlVuNgBVkeuvtaKEciOEjjUm bhI43jSQRXDYcx3yGWL5bNEJ/kDJI9IIGlhRShsuc= X-Received: by 2002:adf:fd44:0:b0:37d:42ce:f3a5 with SMTP id ffacd0b85a97d-37ea213c624mr5061627f8f.12.1729439612529; Sun, 20 Oct 2024 08:53:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwqYrPsmtpjyII/k8kiWuM34rCyHJVYzNs4qBnQByePejJFMQGb9/059um7HV8XrTfXfghaQ== X-Received: by 2002:adf:fd44:0:b0:37d:42ce:f3a5 with SMTP id ffacd0b85a97d-37ea213c624mr5061611f8f.12.1729439612098; Sun, 20 Oct 2024 08:53:32 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37ee0a49180sm2007266f8f.39.2024.10.20.08.53.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 08:53:30 -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: Sun, 20 Oct 2024 17:53:12 +0200 Message-ID: <20241020155324.35273-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241020155324.35273-1-pbonzini@redhat.com> References: <20241020155324.35273-1-pbonzini@redhat.com> MIME-Version: 1.0 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: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.527, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 */ -static const char *cc_op_str[CC_OP_NB] = { +static const char * const cc_op_str[] = { [CC_OP_DYNAMIC] = "DYNAMIC", [CC_OP_EFLAGS] = "EFLAGS", @@ -347,7 +347,6 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, int flags) X86CPU *cpu = X86_CPU(cs); CPUX86State *env = &cpu->env; int eflags, i, nb; - char cc_op_name[32]; static const char *seg_name[6] = { "ES", "CS", "SS", "DS", "FS", "GS" }; eflags = cpu_compute_eflags(env); @@ -456,10 +455,16 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, int flags) 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 = NULL; + char cc_op_buf[32]; + + if ((unsigned)env->cc_op < ARRAY_SIZE(cc_op_str)) { + cc_op_name = cc_op_str[env->cc_op]; + } + if (cc_op_name == NULL) { + snprintf(cc_op_buf, sizeof(cc_op_buf), "[%d]", env->cc_op); + cc_op_name = cc_op_buf; + } #ifdef TARGET_X86_64 if (env->hflags & HF_CS64_MASK) { qemu_fprintf(f, "CCS=%016" PRIx64 " CCD=%016" PRIx64 " CCO=%s\n", From patchwork Sun Oct 20 15:53:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13843114 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 33207D3C92A for ; Sun, 20 Oct 2024 15:54:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2YG6-0003Wx-9s; Sun, 20 Oct 2024 11:54:22 -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 1t2YFi-0003NH-Jj for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:53:58 -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 1t2YFf-0005Pi-JF for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:53:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729439621; 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=ZG7pDim8gIa7OEsfLMhqCQMQAwzlje+SQX3YGIdJRk4=; b=fvNrf7e0pW7H/eXr1uBpVM6J+3NUDjtauXAImnZr0Sgpjulqs+RMLZJnLG0xhmLS9Ws4Fs CWTzhIscq0ALrsigDpF5BBoLcq5KPzbyBhYMDBmkb3VB583TcWMbfCHvXiQwVXVHAWZ+fy BckwSXwWH1uEQJ6g2FBGCuiT4omoJEg= 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-361-oou1QCbyPVuykxrT6N1Jpw-1; Sun, 20 Oct 2024 11:53:39 -0400 X-MC-Unique: oou1QCbyPVuykxrT6N1Jpw-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-431518e6d8fso24230505e9.0 for ; Sun, 20 Oct 2024 08:53:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729439616; x=1730044416; 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=ZG7pDim8gIa7OEsfLMhqCQMQAwzlje+SQX3YGIdJRk4=; b=NkgzXMYQL+VeziNy0pzUlaYpD1Lk1X1la4LfHHZYWrxbIQg9UVNeNcdaH3r2AQR34U MxYQ3IT5XnD+vAfTDEAmzVPytM8GgZ0uzFd5qNaJzWzH2q7zcoRnlYpQNjOXqsavJ/u4 Zdx+CJt8ec5XtAWalTBN1cfzu2Df/2cTZ5lW3zIcVIZdS1DonzWwozp4/AGHpVEProPJ rpWE5Q/YbmbWrIVJVXl+a+SwxlVzD+sGTmgHJ1GEqvoUFh88rorcYFgYUUixpzNoZcXd eg8OYOcPW2TwbV5mBUlrPQ8Ook8nXuLD/aG4UGjZd0lolBJ8NXd93EjktKQs32cVUnaV B5kQ== X-Gm-Message-State: AOJu0Yxw037bJVniwfQI/76b1D86n/i+T2JQ0Rq5U1jOJGs5a++VaNH4 PkKVbYtE+iMpVCq39pbmUnw3ElcmU81xDOVbEZx9Sjv21HdeSA8KCB1CoYNUzIwL4LydMl/5Rju QGONBY9kt6nqz3gtjbDRlkqDXV5JiH0iMBQFvUPdPbzLQatysDlXr/d50Un8ft7ucxfOSGKK/NS xeU7uVckwSHwsIf04gllhG0aUwxq1CWuPBVkxa0eY= X-Received: by 2002:a05:600c:c89:b0:431:5c1c:250b with SMTP id 5b1f17b1804b1-43161633321mr70622655e9.1.1729439616474; Sun, 20 Oct 2024 08:53:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGkachAWDb3R5jKP+xQSpQUj5WQCI4H1d2THyn09b/y6GSBk3CTXpj3MmloHeRBMBjAFFXT0g== X-Received: by 2002:a05:600c:c89:b0:431:5c1c:250b with SMTP id 5b1f17b1804b1-43161633321mr70622455e9.1.1729439615860; Sun, 20 Oct 2024 08:53:35 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f57112esm27392755e9.6.2024.10.20.08.53.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 08:53:34 -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: Sun, 20 Oct 2024 17:53:13 +0200 Message-ID: <20241020155324.35273-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241020155324.35273-1-pbonzini@redhat.com> References: <20241020155324.35273-1-pbonzini@redhat.com> MIME-Version: 1.0 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: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.527, 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=-1.699, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- 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 74886d1580f..567fefa1d7b 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1283,7 +1283,6 @@ typedef enum { CC_OP_ADCX, /* CC_DST = C, CC_SRC = rest. */ CC_OP_ADOX, /* CC_SRC2 = O, CC_SRC = rest. */ CC_OP_ADCOX, /* CC_DST = C, CC_SRC2 = O, CC_SRC = rest. */ - CC_OP_CLR, /* Z and P set, all other flags clear. */ CC_OP_MULB, /* modify all flags, C, O = (CC_SRC != 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[] = { [CC_OP_BMILGQ] = "BMILGQ", [CC_OP_POPCNT] = "POPCNT", - [CC_OP_CLR] = "CLR", }; 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, target_ulong src1, case CC_OP_EFLAGS: return src1; - case CC_OP_CLR: - return CC_Z | CC_P; case CC_OP_POPCNT: return dst ? 0 : CC_Z; @@ -243,7 +241,6 @@ target_ulong helper_cc_compute_c(target_ulong dst, target_ulong src1, case CC_OP_LOGICW: case CC_OP_LOGICL: case CC_OP_LOGICQ: - case CC_OP_CLR: case CC_OP_POPCNT: return 0; 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] = { [CC_OP_ADCX] = USES_CC_DST | USES_CC_SRC, [CC_OP_ADOX] = USES_CC_SRC | USES_CC_SRC2, [CC_OP_ADCOX] = USES_CC_DST | USES_CC_SRC | USES_CC_SRC2, - [CC_OP_CLR] = 0, [CC_OP_POPCNT] = USES_CC_DST, }; @@ -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 == CC_OP_CLR) { - tcg_gen_movi_tl(reg, CC_Z | CC_P); - return; - } dst = cpu_cc_dst; src1 = cpu_cc_src; @@ -897,7 +892,6 @@ static CCPrepare gen_prepare_eflags_c(DisasContext *s, TCGv reg) .reg2 = cpu_cc_src, .use_reg2 = true }; case CC_OP_LOGICB ... CC_OP_LOGICQ: - case CC_OP_CLR: case CC_OP_POPCNT: return (CCPrepare) { .cond = TCG_COND_NEVER }; @@ -969,7 +963,6 @@ static CCPrepare gen_prepare_eflags_s(DisasContext *s, TCGv reg) case CC_OP_ADCOX: return (CCPrepare) { .cond = TCG_COND_TSTNE, .reg = cpu_cc_src, .imm = CC_S }; - case CC_OP_CLR: case CC_OP_POPCNT: return (CCPrepare) { .cond = 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 = TCG_COND_NE, .reg = cpu_cc_src2, .no_setcond = true }; - case CC_OP_CLR: case CC_OP_POPCNT: return (CCPrepare) { .cond = 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 = TCG_COND_TSTNE, .reg = cpu_cc_src, .imm = CC_Z }; - case CC_OP_CLR: - return (CCPrepare) { .cond = TCG_COND_ALWAYS }; default: { MemOp size = (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, X86DecodedInsn *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 == CC_OP_DYNAMIC || CC_OP_HAS_EFLAGS(s->cc_op)) { /* Generate EFLAGS and replace the C bit. */ cf = 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, X86DecodedInsn *decode, TCGv src, TCGv decode->cc_dst = cpu_cc_dst; decode->cc_op = ((s->cc_op - CC_OP_MULB) & 3) + CC_OP_SARB; tcg_gen_shr_tl(decode->cc_src, src, s->T1); - break; } } @@ -4724,7 +4716,8 @@ static void gen_XOR(DisasContext *s, X86DecodedInsn *decode) decode->op[2].unit == X86_OP_INT && decode->op[1].n == decode->op[2].n) { tcg_gen_movi_tl(s->T0, 0); - decode->cc_op = CC_OP_CLR; + decode->cc_op = CC_OP_EFLAGS; + decode->cc_src = tcg_constant_tl(CC_Z | CC_P); } else { MemOp ot = decode->op[1].ot; From patchwork Sun Oct 20 15:53:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13843126 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A2BE7D3C92D for ; Sun, 20 Oct 2024 15:56:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2YG7-0003X6-4V; Sun, 20 Oct 2024 11:54: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 1t2YFh-0003NA-56 for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:53:58 -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 1t2YFf-0005Pp-JL for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:53:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729439623; 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=uPHb5ByYipPEkRTaBja/s+S6rotpUpBmTRUGPYsW6is=; b=f10Z7w5g811ee7A5Y2FMW9O1hDHfqKNwOnmYPYOq3c8ic74I8iVFUiNqE9Qq4U1DA4RIAg UoGOPPty+m86llFUVF72Og6MMXnexYg3vVP8AZnepjznBF4hSEDIsZ2GMjnVioKvzBtG2a 66BPRsf4QokgnK5S/VieMGSA3V3X9Qo= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-587-7oxP4ECDOWGrI8i5US1hrA-1; Sun, 20 Oct 2024 11:53:42 -0400 X-MC-Unique: 7oxP4ECDOWGrI8i5US1hrA-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-431673032e6so11855135e9.0 for ; Sun, 20 Oct 2024 08:53:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729439620; x=1730044420; 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=uPHb5ByYipPEkRTaBja/s+S6rotpUpBmTRUGPYsW6is=; b=j+FTXiXlRdzEFPkkvX7aJmVZ7imjoDil81mw8qzQF2mfYp3gpdJQw+KFh/eunsKA8u gA+UVo6R0hDCt6Kk0gZDbrNZCNCHMMBVRjAnl634zH12JJxg56q2p2zvhVp3Fuy2yCFW UsITmtSZtgIKo9I7CkHQDGhe/uwG4sjsMNigcu0yyMFQ+5+P3Y3mipItMQZhk6hUS3j4 i2RogH1+IlndU8ps1Y1Lxmzrznu0SJaPuOGu14ui/C5HSsEzSTMCsDkPz/frAL0DiNbT rYVO/CUbtYyxK9wA9KIbADtmYkccXrO/H3tX7/jTccBha42OXH+B89EPvIkedlOjO/an rp+g== X-Gm-Message-State: AOJu0YzLo+XUBroRPOOsvEU8o2+CGlniWWLLkem+EaXenf76ZbrrN+3n 8E7fd8COhz846AJt5KYUuSqk0LULUTYsiXRMygD/FUOImXXw/paWiy6icDv0/Cw8I5+Kgjs+KPs BdKQWOkprkuYvbOPiipOd2THJ2K89nmQ9uPo/ZmmWEOKQL39LqRs4P+HjRawo4TJJBRDRgKBsVk wa4DjzYApFZd3S5FMEJrCCg561Ck/8QueX/rJC2p4= X-Received: by 2002:a05:600c:3151:b0:431:6060:8b22 with SMTP id 5b1f17b1804b1-43161641a62mr67364205e9.10.1729439620017; Sun, 20 Oct 2024 08:53:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELz/Bg3uT/zOKKTe5KLi113M0KBal67e64hNp/KNlHYoW6Wuny6p2X/IHUjTd1m42veVQYrQ== X-Received: by 2002:a05:600c:3151:b0:431:6060:8b22 with SMTP id 5b1f17b1804b1-43161641a62mr67364125e9.10.1729439619617; Sun, 20 Oct 2024 08:53:39 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f5cb88csm27004045e9.39.2024.10.20.08.53.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 08:53:38 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PATCH 04/14] target/i386: Rearrange CCOp Date: Sun, 20 Oct 2024 17:53:14 +0200 Message-ID: <20241020155324.35273-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241020155324.35273-1-pbonzini@redhat.com> References: <20241020155324.35273-1-pbonzini@redhat.com> MIME-Version: 1.0 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: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.527, 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=-1.699, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 567fefa1d7b..f292463c34a 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1278,11 +1278,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 = flags */ - CC_OP_ADCX, /* CC_DST = C, CC_SRC = rest. */ - CC_OP_ADOX, /* CC_SRC2 = O, CC_SRC = rest. */ - CC_OP_ADCOX, /* CC_DST = C, CC_SRC2 = O, CC_SRC = rest. */ + CC_OP_EFLAGS = 0, /* all cc are explicitly computed, CC_SRC = flags */ + CC_OP_ADCX = 1, /* CC_DST = C, CC_SRC = rest. */ + CC_OP_ADOX = 2, /* CC_SRC2 = O, CC_SRC = rest. */ + CC_OP_ADCOX = 3, /* CC_DST = C, CC_SRC2 = O, CC_SRC = rest. */ CC_OP_MULB, /* modify all flags, C, O = (CC_SRC != 0) */ CC_OP_MULW, @@ -1355,9 +1354,12 @@ typedef enum { CC_OP_POPCNTQ__, CC_OP_POPCNT = sizeof(target_ulong) == 8 ? CC_OP_POPCNTQ__ : CC_OP_POPCNTL__, + CC_OP_DYNAMIC, /* must use dynamic code to get cc_op */ CC_OP_NB, } CCOp; -QEMU_BUILD_BUG_ON(CC_OP_NB >= 128); + +/* See X86DecodedInsn.cc_op, using int8_t. */ +QEMU_BUILD_BUG_ON(CC_OP_DYNAMIC > INT8_MAX); typedef struct SegmentCache { uint32_t selector; From patchwork Sun Oct 20 15:53:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13843122 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 957B5D3C92D for ; Sun, 20 Oct 2024 15:56:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2YG3-0003UF-F7; Sun, 20 Oct 2024 11:54:19 -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 1t2YFh-0003NB-Bn for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:53:58 -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 1t2YFf-0005Pt-JV for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:53:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729439627; 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=Q/DAM2YNnB8TrYcYga96JVed5cRakVoAhw2Qa5TewE0=; b=UrGKR9EHjCuC7HfmE+MDGXv3TX/BROtNR/4TPSptanNHD26Ke2wGNhLydONBz/C7X4PVvA ofjLFxISGcVeCojLFFPEFdYuoLldtZU/2XO6ATPJhYLJMEvtJunVsKi/DS96T38ar9wSEm h9C/w5SaYf9hcqDc1zq/BK70jRTEhAM= 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-410-owuzonpVNGOX4IeaXInMrQ-1; Sun, 20 Oct 2024 11:53:45 -0400 X-MC-Unique: owuzonpVNGOX4IeaXInMrQ-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-37d531a19a9so1779741f8f.1 for ; Sun, 20 Oct 2024 08:53:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729439624; x=1730044424; 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=Q/DAM2YNnB8TrYcYga96JVed5cRakVoAhw2Qa5TewE0=; b=QkjW9HCnqk9QmHhpj1SSCU4AcNlTb0W5pMtj8EpLzkImlkhVfgKlwnNAgU5d3F0XcZ PTKDAzJPgXm5C4ZmdYc6KRdhq5GQe/iP9V+Ma2q2yDhLsUNEf82RXyjQLFA339/6M3K4 asMlqAdYO1MDnm+FkvM+zePLYy9tD1NX3eN+gh3YORqLpXPp4sVPiLCjA8ki1HNxV8Z4 VOQbqFoQQVSzdtKbP/32NDKWrCv3uCKMgbXve2+XvN0/4PHe2aAk4fJb7cErNEgYnSex TqpFFqJBrSLsfgLMANI+c5Zm5be1eUCmLEu/UkcS6FvGMFTYpztWplvabJ1jKxJUxQpE GfeQ== X-Gm-Message-State: AOJu0YxR28fRdRgQPfxMd60c+NeAb9luzx0fOJnH8Q15aGWpxkPVrHDj iXuHpOAU9qgbwcSuSeZ5WpyhPpfjJMJjCANhiROJWSLutxyafeY+O0uVPevRDuEYbHLC7cz7eHZ iO9YBQBhKeMwA4pl3AINfuTI/xLsenWsG/Nuqj+q1LPwC1K7WIIYI8Z+xepN7vsge7E6KWrQkZD egy/PvRZ4vfb7G/G6rH6VdlfLUB4J9crA6cm6pc0s= X-Received: by 2002:a5d:4044:0:b0:37d:4e03:ff8e with SMTP id ffacd0b85a97d-37ea21a1f42mr6497353f8f.28.1729439623595; Sun, 20 Oct 2024 08:53:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGSlkimWyAf0WxuDWtQfYU+dvLUUA3DmGCQX6hsd1lRy/SMdmcu9yXDGPnGMcD7ebi5qQHnAQ== X-Received: by 2002:a5d:4044:0:b0:37d:4e03:ff8e with SMTP id ffacd0b85a97d-37ea21a1f42mr6497338f8f.28.1729439623070; Sun, 20 Oct 2024 08:53:43 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37ee0a37b4dsm2006033f8f.18.2024.10.20.08.53.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 08:53:41 -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: Sun, 20 Oct 2024 17:53:15 +0200 Message-ID: <20241020155324.35273-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241020155324.35273-1-pbonzini@redhat.com> References: <20241020155324.35273-1-pbonzini@redhat.com> MIME-Version: 1.0 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: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.527, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 f292463c34a..51a0a463c3e 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" @@ -1283,7 +1284,9 @@ typedef enum { CC_OP_ADOX = 2, /* CC_SRC2 = O, CC_SRC = rest. */ CC_OP_ADCOX = 3, /* CC_DST = C, CC_SRC2 = O, CC_SRC = rest. */ - CC_OP_MULB, /* modify all flags, C, O = (CC_SRC != 0) */ + /* Low 2 bits = MemOp constant for the size */ +#define CC_OP_FIRST_BWLQ CC_OP_MULB + CC_OP_MULB = 4, /* modify all flags, C, O = (CC_SRC != 0) */ CC_OP_MULW, CC_OP_MULL, CC_OP_MULQ, @@ -1353,6 +1356,7 @@ typedef enum { CC_OP_POPCNTL__, CC_OP_POPCNTQ__, CC_OP_POPCNT = sizeof(target_ulong) == 8 ? CC_OP_POPCNTQ__ : CC_OP_POPCNTL__, +#define CC_OP_LAST_BWLQ CC_OP_POPCNTQ__ CC_OP_DYNAMIC, /* must use dynamic code to get cc_op */ CC_OP_NB, @@ -1361,6 +1365,17 @@ typedef enum { /* See X86DecodedInsn.cc_op, using int8_t. */ QEMU_BUILD_BUG_ON(CC_OP_DYNAMIC > INT8_MAX); +static inline MemOp cc_op_size(CCOp op) +{ + MemOp size = op & 3; + + QEMU_BUILD_BUG_ON(CC_OP_FIRST_BWLQ & 3); + assert(op >= CC_OP_FIRST_BWLQ && op <= CC_OP_LAST_BWLQ); + assert(size <= 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) case CC_OP_ADDB ... CC_OP_ADDQ: /* (DATA_TYPE)CC_DST < (DATA_TYPE)CC_SRC */ - size = s->cc_op - CC_OP_ADDB; + size = 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 = TCG_COND_LTU, .reg = cpu_cc_dst, @@ -902,7 +902,7 @@ static CCPrepare gen_prepare_eflags_c(DisasContext *s, TCGv reg) case CC_OP_SHLB ... CC_OP_SHLQ: /* (CC_SRC >> (DATA_BITS - 1)) & 1 */ - size = s->cc_op - CC_OP_SHLB; + size = cc_op_size(s->cc_op); return gen_prepare_sign_nz(cpu_cc_src, size); case CC_OP_MULB ... CC_OP_MULQ: @@ -910,11 +910,11 @@ static CCPrepare gen_prepare_eflags_c(DisasContext *s, TCGv reg) .reg = cpu_cc_src }; case CC_OP_BMILGB ... CC_OP_BMILGQ: - size = s->cc_op - CC_OP_BMILGB; + size = cc_op_size(s->cc_op); return gen_prepare_val_nz(cpu_cc_src, size, true); case CC_OP_BLSIB ... CC_OP_BLSIQ: - size = s->cc_op - CC_OP_BLSIB; + size = cc_op_size(s->cc_op); return gen_prepare_val_nz(cpu_cc_src, size, false); 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 = TCG_COND_NEVER }; default: - { - MemOp size = (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)); } } @@ -1007,7 +1004,7 @@ static CCPrepare gen_prepare_eflags_z(DisasContext *s, TCGv reg) .imm = CC_Z }; default: { - MemOp size = (s->cc_op - CC_OP_ADDB) & 3; + MemOp size = 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 = s->cc_op - CC_OP_SUBB; + size = 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, X86DecodedInsn *decode, TCGv src, TCGv */ decode->cc_src = tcg_temp_new(); decode->cc_dst = cpu_cc_dst; - decode->cc_op = ((s->cc_op - CC_OP_MULB) & 3) + CC_OP_SARB; + decode->cc_op = 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, X86DecodedInsn *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 == 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 = cc_op_size(s->cc_op); + tcg_gen_shri_tl(decode->cc_dst, cpu_cc_src, (8 << size) - 1); got_cf = true; } gen_mov_eflags(s, decode->cc_src); From patchwork Sun Oct 20 15:53:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13843119 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2AC54D3C92D for ; Sun, 20 Oct 2024 15:55:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2YG0-0003PU-RF; Sun, 20 Oct 2024 11:54:17 -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 1t2YFi-0003NG-Is for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:54:00 -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 1t2YFf-0005Px-JV for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:53:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729439630; 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=q6Atrid02n+aIsNXR6t6jfxIFvTGj0hOmgcUWqfqLMk=; b=R48dcR+zNcMTFoSKZwbacSrF4z99SsHYa624AQLhvOT4NSPg2ml81ztyiiGW11U/8cfp90 kcjqHK3gH+sRBcoRpQzzKNyM8D8Hauemi2DYrwKZx1C4uFExrv+mRTnBE3EKaJEpa30zbQ FZXZIMggomy6+MMHhMUcOOhKdExU+b4= 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-489-IKDbB3trP5SmisM5HEI-DQ-1; Sun, 20 Oct 2024 11:53:48 -0400 X-MC-Unique: IKDbB3trP5SmisM5HEI-DQ-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-37d4af408dcso2107523f8f.0 for ; Sun, 20 Oct 2024 08:53:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729439627; x=1730044427; 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=q6Atrid02n+aIsNXR6t6jfxIFvTGj0hOmgcUWqfqLMk=; b=RV3p6wj9XokdHcNAXdLFgtVxRYpHq1x5Fhi8NIVDpzezV+hjM/qniX39AiapLxLi6i SJuVltSu89UFNZOYtFw673Wiuw+sAgfkkDw4uKw3gncO6hwkyA/ZFuaWgLeITqAb3qTD 50EDC0MJB0AIfr/dntJcPqbX/ZMKJHnbOgVhIJ/fCt18O9oFsk07xdfOTQF/y3MaGpIC wxOrAWdXU9IpN8PHkqROv0XoQWqDh8JqspVjmWVWmopPrQyMUTb3COOm3bGB+IybrlVx aPODk+kj4QlO2g7Ul3Hbe57fuFp5z+2Btv+q/Pt/8b5Cf78/gzY7hZ3+Wnl6yJaD3Enb l9Rw== X-Gm-Message-State: AOJu0YxblMh7wUGq+Yu0bScdoAC3P7oXQv8APHVhnf7cNR6pPbYuhFqF TgDljaVf206Zvrj/i30sWW077fzhmgp7wAPPB11YhZvPW0dSmuGm1jyyhokIlLdHD7dkrPbcn8a E48B5tuCf2MdZh30vfT3OrvcmwqjlCtKSnqye+c5hZ1xWyt2YqZZ4Ps2rNrC8hhSIJwcakmwUiY stZlemQGGkj53nWKZ7WuhZNjiyJ3Kn1Vmu/GECBhc= X-Received: by 2002:adf:ef50:0:b0:37d:54a0:d0a1 with SMTP id ffacd0b85a97d-37eb4897a21mr5463496f8f.56.1729439627042; Sun, 20 Oct 2024 08:53:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFdXgQVtZjWgZ1/6Oo7v50h3P7ADnBe8k6t47/08C9J21SiCJ7id0EwSU+7F2ILL15ST/86bg== X-Received: by 2002:adf:ef50:0:b0:37d:54a0:d0a1 with SMTP id ffacd0b85a97d-37eb4897a21mr5463486f8f.56.1729439626540; Sun, 20 Oct 2024 08:53:46 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37ee095bec2sm2040612f8f.0.2024.10.20.08.53.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 08:53:44 -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: Sun, 20 Oct 2024 17:53:16 +0200 Message-ID: <20241020155324.35273-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241020155324.35273-1-pbonzini@redhat.com> References: <20241020155324.35273-1-pbonzini@redhat.com> MIME-Version: 1.0 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: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.527, 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=-1.699, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Richard Henderson Assert that op is known and that cc_op_live_ is populated. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- 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 51a0a463c3e..782e329c15c 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1359,7 +1359,6 @@ typedef enum { #define CC_OP_LAST_BWLQ CC_OP_POPCNTQ__ CC_OP_DYNAMIC, /* must use dynamic code to get cc_op */ - CC_OP_NB, } CCOp; /* 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 { }; /* Bit set if the global variable is live after setting CC_OP to X. */ -static const uint8_t cc_op_live[CC_OP_NB] = { +static const uint8_t cc_op_live_[] = { [CC_OP_DYNAMIC] = USES_CC_DST | USES_CC_SRC | USES_CC_SRC2, [CC_OP_EFLAGS] = USES_CC_SRC, [CC_OP_MULB ... CC_OP_MULQ] = USES_CC_DST | USES_CC_SRC, @@ -312,6 +312,21 @@ static const uint8_t cc_op_live[CC_OP_NB] = { [CC_OP_POPCNT] = USES_CC_DST, }; +static uint8_t cc_op_live(CCOp op) +{ + uint8_t result; + assert(op >= 0 && op < ARRAY_SIZE(cc_op_live_)); + + /* + * Check that the array is fully populated. A zero entry would correspond + * to a fixed value of EFLAGS, which can be obtained with CC_OP_EFLAGS + * as well. + */ + result = 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) } /* Discard CC computation that will no longer be used. */ - dead = cc_op_live[s->cc_op] & ~cc_op_live[op]; + dead = 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 = cpu_cc_src2; /* Take care to not read values that are not live. */ - live = cc_op_live[s->cc_op] & ~USES_CC_SRCT; + live = cc_op_live(s->cc_op) & ~USES_CC_SRCT; dead = live ^ (USES_CC_DST | USES_CC_SRC | USES_CC_SRC2); if (dead) { TCGv zero = tcg_constant_tl(0); diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc index 1f193716468..ee2a508ae9a 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 = cc_op_live[decode.cc_op]; + cc_live = cc_op_live(decode.cc_op); } else { cc_live = 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 = tcg_temp_new_i32(); assert(decode->cc_dst == 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 = tcg_temp_new(); tcg_gen_movcond_tl(TCG_COND_EQ, decode->cc_dst, count, tcg_constant_tl(0), cpu_cc_dst, s->T0); } - 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_constant_tl(0), cpu_cc_src, decode->cc_src); } From patchwork Sun Oct 20 15:53:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13843116 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CFCC9D3C92A for ; Sun, 20 Oct 2024 15:54:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2YFz-0003Om-OI; Sun, 20 Oct 2024 11:54: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 1t2YFi-0003NF-FZ for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:53:58 -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 1t2YFf-0005Q1-Jn for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:53:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729439633; 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=u4PvFEk58IPsCXTEM1w79SZ0J2i929/FJcA19Ybp0Gg=; b=R0aOo5uYsLF/EWpWZFxUvgbS90PqPOHaF1ATXdIvXyelCDNWBQHg/1at5/4S3ffqjXj53g ZMP/KIPfU/du9gCx3+Bx0X9HeZ1aBrmVpaOZ9Bd8LqYVCoiPSr2PWTagS3M7ebaCK8mpyG zpmnJ8l42JKLbpU1YddXjN6eGBW7TW8= 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-648-ASvykA80PHiJO2dxNZ3tfA-1; Sun, 20 Oct 2024 11:53:52 -0400 X-MC-Unique: ASvykA80PHiJO2dxNZ3tfA-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-37d43e7acd9so1935942f8f.2 for ; Sun, 20 Oct 2024 08:53:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729439630; x=1730044430; 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=u4PvFEk58IPsCXTEM1w79SZ0J2i929/FJcA19Ybp0Gg=; b=JhTJJJfFCq/d3TQIgqRCpTfDPHy7LBedaJDVaCwIgUDj3SYQzmQk/9wawiKu3wZene KBlipgo27Z3RKQ+IIysGQrliwwSYshcdeY1bnnMM/vLr07Z3Uex73Kl2fyYmHDIw+VS6 ysXqiMSjjg3PhMgaGBBYlgsVfm6+7Nu6qZXFkNHf6KhuJro3IsIgL0PiI6CeoBs3u9UQ ZwIjGWk595ncx6aMi5rnNMfl+RlBCMnxr4GRFeLK+BnF8uJijEei9I0QBWEnVJu83YFx o/b/+WY8vhTWRdWgWoqgMamH+hjCZircFbi0DoPPki8QVhdBFDM8aVH5ivVFo0/W5n95 ltRA== X-Gm-Message-State: AOJu0YxTXWo2DDmMOmrvuG4WnN3AyvpKIGvkK4uGWWJ9nDBiZkaUFFFh oujKJB7Sf8/Bzt9DizhcsSibQqiaw5ymih4wQ9eS1kIF21tyuQc5vQaqPL/E51mIOEbQWoE4E0w ARe8OGlg4QdJmGw/O9cv/U2q2EbtuKZLcTC2WvtaAkZC+CGvfoeVwi8HwXIgqnvzkupN9yDGuLh XGvMI5VCwec/ALxsgO3SK93ipmsyUlrO66ePFBllI= X-Received: by 2002:adf:9bce:0:b0:374:c3e4:d6de with SMTP id ffacd0b85a97d-37eb47693ebmr5568572f8f.41.1729439630471; Sun, 20 Oct 2024 08:53:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYs5PhMmHMVurLaUGvUD3qQLkrgINiHMsLxe/lrIiMjEMIN9exT2J2RBGEAZcGZ9RUH5GKZg== X-Received: by 2002:adf:9bce:0:b0:374:c3e4:d6de with SMTP id ffacd0b85a97d-37eb47693ebmr5568560f8f.41.1729439629969; Sun, 20 Oct 2024 08:53:49 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37ee0b9bb66sm1979910f8f.95.2024.10.20.08.53.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 08:53:48 -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: Sun, 20 Oct 2024 17:53:17 +0200 Message-ID: <20241020155324.35273-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241020155324.35273-1-pbonzini@redhat.com> References: <20241020155324.35273-1-pbonzini@redhat.com> MIME-Version: 1.0 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: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.527, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 --- target/i386/helper.h | 1 + target/i386/tcg/cc_helper.c | 20 ++++++++++++++++++++ target/i386/tcg/translate.c | 10 +++++++--- 3 files changed, 28 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) 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..c24e6a14c07 100644 --- a/target/i386/tcg/cc_helper.c +++ b/target/i386/tcg/cc_helper.c @@ -95,6 +95,26 @@ static target_ulong compute_all_adcox(target_ulong dst, target_ulong src1, return (src1 & ~(CC_C | CC_O)) | (dst * CC_C) | (src2 * CC_O); } +target_ulong helper_cc_compute_nz(target_ulong dst, target_ulong src1, + int op) +{ + target_ulong mask; + + if (CC_OP_HAS_EFLAGS(op)) { + return ~src1 & CC_Z; + } else { + MemOp size = cc_op_size(op); + + if (size == MO_TL) { + /* Avoid shift count overflow when computing the mask below. */ + return dst; + } + + mask = (1ull << (8 << size)) - 1; + 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 = TCG_COND_TSTNE, .reg = cpu_cc_src, .imm = CC_Z }; + case CC_OP_DYNAMIC: + gen_update_cc_op(s); + if (!reg) { + reg = tcg_temp_new(); + } + gen_helper_cc_compute_nz(reg, cpu_cc_dst, cpu_cc_src, cpu_cc_op); + return (CCPrepare) { .cond = TCG_COND_EQ, .reg = reg, .imm = 0 }; default: { MemOp size = cc_op_size(s->cc_op); From patchwork Sun Oct 20 15:53:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13843120 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 27887D3C92D for ; Sun, 20 Oct 2024 15:55:58 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2YG8-0003aT-VM; Sun, 20 Oct 2024 11:54:24 -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 1t2YFo-0003OC-Gn for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:54:09 -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 1t2YFi-0005QQ-CA for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:53:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729439637; 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=26EBxQ0Z85mnaPKsgMajhtGRoo57YJy8Zn6ojuxhHvM=; b=W/yVPBohzJozaXZJ7flZOewXrrgQYdMAsBWBKJY9qrYlHx1ZmYHc/bOThyOUuj8Ifgdzb8 2u8DtGP7Q4MGazdpzA2FA3us0mfdvvZWJL5NvVr4hxPom9UQgPrgXYpv1mR5dxsqNiiDz+ kgeOwSuVg1lZ1Kr/hrQNMXYGsAOKnIk= 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-584-BpIugzauNIWOqXyVlppEaA-1; Sun, 20 Oct 2024 11:53:56 -0400 X-MC-Unique: BpIugzauNIWOqXyVlppEaA-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-43163a40ee0so16819625e9.0 for ; Sun, 20 Oct 2024 08:53:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729439634; x=1730044434; 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=26EBxQ0Z85mnaPKsgMajhtGRoo57YJy8Zn6ojuxhHvM=; b=j1p2JSe6heJ1pEl+wfEpdIhFpxOx7tCIESxxyplJ6Mn0PGcvg6giZTNHgS3bXjOgtB XsmDENKqjjsJIqa1w9K2wEIV2/Iv2PN7R6UngyPOth2i1+2UTUiCiBUD6HV4pMFek7Az jdGcgpFoRE0fCuEIMy7ZC0ctlQqHxtAq8tMLiQaKxBNWf/MqdJ9lMnyxUJn2ujqfTr1r qUPMatB35ewnV2jOVSDmetdFXnS3FUL2m53x7DpC7+QEokNu1vrq2gCkMk0gIt/BCArL QTjtvNdEjdfZA79PGWBIzd4WRfZUHTPWlYmB/eDSGoAk2mD2K+R1xyFxocU6FC1hqomU oWlw== X-Gm-Message-State: AOJu0YzrQ1BDy2++GWRtTiIVGSUvfzzYtmh22xIxqwtnkveEQYZ/5PXt 9q/N9cyFc3gi8TMZMRvaitDmY0P6GyGEM50fj4t/1oqtM1YQBVYiGMJ2w/2X5PXRWgSbrjMUSGf wHdv1l0H4fjTItGrKFU3ObhJiYQpK2WRpvnDCrxYAm1v07E6Dte+L26ZkaUmyUk3KYm/YKL3RCM l4hqS6jgxy1puEglYOOrXQaKCXdi5jyWORmrM2kDc= X-Received: by 2002:a05:600c:4f16:b0:430:52ec:1e2b with SMTP id 5b1f17b1804b1-431616a0a01mr69858275e9.29.1729439634045; Sun, 20 Oct 2024 08:53:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFnxG1tmyJImvSSC3JcG7HxZykM4C6BBR8/ekYkE3UJHObp0k3zoLKei6RCPgoDHckFwaDx8A== X-Received: by 2002:a05:600c:4f16:b0:430:52ec:1e2b with SMTP id 5b1f17b1804b1-431616a0a01mr69858135e9.29.1729439633551; Sun, 20 Oct 2024 08:53:53 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f57bc1dsm27167725e9.11.2024.10.20.08.53.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 08:53:51 -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: Sun, 20 Oct 2024 17:53:18 +0200 Message-ID: <20241020155324.35273-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241020155324.35273-1-pbonzini@redhat.com> References: <20241020155324.35273-1-pbonzini@redhat.com> MIME-Version: 1.0 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: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.527, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- 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; + case CC_OP_LOGICB ... CC_OP_LOGICQ: + /* Mostly used for test+jump */ + size = s->cc_op - CC_OP_LOGICB; + switch (jcc_op) { + case JCC_BE: + /* CF = 0, becomes jz/je */ + jcc_op = JCC_Z; + goto slow_jcc; + case JCC_L: + /* OF = 0, becomes js/jns */ + jcc_op = JCC_S; + goto slow_jcc; + case JCC_LE: + /* SF or ZF, becomes signed <= 0 */ + tcg_gen_ext_tl(cpu_cc_dst, cpu_cc_dst, size | MO_SIGN); + cc = (CCPrepare) { .cond = TCG_COND_LE, .reg = cpu_cc_dst }; + break; + default: + goto slow_jcc; + } + break; + default: slow_jcc: /* This actually generates good code for JC, JZ and JS. */ From patchwork Sun Oct 20 15:53:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13843124 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 865E3D3C92A for ; Sun, 20 Oct 2024 15:56:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2YG8-0003Yf-9Z; Sun, 20 Oct 2024 11:54:24 -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 1t2YFp-0003OE-Kv for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:54: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 1t2YFo-0005Qp-9J for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:54:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729439643; 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=XpF+XZQI4Pde12kaWW1aCvqAcg4Fwt6yZrI1Joisxg4=; b=gWBSXxr1VMN4c+3stP/WxKAiXpJ/3/B5FxIKCMnXJQWlsf5DQ7z+w8ERzOa11ulNW16196 rOcoalY7aosbk4THK76WLErpFxCQxCMWyjm+2/hpz9e4dlfpfPayXXe0UeS15sDjQlhqVy J7ji5x7goX6mS7vApXs/4aKf9VtPq3Y= 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-43-iwtDBgByN0KxoIDBhqrQRw-1; Sun, 20 Oct 2024 11:54:00 -0400 X-MC-Unique: iwtDBgByN0KxoIDBhqrQRw-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-37d5a3afa84so1859772f8f.3 for ; Sun, 20 Oct 2024 08:54:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729439637; x=1730044437; 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=XpF+XZQI4Pde12kaWW1aCvqAcg4Fwt6yZrI1Joisxg4=; b=G8VC+kog5E+tz6dULMzvCaz3YLi/5kxYQBmah4Edfb8PxdPv6ywtQMA2SCHYsP/6NM Nva5f8dnO8AUq6Hn9DIFE03OQSZZ49ItSt6svQOonEpLGtiRKKZUCVKMJ/9k+67l7sPt MRJ7kEG6vnvA9NavJX7p92IMPMWOFlrsb2DgNM74laEk+3OG9jhD7RnVxXHpFiQpGQrB JXHzv/c0Op+7TOViFZXRDKUJEYqIBeznB9Mx0vGNdCdVu0bezpcqwD8UvT3pRxQV2Mhu /vZfSP/VO+EVJnfbtkSVJTMlu/dsfCh/IldVrAyUQiPX/0GID/SdeDRmmJQkLPJIcEPt halA== X-Gm-Message-State: AOJu0Yzy5LzTpPYher/9Iz632udg0WpUijztBiOiQvv7y38IzUJM2BBw rBJb0LEFBFWL/IHmQWPOQy/kqIXTzUwZVd2FickNYoE5ZR6bGqg7N9fVaxkPIGImQDP3p8XlnL/ CcFQKdE4XiRkhXqrZW+gbwLRLj0cQej/weBUMT3qcwF6c6szXSWMJAqcTxBEF5OZgjh8rZu5M4i K3GPWy0S58Lhqcdi6yVOz886hkyckqSVL07A/yWdA= X-Received: by 2002:a5d:6d89:0:b0:37d:5429:9004 with SMTP id ffacd0b85a97d-37ea2137362mr6584622f8f.3.1729439637485; Sun, 20 Oct 2024 08:53:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQiLcp+sMriC3fEshp7X9Kj1/ATuY9OiLmqLwg1xi+1eM94iYTYOUUxkZxo3WBvy5TELIP4w== X-Received: by 2002:a5d:6d89:0:b0:37d:5429:9004 with SMTP id ffacd0b85a97d-37ea2137362mr6584611f8f.3.1729439637101; Sun, 20 Oct 2024 08:53:57 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37ee0a57e0fsm2006002f8f.47.2024.10.20.08.53.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 08:53:55 -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: Sun, 20 Oct 2024 17:53:19 +0200 Message-ID: <20241020155324.35273-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241020155324.35273-1-pbonzini@redhat.com> References: <20241020155324.35273-1-pbonzini@redhat.com> MIME-Version: 1.0 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: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.527, 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=-1.699, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- 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 = TCG_COND_NE, .reg = cpu_cc_src2, .no_setcond = true }; + case CC_OP_LOGICB ... CC_OP_LOGICQ: case CC_OP_POPCNT: return (CCPrepare) { .cond = 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 = TCG_COND_EQ, .reg = reg, .imm = 0 }; + case CC_OP_POPCNT: + return (CCPrepare) { .cond = TCG_COND_EQ, .reg = cpu_cc_dst }; default: { MemOp size = cc_op_size(s->cc_op); From patchwork Sun Oct 20 15:53:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13843123 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DDE7ED3C92D for ; Sun, 20 Oct 2024 15:56:24 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2YG3-0003UD-F6; Sun, 20 Oct 2024 11:54:19 -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 1t2YFq-0003OG-Do for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:54:12 -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 1t2YFp-0005R7-5h for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:54:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729439644; 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=r2SU/h69yvxkJM5HdDexHlLR1QA6w8NK8C4Te2utDtM=; b=bOIba5ih6rqaeb1vAddwjO9ITyyD8fer5mXP4hARSprabNofVTcitwo/HgaCxxSRm7Leyw xIJHwHqnsyrDznqhq0ctA97BOZXSRNB6RTo2FSPkhhlNbEKfLkymb3w/5pjw+pfQ/YUNtJ 6tZGMJdjWer8aEOV0tlGPUAgx7/NKH0= 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-569-IzSPgvz6Ocy5WsAkplPnOw-1; Sun, 20 Oct 2024 11:54:03 -0400 X-MC-Unique: IzSPgvz6Ocy5WsAkplPnOw-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4316ac69e6dso8108005e9.0 for ; Sun, 20 Oct 2024 08:54:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729439641; x=1730044441; 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=r2SU/h69yvxkJM5HdDexHlLR1QA6w8NK8C4Te2utDtM=; b=PEMOKpZ/zMuFq3U3L2cfqyndenS/Ao7isRjKZy12EMttTo1oJybC2qABGeeuXLknBK MyQE6btSK6jjZ5xbrvf9M7U6n0sqt/fX2os0Hj+r+dj3IdZLaBX75Qa7nHqNiVzZku1m F3HvbvaYErsW+nOwI+S9vNdOatc+u+f/lEejYsCIlNKCP9wulTI/xtG20B8ltBD3G6Y7 XAGdWrE3LaSVuV5AQrpuwJJQwpNFkur60xCujyetsaEfXQFIvm0E5ttQ/z2Au2ey7baM 4lXYbAsy1T9QA0ak8s8rW0D656emhv8zG7WUja6VJLXgoVNxpiVZvxyDgdunE8reELMZ RZKQ== X-Gm-Message-State: AOJu0YxVx98SQoWt7ADpvEDdUFgWBRqDyfelNdf8GCqtDgk6oWPt8w4w QK9CBX4A2FW0pRN8G4AoznLIBbLTD1E/fBWH9NIEOm52qToJGj/3ynKCRgsJSV3asx5fLnOr/xb tatFTd0heB1HT1l1EYCv4ODZZaXGkE4FI6WTqrgelOSL1cGYPG4CsTC3HYiwKth4ewZ18s8V5wL m6MYaiLv8bE8w2beRbzooklQ2BnKR7A7l98I27epc= X-Received: by 2002:a05:600c:1c81:b0:42c:cd88:d0f4 with SMTP id 5b1f17b1804b1-43161687d53mr60849415e9.22.1729439641251; Sun, 20 Oct 2024 08:54:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEhLA2VvGCtJbTdIYWN4PTBA2eWRFA6d81knpIiAZGXX/06Tpteutg42Tb2GKV2+bTWdXwz3w== X-Received: by 2002:a05:600c:1c81:b0:42c:cd88:d0f4 with SMTP id 5b1f17b1804b1-43161687d53mr60849305e9.22.1729439640812; Sun, 20 Oct 2024 08:54:00 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37ee0a37935sm2016639f8f.17.2024.10.20.08.53.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 08:53:58 -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: Sun, 20 Oct 2024 17:53:20 +0200 Message-ID: <20241020155324.35273-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241020155324.35273-1-pbonzini@redhat.com> References: <20241020155324.35273-1-pbonzini@redhat.com> MIME-Version: 1.0 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: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.527, 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=-1.699, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Paolo Bonzini --- 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 = gen_prepare_cc(s, b, NULL); + /* + * 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); From patchwork Sun Oct 20 15:53:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13843125 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B29CDD3C92D for ; Sun, 20 Oct 2024 15:56:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2YG8-0003Yy-BA; Sun, 20 Oct 2024 11:54:24 -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 1t2YFv-0003Og-5U for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:54:13 -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 1t2YFt-0005RP-IY for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:54:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729439648; 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=4Y3jIf+hNsv83+CZvNpXB3wyuIaNSzogNsVqhzqQ8Ds=; b=AukYdtJNuQ9iuhYSG8bmWVWGJ+pvsik8iJoV9F6S8etEUF7r9XJjsNF6wFFjdXxQTuweer OHCbojvzoEvuokeM1SJyfA+PCdLaoFWbVrRFAzWI1tdGhIfOST+c6m7vl9rQg11fanAkwY 9GEufwV/R1pjO1z3UaYzCthUua92xyE= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-616--qU1qUC3M02z0-1p_ANPfQ-1; Sun, 20 Oct 2024 11:54:06 -0400 X-MC-Unique: -qU1qUC3M02z0-1p_ANPfQ-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4314f1e0f2bso24168815e9.1 for ; Sun, 20 Oct 2024 08:54:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729439644; x=1730044444; 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=4Y3jIf+hNsv83+CZvNpXB3wyuIaNSzogNsVqhzqQ8Ds=; b=qwx2KIHHocpjFFGlMHhCk05isY29dsp6TM1wIetYHQCav9jAfCdMj0azuyVAtHFmtU /dsIM3hx0YQGeFEIkolZFzXVDG0rJSrZkQOm0ZLXAGWmQ/7SOm6xrRC2K6CgDeLuZ3Xu cuRSRC0OxGzm1/3QQJG0EVqNJEutwhgRU/GAHoy2l+RhdP61Bmnlc9ySkzHWCA691LtT KaTNeB5NWBz5vI4kphUxEWUO6EBvxPM3kAhShAJB9XjhrjTqcWUItj+AQBiGhHeKoPbj SUOt5bt0IR4LvWquySDCmaKdUp9hYKOPJViFB2NOHlNWBdd8J0VMdvH0wW73vLKTQzvN AqYQ== X-Gm-Message-State: AOJu0YwUg5qS0sAdVwZr0DA83A6d6Gc37lMcKnjXrh9+jPeoUet0OXer gwGpwWQ3izNJQSLHwMEFybNh98hqgBWXc+1mkfiUvaXCnrX2j7Ut240hzNQwYiaIc1vVsG/3Pn/ k3UcoDxfEeE24ln3RFzaWwZaku7Urnz3X7k0ABKMkBEb8ztcR4m7swn9ET76pi4oZXKnoco2Gx2 MHpN9C1ruYwrWna86i6gff93mVEbFAi4HSU0a1FPE= X-Received: by 2002:a05:600c:3515:b0:431:52cc:877e with SMTP id 5b1f17b1804b1-43161669459mr62972175e9.20.1729439644128; Sun, 20 Oct 2024 08:54:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHl9HP4jF8dlq2watXhhYZPnTthlZUbKePtZPVtbKHquGlD65AVe8wG7zlMUWxyMcL8PxISuA== X-Received: by 2002:a05:600c:3515:b0:431:52cc:877e with SMTP id 5b1f17b1804b1-43161669459mr62972045e9.20.1729439643658; Sun, 20 Oct 2024 08:54:03 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f570f7esm27171185e9.10.2024.10.20.08.54.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 08:54:03 -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: Sun, 20 Oct 2024 17:53:21 +0200 Message-ID: <20241020155324.35273-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241020155324.35273-1-pbonzini@redhat.com> References: <20241020155324.35273-1-pbonzini@redhat.com> MIME-Version: 1.0 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: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.527, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This makes it easier for the compiler to understand the bits that are set, and removes "cltq" instructions to canonicalize the output value as 32-bit signed. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- 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 @@ /* dynamic flags computation */ -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 src1) { - int cf, pf, af, zf, sf, of; + uint32_t cf, pf, af, zf, sf, of; DATA_TYPE src2 = dst - src1; cf = dst < src1; @@ -58,10 +58,10 @@ static int glue(compute_c_add, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) return dst < src1; } -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 src1, DATA_TYPE src3) { - int cf, pf, af, zf, sf, of; + uint32_t cf, pf, af, zf, sf, of; DATA_TYPE src2 = dst - src1 - src3; cf = (src3 ? dst <= src1 : dst < src1); @@ -79,9 +79,9 @@ static int glue(compute_c_adc, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1, return src3 ? dst <= src1 : dst < src1; } -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 src2) { - int cf, pf, af, zf, sf, of; + uint32_t cf, pf, af, zf, sf, of; DATA_TYPE src1 = dst + src2; cf = src1 < src2; @@ -100,10 +100,10 @@ static int glue(compute_c_sub, SUFFIX)(DATA_TYPE dst, DATA_TYPE src2) return src1 < src2; } -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 src2, DATA_TYPE src3) { - int cf, pf, af, zf, sf, of; + uint32_t cf, pf, af, zf, sf, of; DATA_TYPE src1 = dst + src2 + src3; cf = (src3 ? src1 <= src2 : src1 < src2); @@ -123,9 +123,9 @@ static int glue(compute_c_sbb, SUFFIX)(DATA_TYPE dst, DATA_TYPE src2, return (src3 ? src1 <= src2 : src1 < src2); } -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 src1) { - int cf, pf, af, zf, sf, of; + uint32_t cf, pf, af, zf, sf, of; cf = 0; pf = parity_table[(uint8_t)dst]; @@ -136,9 +136,9 @@ static int glue(compute_all_logic, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) return cf | pf | af | zf | sf | of; } -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 src1) { - int cf, pf, af, zf, sf, of; + uint32_t cf, pf, af, zf, sf, of; DATA_TYPE src2; cf = 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; } -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 src1) { - int cf, pf, af, zf, sf, of; + uint32_t cf, pf, af, zf, sf, of; DATA_TYPE src2; cf = 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; } -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 src1) { - int cf, pf, af, zf, sf, of; + uint32_t cf, pf, af, zf, sf, of; cf = (src1 >> (DATA_BITS - 1)) & CC_C; pf = parity_table[(uint8_t)dst]; @@ -187,9 +187,9 @@ static int glue(compute_c_shl, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) return (src1 >> (DATA_BITS - 1)) & CC_C; } -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 src1) { - int cf, pf, af, zf, sf, of; + uint32_t cf, pf, af, zf, sf, of; cf = src1 & 1; pf = 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 src1) { - int cf, pf, af, zf, sf, of; + uint32_t cf, pf, af, zf, sf, of; cf = (src1 != 0); pf = 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; } -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 src1) { - int cf, pf, af, zf, sf, of; + uint32_t cf, pf, af, zf, sf, of; cf = (src1 == 0); pf = 0; /* undefined */ @@ -237,7 +237,7 @@ static int glue(compute_c_bmilg, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) 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; cf = (src1 != 0); pf = 0; /* undefined */ From patchwork Sun Oct 20 15:53:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13843118 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 782BED3C92A for ; Sun, 20 Oct 2024 15:55:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2YGC-0003hf-A0; Sun, 20 Oct 2024 11:54:28 -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 1t2YFx-0003On-GG for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:54:15 -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 1t2YFv-0005RX-QO for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:54:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729439650; 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=puHKtdYSByTzsLL6YmkC2GAWqDoPkcpbu5iM6Kyqj54=; b=Nz4zIPC0TyS8ncIS9x09uzaEf+MG2HH30lHFSPendb/mxhnzCTeZXI+mfAnSiOaJB3LPiI 6rbjg5J5+7S8w+pEA713m5jVeysPEM3stwvQp4suVaXw5t/1gxLExP4lkx7jr02LMk/nlQ 00z7wBj6nB/hhCf2WJShrOn3s5g1YGo= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-656-e8e5t7HwPCu7KjFE2Xh9wA-1; Sun, 20 Oct 2024 11:54:09 -0400 X-MC-Unique: e8e5t7HwPCu7KjFE2Xh9wA-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-431518ae047so22293275e9.0 for ; Sun, 20 Oct 2024 08:54:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729439647; x=1730044447; 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=puHKtdYSByTzsLL6YmkC2GAWqDoPkcpbu5iM6Kyqj54=; b=ROPcz4MzLLLyoFq8PQQW/ARmUWp1YKUTYwNaiNbQum8S6l0p3eo6aN2YaKsb73/alw IYfCfy2efZd+tuyBdNb4yIiWdJnyEm1Wh/aEiv9BbEMk6qCwjpR0ebTEjkYQw3XU/EU2 vCLB1khdxAjkjvL2lm0jEV3uPbUdEbkM+Oc1SKoQGMrAnCxTq2hjkWr7YwI5x8XcqtBH Ua3L6doyA37fjonVfHZPy75DZQFlKLmhVOCwqBcCG0lb+GicrVFN3wJeR5t+5PaoIOXM R6ey+Wad3QrybhSEREZRXQ26kMHpjPvYRJ9OSthIqzRlot3/BrhnNjo8iuZwA80ykL9p cKfg== X-Gm-Message-State: AOJu0YwSLVPWRl9TPIBt69cYpawW2/6b613mA5x5sKfljCPjhpXfSp9u WqevpGQ8I8wBhqmC4BJ/ylBvj3RtvbhuLfWgRID60gwM545L0ASjRaIZaJUk3oN7mUL0ifMTrJr UFO3+ZG8giRO2e/CwsQQns1WB3Ak5YS9/qrUGT7GYQC5XV51lhWIld5GEa7PhWvSp7h2jue+mPp 7Jj5ytTynuDscFWcEbsZLNJVRh4dg+jpd1L+Pg2DE= X-Received: by 2002:a05:600c:511c:b0:430:56f5:4d1f with SMTP id 5b1f17b1804b1-431586fc549mr74756155e9.2.1729439646841; Sun, 20 Oct 2024 08:54:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFxc5DRFb/uEe0C0BIK2MYpByrUuLmhNMTr70RIymtc9wedP82J5pjzpcd7CyaAlbN/GtxCIg== X-Received: by 2002:a05:600c:511c:b0:430:56f5:4d1f with SMTP id 5b1f17b1804b1-431586fc549mr74756005e9.2.1729439646383; Sun, 20 Oct 2024 08:54:06 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37ee0a37bb5sm2015074f8f.7.2024.10.20.08.54.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 08:54:05 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PATCH 12/14] target/i386: use builtin popcnt or parity to compute PF, if available Date: Sun, 20 Oct 2024 17:53:22 +0200 Message-ID: <20241020155324.35273-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241020155324.35273-1-pbonzini@redhat.com> References: <20241020155324.35273-1-pbonzini@redhat.com> MIME-Version: 1.0 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: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.527, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This removes the 256 byte parity table from the executable on x86, s390 and RISC-V/zbb hosts. Signed-off-by: Paolo Bonzini --- include/qemu/host-utils.h | 16 ++++++++++++++++ target/i386/tcg/helper-tcg.h | 12 ++++++++++++ target/i386/tcg/cc_helper_template.h.inc | 20 ++++++++++---------- target/i386/tcg/cc_helper.c | 2 ++ target/i386/tcg/int_helper.c | 4 ++-- 5 files changed, 42 insertions(+), 12 deletions(-) diff --git a/include/qemu/host-utils.h b/include/qemu/host-utils.h index ead97d354d6..bd4c684e5b5 100644 --- a/include/qemu/host-utils.h +++ b/include/qemu/host-utils.h @@ -126,6 +126,13 @@ static inline uint64_t muldiv64_round_up(uint64_t a, uint32_t b, uint32_t c) } #endif +#if defined __POPCNT__ || defined __s390x__|| defined __riscv_zbb +#define HAVE_FAST_CTPOP 1 +#endif +#if defined __i386__ || defined __x86_64__ || defined HAVE_FAST_CTPOP +#define HAVE_FAST_PARITY8 1 +#endif + /** * clz8 - count leading zeros in a 8-bit value. * @val: The value to search @@ -313,6 +320,15 @@ static inline int ctpop8(uint8_t val) return __builtin_popcount(val); } +/* + * parity8 - return the parity (1 = 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..fb6354873d1 100644 --- a/target/i386/tcg/helper-tcg.h +++ b/target/i386/tcg/helper-tcg.h @@ -21,6 +21,7 @@ #define I386_HELPER_TCG_H #include "exec/exec-all.h" +#include "qemu/host-utils.h" /* Maximum instruction code size */ #define TARGET_MAX_INSN_SIZE 16 @@ -87,7 +88,18 @@ G_NORETURN void x86_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, #endif /* cc_helper.c */ +#ifdef HAVE_FAST_PARITY8 +static inline unsigned int compute_pf(uint8_t x) +{ + return !parity8(x) * CC_P; +} +#else extern const uint8_t parity_table[256]; +static inline unsigned int compute_pf(uint8_t x) +{ + return parity_table[x]; +} +#endif /* 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 dst, DATA_TYPE src1) DATA_TYPE src2 = dst - src1; cf = dst < src1; - pf = parity_table[(uint8_t)dst]; + pf = compute_pf(dst); af = (dst ^ src1 ^ src2) & CC_A; zf = (dst == 0) * CC_Z; sf = lshift(dst, 8 - DATA_BITS) & CC_S; @@ -65,7 +65,7 @@ static uint32_t glue(compute_all_adc, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1, DATA_TYPE src2 = dst - src1 - src3; cf = (src3 ? dst <= src1 : dst < src1); - pf = parity_table[(uint8_t)dst]; + pf = compute_pf(dst); af = (dst ^ src1 ^ src2) & 0x10; zf = (dst == 0) << 6; sf = lshift(dst, 8 - DATA_BITS) & 0x80; @@ -85,7 +85,7 @@ static uint32_t glue(compute_all_sub, SUFFIX)(DATA_TYPE dst, DATA_TYPE src2) DATA_TYPE src1 = dst + src2; cf = src1 < src2; - pf = parity_table[(uint8_t)dst]; + pf = compute_pf(dst); af = (dst ^ src1 ^ src2) & CC_A; zf = (dst == 0) * CC_Z; sf = 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 = dst + src2 + src3; cf = (src3 ? src1 <= src2 : src1 < src2); - pf = parity_table[(uint8_t)dst]; + pf = compute_pf(dst); af = (dst ^ src1 ^ src2) & 0x10; zf = (dst == 0) << 6; sf = lshift(dst, 8 - DATA_BITS) & 0x80; @@ -128,7 +128,7 @@ static uint32_t glue(compute_all_logic, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) uint32_t cf, pf, af, zf, sf, of; cf = 0; - pf = parity_table[(uint8_t)dst]; + pf = compute_pf(dst); af = 0; zf = (dst == 0) * CC_Z; sf = 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 = src1; src1 = dst - 1; src2 = 1; - pf = parity_table[(uint8_t)dst]; + pf = compute_pf(dst); af = (dst ^ src1 ^ src2) & CC_A; zf = (dst == 0) * CC_Z; sf = 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 = src1; src1 = dst + 1; src2 = 1; - pf = parity_table[(uint8_t)dst]; + pf = compute_pf(dst); af = (dst ^ src1 ^ src2) & CC_A; zf = (dst == 0) * CC_Z; sf = 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; cf = (src1 >> (DATA_BITS - 1)) & CC_C; - pf = parity_table[(uint8_t)dst]; + pf = compute_pf(dst); af = 0; /* undefined */ zf = (dst == 0) * CC_Z; sf = 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; cf = src1 & 1; - pf = parity_table[(uint8_t)dst]; + pf = compute_pf(dst); af = 0; /* undefined */ zf = (dst == 0) * CC_Z; sf = 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; cf = (src1 != 0); - pf = parity_table[(uint8_t)dst]; + pf = compute_pf(dst); af = 0; /* undefined */ zf = (dst == 0) * CC_Z; sf = lshift(dst, 8 - DATA_BITS) & CC_S; diff --git a/target/i386/tcg/cc_helper.c b/target/i386/tcg/cc_helper.c index c24e6a14c07..d65345f059d 100644 --- a/target/i386/tcg/cc_helper.c +++ b/target/i386/tcg/cc_helper.c @@ -22,6 +22,7 @@ #include "exec/helper-proto.h" #include "helper-tcg.h" +#ifndef HAVE_FAST_PARITY8 const uint8_t parity_table[256] = { CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, @@ -56,6 +57,7 @@ const uint8_t parity_table[256] = { CC_P, 0, 0, CC_P, 0, CC_P, CC_P, 0, 0, CC_P, CC_P, 0, CC_P, 0, 0, CC_P, }; +#endif #define SHIFT 0 #include "cc_helper_template.h.inc" 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] = (env->regs[R_EAX] & ~0xff) | al; /* well, speed is not an issue here, so we compute the flags by hand */ eflags |= (al == 0) << 6; /* zf */ - eflags |= parity_table[al]; /* pf */ + eflags |= compute_pf(al); eflags |= (al & 0x80); /* sf */ CC_SRC = eflags; CC_OP = CC_OP_EFLAGS; @@ -269,7 +269,7 @@ void helper_das(CPUX86State *env) env->regs[R_EAX] = (env->regs[R_EAX] & ~0xff) | al; /* well, speed is not an issue here, so we compute the flags by hand */ eflags |= (al == 0) << 6; /* zf */ - eflags |= parity_table[al]; /* pf */ + eflags |= compute_pf(al); eflags |= (al & 0x80); /* sf */ CC_SRC = eflags; CC_OP = CC_OP_EFLAGS; From patchwork Sun Oct 20 15:53:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13843115 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 45297D3C92D for ; Sun, 20 Oct 2024 15:54:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2YGC-0003hz-R9; Sun, 20 Oct 2024 11:54:28 -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 1t2YG3-0003Us-Gh for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:54:19 -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 1t2YG1-0005Rt-5s for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:54:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729439656; 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=rdCTjRuJWU9eu1zEMJ2p20wsDU/+YEzfRzwCWhFB3yM=; b=CXdsvnOa5C/j30ATpnxii9qOQDFM5Vz+5cYg5+I9Qbzc/NydE7nle8RpRJsCwUv17W641A 0LmhWN5d4CPG0A6t+fzyA+eGSHHYRpDjxBCY7HrZd/1sBskHLQznu5QkGt3HDRTV+AMp9Z gfxWdcDcw3vg+B4+qChHY0Xo8ALwoxA= 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-622-NxBTyTQzMoKA4weyoH27QQ-1; Sun, 20 Oct 2024 11:54:13 -0400 X-MC-Unique: NxBTyTQzMoKA4weyoH27QQ-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-37d5a3afa84so1859821f8f.3 for ; Sun, 20 Oct 2024 08:54:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729439651; x=1730044451; 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=rdCTjRuJWU9eu1zEMJ2p20wsDU/+YEzfRzwCWhFB3yM=; b=TvwjKeKvTpK7X1iEmDSyVj51RIlXseWgLwKUchoZ1lfLFv3TR3PuHupH1SCTlZqQut nuaaGi3JbkQSKW/3LlREV2lpF/96Z7NuUgPs36uLPEoNocttJZM9oNC5Q0+sqM2RBwdV kJcieDrbSx+Nh/vttzT7yuTo0B98Llu1OMHaw2wm3BlRJh/kxoSXW0xKXKBHsokhMbfM qeGYEI9i5bqq8DMefZr+HYVxjnwMpy8Y38MJHkCgwkyksQPUPvorT/3xkTtS2Zxl6meC 7TJbcQn45ahkSvBZOmh0ZFKDnLrQD9LL3b8QTK+fBVOJZBkZxg93gXN913u1mZRpn6M1 veqw== X-Gm-Message-State: AOJu0YxdK7k5HL35koI7CtW5mqV2gKf2fFeUkuwSwKDCRuYwsVcDLfK2 sf1O9YyRqCJWoABFKZqJFcX8eNbmbLVdnJ0A16jndVE854UjshgOB7g7yGmcuZ5euBIIKLQxpQE nu70oXfxn5NMOoZA6NpdvSquIE3wem2HWdVkt3EdDJlZvQMK/U6B0b5Xw9EDzMjTCpKGzkCZOhx aKkK2ocditBlw7k1e52/x6dHOTc8gniZYjmDssG2o= X-Received: by 2002:adf:f6d2:0:b0:37c:d299:b5f0 with SMTP id ffacd0b85a97d-37eab6ec6camr5327420f8f.59.1729439650906; Sun, 20 Oct 2024 08:54:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYWBXyX46VYVA7kzUy0SkLvAFBfoAYjzVeL4dAj59yP8wZStDJT74AzOHqBwAPxGhzbkSWuw== X-Received: by 2002:adf:f6d2:0:b0:37c:d299:b5f0 with SMTP id ffacd0b85a97d-37eab6ec6camr5327412f8f.59.1729439650386; Sun, 20 Oct 2024 08:54:10 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37ee0ba7dffsm1991213f8f.116.2024.10.20.08.54.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 08:54:08 -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: Sun, 20 Oct 2024 17:53:23 +0200 Message-ID: <20241020155324.35273-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241020155324.35273-1-pbonzini@redhat.com> References: <20241020155324.35273-1-pbonzini@redhat.com> MIME-Version: 1.0 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: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.527, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 == 8 #define SUFFIX b #define DATA_TYPE uint8_t +#define WIDER_TYPE uint32_t #elif DATA_BITS == 16 #define SUFFIX w #define DATA_TYPE uint16_t +#define WIDER_TYPE uint32_t #elif DATA_BITS == 32 #define SUFFIX l #define DATA_TYPE uint32_t +#if HOST_LONG_BITS <= 64 +#define WIDER_TYPE uint64_t +#endif #elif DATA_BITS == 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 = (WIDER_TYPE) src1 + (WIDER_TYPE) src3; + DATA_TYPE src2 = dst - src13; + + cf = dst < src13; +#else DATA_TYPE src2 = dst - src1 - src3; cf = (src3 ? dst <= src1 : dst < src1); +#endif + pf = compute_pf(dst); af = (dst ^ src1 ^ src2) & 0x10; zf = (dst == 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 = (WIDER_TYPE) src1 + (WIDER_TYPE) src3; + + return dst < src13; +#else return src3 ? dst <= src1 : dst < src1; +#endif } static uint32_t glue(compute_all_sub, SUFFIX)(DATA_TYPE dst, DATA_TYPE src2) @@ -104,9 +124,18 @@ static uint32_t glue(compute_all_sbb, SUFFIX)(DATA_TYPE dst, DATA_TYPE src2, DATA_TYPE src3) { uint32_t cf, pf, af, zf, sf, of; + +#ifdef WIDER_TYPE + WIDER_TYPE src23 = (WIDER_TYPE) src2 + (WIDER_TYPE) src3; + DATA_TYPE src1 = dst + src23; + + cf = src1 < src23; +#else DATA_TYPE src1 = dst + src2 + src3; cf = (src3 ? src1 <= src2 : src1 < src2); +#endif + pf = compute_pf(dst); af = (dst ^ src1 ^ src2) & 0x10; zf = (dst == 0) << 6; @@ -118,9 +147,16 @@ static uint32_t glue(compute_all_sbb, SUFFIX)(DATA_TYPE 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 = (WIDER_TYPE) src2 + (WIDER_TYPE) src3; + DATA_TYPE src1 = dst + src23; + + return src1 < src23; +#else DATA_TYPE src1 = dst + src2 + src3; return (src3 ? src1 <= src2 : src1 < src2); +#endif } static uint32_t glue(compute_all_logic, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) @@ -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 From patchwork Sun Oct 20 15:53:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 13843117 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C6FEED3C92A for ; Sun, 20 Oct 2024 15:54:59 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2YG9-0003ak-BW; Sun, 20 Oct 2024 11:54:25 -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 1t2YG4-0003WK-W0 for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:54:21 -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 1t2YG3-0005Rx-DK for qemu-devel@nongnu.org; Sun, 20 Oct 2024 11:54:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729439657; 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=wgy24lMTqIuST3Sc0fNBO9jDVweqRdB371hlg23DEdk=; b=L6PG0JdjewsKbelzSC57PrhsXW5ktbKXhahZr3brPwGcDDAPbI91wttTMyCifE40ERzbpY KSsp7cVrEWNEg9FPQLxCJmhCdDCIGJbdTUV1dvQKIrL4oh6yl9TOWo23w65KcYdHh8CJfF k2UkdZJmoMRb+w3hIVFR3Ag2R/WxK1o= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-505-VVLuOD8cMviCcYffaAgorA-1; Sun, 20 Oct 2024 11:54:16 -0400 X-MC-Unique: VVLuOD8cMviCcYffaAgorA-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-43159c07193so31855705e9.0 for ; Sun, 20 Oct 2024 08:54:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729439654; x=1730044454; 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=wgy24lMTqIuST3Sc0fNBO9jDVweqRdB371hlg23DEdk=; b=JWT7iHxhtr8YacmghV698ny0myzzL1j29fUWRw2WXJR5TS5R08OTn/hakQqPPVqa8h eUYAhvuGq257G7SCuBLt8csocgXvTTIlBULLksSdT/lbHubilivBPJXkO/ETCxZhk3au dRMs4W3G6pJI3KUoSwQqBicUgEZb6+u0d9XzWclU6fU6aRPkiDP9KILrpFEXis/g0VaY 93B9zxwkWzZNDQ5IOMEmCJIpFZlKKyXnafQObacXXWIE4wML5BLwSsjFw2ktCJGMssoM uVcBHBV7Jvs/b0bT7sg4HPPqXkjWzFyshwoExlCQTqATvah/VYbbXEDBB6TYA2kHtoBm laZA== X-Gm-Message-State: AOJu0YwPHeRXHXYDo7a9S2BoNKj6m9p1lpVyfZNnkuhDHf4BEED27pWC jUX3PkUFg7aE8OnW4oFMhScdBSFRmCIovpbSz3D72Ktf8SdnU1zp4TVHHOfeyQoWv5RFHAawNIa vpQHeY/QLYwboI1QG+Z7SgHgIJOxbQUPlblk31ApNU7c+yXj3pvZvfynUVVkLS4H4Sbdl3lFlkA 39bqjhCorzkFZhy/sXm1N7tKfp52rSuT6HFcaCr8c= X-Received: by 2002:a05:600c:46d0:b0:431:4f29:9539 with SMTP id 5b1f17b1804b1-43161690021mr94518785e9.32.1729439654309; Sun, 20 Oct 2024 08:54:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEvefVFJ3Q1FwgHOfn9xAGGFkYAtcs2zju6QUDw7KAKg5bI6p+qkP+SSoIQ21J0nfziyxpn8w== X-Received: by 2002:a05:600c:46d0:b0:431:4f29:9539 with SMTP id 5b1f17b1804b1-43161690021mr94518545e9.32.1729439653943; Sun, 20 Oct 2024 08:54:13 -0700 (PDT) Received: from avogadro.local ([151.95.144.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f58f1fdsm27217705e9.28.2024.10.20.08.54.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Oct 2024 08:54:12 -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: Sun, 20 Oct 2024 17:53:24 +0200 Message-ID: <20241020155324.35273-15-pbonzini@redhat.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241020155324.35273-1-pbonzini@redhat.com> References: <20241020155324.35273-1-pbonzini@redhat.com> MIME-Version: 1.0 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: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.527, 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=-1.699, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 dst, DATA_TYPE src1) zf = (dst == 0) * CC_Z; sf = lshift(dst, 8 - DATA_BITS) & CC_S; of = 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; } 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 dst, DATA_TYPE src1, zf = (dst == 0) << 6; sf = lshift(dst, 8 - DATA_BITS) & 0x80; of = 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; } 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 = (dst == 0) * CC_Z; sf = lshift(dst, 8 - DATA_BITS) & CC_S; of = lshift((src1 ^ src2) & (src1 ^ dst), 12 - DATA_BITS) & CC_O; - return cf | pf | af | zf | sf | of; + return cf + pf + af + zf + sf + of; } 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 = (dst == 0) << 6; sf = lshift(dst, 8 - DATA_BITS) & 0x80; of = lshift((src1 ^ src2) & (src1 ^ dst), 12 - DATA_BITS) & CC_O; - return cf | pf | af | zf | sf | of; + return cf + pf + af + zf + sf + of; } 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_TYPE dst, DATA_TYPE src1) zf = (dst == 0) * CC_Z; sf = lshift(dst, 8 - DATA_BITS) & CC_S; of = 0; - return cf | pf | af | zf | sf | of; + return cf + pf + af + zf + sf + of; } static uint32_t glue(compute_all_inc, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) @@ -185,7 +185,7 @@ static uint32_t glue(compute_all_inc, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) zf = (dst == 0) * CC_Z; sf = lshift(dst, 8 - DATA_BITS) & CC_S; of = (dst == SIGN_MASK) * CC_O; - return cf | pf | af | zf | sf | of; + return cf + pf + af + zf + sf + of; } static uint32_t glue(compute_all_dec, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) @@ -201,7 +201,7 @@ static uint32_t glue(compute_all_dec, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) zf = (dst == 0) * CC_Z; sf = lshift(dst, 8 - DATA_BITS) & CC_S; of = (dst == SIGN_MASK - 1) * CC_O; - return cf | pf | af | zf | sf | of; + return cf + pf + af + zf + sf + of; } static uint32_t glue(compute_all_shl, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) @@ -215,7 +215,7 @@ static uint32_t glue(compute_all_shl, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) sf = lshift(dst, 8 - DATA_BITS) & CC_S; /* of is defined iff shift count == 1 */ of = lshift(src1 ^ dst, 12 - DATA_BITS) & CC_O; - return cf | pf | af | zf | sf | of; + return cf + pf + af + zf + sf + of; } 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 = lshift(dst, 8 - DATA_BITS) & CC_S; /* of is defined iff shift count == 1 */ of = lshift(src1 ^ dst, 12 - DATA_BITS) & CC_O; - return cf | pf | af | zf | sf | of; + return cf + pf + af + zf + sf + of; } /* 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 = (dst == 0) * CC_Z; sf = lshift(dst, 8 - DATA_BITS) & CC_S; of = cf * CC_O; - return cf | pf | af | zf | sf | of; + return cf + pf + af + zf + sf + of; } static uint32_t glue(compute_all_bmilg, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) @@ -263,7 +263,7 @@ static uint32_t glue(compute_all_bmilg, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1) zf = (dst == 0) * CC_Z; sf = lshift(dst, 8 - DATA_BITS) & CC_S; of = 0; - return cf | pf | af | zf | sf | of; + return cf + pf + af + zf + sf + of; } 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 = (dst == 0) * CC_Z; sf = lshift(dst, 8 - DATA_BITS) & CC_S; of = 0; - return cf | pf | af | zf | sf | of; + return cf + pf + af + zf + sf + of; } static int glue(compute_c_blsi, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1)