From nobody Tue Nov 26 08:38:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709118808; cv=none; d=zohomail.com; s=zohoarc; b=hGpNbWsaduUYglbrIobk1GLHWXs2QG9PrW9CH8a85UkooFfzHysFQYQuG28Mlu3+gc+gIuGKb88p4bOzKw+4jgyDDxUjyfwJoEfoKhHy4QckcFRNpOmEDAn3aXdQTbD/+ybiphMnXj5DOKfWJ53Nj55paR0539CBKuH7I7ZYARA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709118808; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vdiqFmI9WNRUmhfY3Qso6ESXzjkal8TeG/51RyozoDo=; b=ERluCF+i5C9OJi9bGyJ/0Kr5tC94zedPsdoBpmCfJwQAw2niKzE+//waJBzneVjQvX49Ku4Pzvc2FuDxB5ELpiNz5RytDB0GXH76kzxAkNOWOgaTElx8BOmASONS/ZXbFV4y//rM0+poBxkiLQF9fgXAN5jvtf/YfC70y2FP+3w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709118808797430.7328273691371; Wed, 28 Feb 2024 03:13:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfHr8-0004gO-4Z; Wed, 28 Feb 2024 06:12:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfHr6-0004fr-K0 for qemu-devel@nongnu.org; Wed, 28 Feb 2024 06:12:08 -0500 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 1rfHr2-0003nA-6G for qemu-devel@nongnu.org; Wed, 28 Feb 2024 06:12:08 -0500 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-642-GZAi8HvsOviYFxewEttv8w-1; Wed, 28 Feb 2024 06:12:01 -0500 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a3ede65e32bso177711766b.1 for ; Wed, 28 Feb 2024 03:12:01 -0800 (PST) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id qo12-20020a170907874c00b00a43c51efb11sm1264669ejc.3.2024.02.28.03.11.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 03:11:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709118723; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vdiqFmI9WNRUmhfY3Qso6ESXzjkal8TeG/51RyozoDo=; b=Hosfy6p4Hgu0VVeOLydxeVfNU6NffZHYFbhkcpbR5DNJw3Tv0bpUnd+qi+8QIUWD4euCEq gQFFOqDMdlpt3xns3mMd6aFhK4mpaiCb+lhzY3knWdmnnQ5kaikzuBtEqlypnTNbaguSu+ MbIv1+f/nBIrtqd9SNSY7NmZtHXCINU= X-MC-Unique: GZAi8HvsOviYFxewEttv8w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709118719; x=1709723519; 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=vdiqFmI9WNRUmhfY3Qso6ESXzjkal8TeG/51RyozoDo=; b=vfoop8y5LJYaY+VdfZfgOz4dAi99HcDYsYru3M3rOUhA50SKxCR2xUNaN5R/Oj9dj3 kJUp0RHCwRxI1l4gmyNLOsXHfEwgvY57LaZXn2UtMmt/g+oFRFG6J4iirfQE2F0X0iio Khasb2/2wLa+5BQY2T6QQq9ky7yc7y5KUmB/QsjhU6H70LqQcNkhZPxJwWMVvHqX2CoP 9aGvKE294ZApapGdhVV9hXgBt6RDKJQSDwGKX/Lvwr/PHG1BFjflkLcF1Hojb/fiEcFg kGSeQxfTjShIcTo9AvyhPOeCdRZahTpsJQGpW8weWOUSbQCusvbRmQ+mtZ9KMrp5wh8U 0h2g== X-Gm-Message-State: AOJu0YyCJSzGg1ZCGpavL9TsfsJ0MMnRjNBvhcIP15+awowNQkYO3FCx jdCtshQLldqOgi/4dq5j7IeOwx9Jt0biVZxrqxSpq97i94ZO1cg+T7NBthOrRN2gwCPv2arXtA+ 7uAeeLt2bwI06LgUWpS4ArPmonn+Y1JFmw27O3Ev7yy9Jb8bzhemNuWdgoXjLKSSCGhrnI27Y5n pCAwezmsFcEHV35rhv/Ou+uWSTodb5phujQDn/ X-Received: by 2002:a17:906:15c1:b0:a43:72d6:f1fe with SMTP id l1-20020a17090615c100b00a4372d6f1femr4926838ejd.77.1709118719481; Wed, 28 Feb 2024 03:11:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IH3334Lqps0/8fvkQjUrC8JcdfSZxB2qb3b3g/NXmrIQD8iajx6xxgMykBn5JJV+Z3YBBLdBA== X-Received: by 2002:a17:906:15c1:b0:a43:72d6:f1fe with SMTP id l1-20020a17090615c100b00a4372d6f1femr4926821ejd.77.1709118719096; Wed, 28 Feb 2024 03:11:59 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org Subject: [PATCH 2/4] target/i386: use TSTEQ/TSTNE to check flags Date: Wed, 28 Feb 2024 12:11:49 +0100 Message-ID: <20240228111151.287738-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240228111151.287738-1-pbonzini@redhat.com> References: <20240228111151.287738-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1709118810931100007 Content-Type: text/plain; charset="utf-8" The new condition obviously come in handy when testing individual bits of EFLAGS, and they make it possible to remove the .mask field of CCPrepare. Lowering to shift+and is done by the optimizer if necessary. Signed-off-by: Paolo Bonzini Reviewed-by: Richard Henderson --- target/i386/tcg/translate.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index fe9021833e3..63d520e0cba 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -995,8 +995,8 @@ static CCPrepare gen_prepare_eflags_c(DisasContext *s, = TCGv reg) case CC_OP_EFLAGS: case CC_OP_SARB ... CC_OP_SARQ: /* CC_SRC & 1 */ - return (CCPrepare) { .cond =3D TCG_COND_NE, - .reg =3D cpu_cc_src, .mask =3D CC_C }; + return (CCPrepare) { .cond =3D TCG_COND_TSTNE, + .reg =3D cpu_cc_src, .mask =3D -1, .imm =3D C= C_C }; =20 default: /* The need to compute only C from CC_OP_DYNAMIC is important @@ -1013,8 +1013,8 @@ static CCPrepare gen_prepare_eflags_c(DisasContext *s= , TCGv reg) static CCPrepare gen_prepare_eflags_p(DisasContext *s, TCGv reg) { gen_compute_eflags(s); - return (CCPrepare) { .cond =3D TCG_COND_NE, .reg =3D cpu_cc_src, - .mask =3D CC_P }; + return (CCPrepare) { .cond =3D TCG_COND_TSTNE, .reg =3D cpu_cc_src, + .mask =3D -1, .imm =3D CC_P }; } =20 /* compute eflags.S to reg */ @@ -1028,8 +1028,8 @@ static CCPrepare gen_prepare_eflags_s(DisasContext *s= , TCGv reg) case CC_OP_ADCX: case CC_OP_ADOX: case CC_OP_ADCOX: - return (CCPrepare) { .cond =3D TCG_COND_NE, .reg =3D cpu_cc_src, - .mask =3D CC_S }; + return (CCPrepare) { .cond =3D TCG_COND_TSTNE, .reg =3D cpu_cc_src, + .mask =3D -1, .imm =3D CC_S }; case CC_OP_CLR: case CC_OP_POPCNT: return (CCPrepare) { .cond =3D TCG_COND_NEVER, .mask =3D -1 }; @@ -1057,8 +1057,8 @@ static CCPrepare gen_prepare_eflags_o(DisasContext *s= , TCGv reg) .reg =3D cpu_cc_src, .mask =3D -1 }; default: gen_compute_eflags(s); - return (CCPrepare) { .cond =3D TCG_COND_NE, .reg =3D cpu_cc_src, - .mask =3D CC_O }; + return (CCPrepare) { .cond =3D TCG_COND_TSTNE, .reg =3D cpu_cc_src, + .mask =3D -1, .imm =3D CC_O }; } } =20 @@ -1073,8 +1073,8 @@ static CCPrepare gen_prepare_eflags_z(DisasContext *s= , TCGv reg) case CC_OP_ADCX: case CC_OP_ADOX: case CC_OP_ADCOX: - return (CCPrepare) { .cond =3D TCG_COND_NE, .reg =3D cpu_cc_src, - .mask =3D CC_Z }; + return (CCPrepare) { .cond =3D TCG_COND_TSTNE, .reg =3D cpu_cc_src, + .mask =3D -1, .imm =3D CC_Z }; case CC_OP_CLR: return (CCPrepare) { .cond =3D TCG_COND_ALWAYS, .mask =3D -1 }; case CC_OP_POPCNT: @@ -1152,8 +1152,8 @@ static CCPrepare gen_prepare_cc(DisasContext *s, int = b, TCGv reg) break; case JCC_BE: gen_compute_eflags(s); - cc =3D (CCPrepare) { .cond =3D TCG_COND_NE, .reg =3D cpu_cc_sr= c, - .mask =3D CC_Z | CC_C }; + cc =3D (CCPrepare) { .cond =3D TCG_COND_TSTNE, .reg =3D cpu_cc= _src, + .mask =3D -1, .imm =3D CC_Z | CC_C }; break; case JCC_S: cc =3D gen_prepare_eflags_s(s, reg); @@ -1167,8 +1167,8 @@ static CCPrepare gen_prepare_cc(DisasContext *s, int = b, TCGv reg) reg =3D s->tmp0; } tcg_gen_addi_tl(reg, cpu_cc_src, CC_O - CC_S); - cc =3D (CCPrepare) { .cond =3D TCG_COND_NE, .reg =3D reg, - .mask =3D CC_O }; + cc =3D (CCPrepare) { .cond =3D TCG_COND_TSTNE, .reg =3D reg, + .mask =3D -1, .imm =3D CC_O }; break; default: case JCC_LE: @@ -1177,8 +1177,8 @@ static CCPrepare gen_prepare_cc(DisasContext *s, int = b, TCGv reg) reg =3D s->tmp0; } tcg_gen_addi_tl(reg, cpu_cc_src, CC_O - CC_S); - cc =3D (CCPrepare) { .cond =3D TCG_COND_NE, .reg =3D reg, - .mask =3D CC_O | CC_Z }; + cc =3D (CCPrepare) { .cond =3D TCG_COND_TSTNE, .reg =3D reg, + .mask =3D -1, .imm =3D CC_O | CC_Z }; break; } break; --=20 2.43.2