From nobody Tue Feb 10 09:57:30 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1650839034887969.4573135622587; Sun, 24 Apr 2022 15:23:54 -0700 (PDT) Received: from localhost ([::1]:33534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nike1-0003X5-Px for importer@patchew.org; Sun, 24 Apr 2022 18:23:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nikSk-0001g9-3f for qemu-devel@nongnu.org; Sun, 24 Apr 2022 18:12:14 -0400 Received: from nowt.default.pbrook.uk0.bigv.io ([2001:41c8:51:832:fcff:ff:fe00:46dd]:58801) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nikSh-0002pR-LG for qemu-devel@nongnu.org; Sun, 24 Apr 2022 18:12:13 -0400 Received: from cpc91554-seac25-2-0-cust857.7-2.cable.virginm.net ([82.27.199.90] helo=wren.home) by nowt.default.pbrook.uk0.bigv.io with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1nikJA-0001ea-Hv; Sun, 24 Apr 2022 23:02:20 +0100 From: Paul Brook To: Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PATCH v2 28/42] i386: Implement VZEROALL and VZEROUPPER Date: Sun, 24 Apr 2022 23:01:50 +0100 Message-Id: <20220424220204.2493824-29-paul@nowt.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220418173904.3746036-1-paul@nowt.org> References: <20220418173904.3746036-1-paul@nowt.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:41c8:51:832:fcff:ff:fe00:46dd; envelope-from=paul@nowt.org; helo=nowt.default.pbrook.uk0.bigv.io X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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: , Cc: "open list:All patches CC here" , Paul Brook Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1650839035980100001 Content-Type: text/plain; charset="utf-8" The use the same opcode as EMMS, which I guess makes some sort of sense. Fairly strightforward other than that. If we were wanting to optimize out gen_clear_ymmh then this would be one of the starting points. Signed-off-by: Paul Brook --- target/i386/ops_sse.h | 48 ++++++++++++++++++++++++++++++++++++ target/i386/ops_sse_header.h | 9 +++++++ target/i386/tcg/translate.c | 26 ++++++++++++++++--- 3 files changed, 80 insertions(+), 3 deletions(-) diff --git a/target/i386/ops_sse.h b/target/i386/ops_sse.h index ad3312d353..a1f50f0c8b 100644 --- a/target/i386/ops_sse.h +++ b/target/i386/ops_sse.h @@ -3071,6 +3071,54 @@ void glue(helper_aeskeygenassist, SUFFIX)(CPUX86Stat= e *env, Reg *d, Reg *s, #endif #endif =20 +#if SHIFT =3D=3D 2 +void helper_vzeroall(CPUX86State *env) +{ + int i; + + for (i =3D 0; i < 8; i++) { + env->xmm_regs[i].ZMM_Q(0) =3D 0; + env->xmm_regs[i].ZMM_Q(1) =3D 0; + env->xmm_regs[i].ZMM_Q(2) =3D 0; + env->xmm_regs[i].ZMM_Q(3) =3D 0; + } +} + +void helper_vzeroupper(CPUX86State *env) +{ + int i; + + for (i =3D 0; i < 8; i++) { + env->xmm_regs[i].ZMM_Q(2) =3D 0; + env->xmm_regs[i].ZMM_Q(3) =3D 0; + } +} + +#ifdef TARGET_X86_64 +void helper_vzeroall_hi8(CPUX86State *env) +{ + int i; + + for (i =3D 8; i < 16; i++) { + env->xmm_regs[i].ZMM_Q(0) =3D 0; + env->xmm_regs[i].ZMM_Q(1) =3D 0; + env->xmm_regs[i].ZMM_Q(2) =3D 0; + env->xmm_regs[i].ZMM_Q(3) =3D 0; + } +} + +void helper_vzeroupper_hi8(CPUX86State *env) +{ + int i; + + for (i =3D 8; i < 16; i++) { + env->xmm_regs[i].ZMM_Q(2) =3D 0; + env->xmm_regs[i].ZMM_Q(3) =3D 0; + } +} +#endif +#endif + #undef SSE_HELPER_S =20 #undef SHIFT diff --git a/target/i386/ops_sse_header.h b/target/i386/ops_sse_header.h index cfcfba154b..48f0945917 100644 --- a/target/i386/ops_sse_header.h +++ b/target/i386/ops_sse_header.h @@ -411,6 +411,15 @@ DEF_HELPER_4(glue(aeskeygenassist, SUFFIX), void, env,= Reg, Reg, i32) DEF_HELPER_5(glue(pclmulqdq, SUFFIX), void, env, Reg, Reg, Reg, i32) #endif =20 +#if SHIFT =3D=3D 2 +DEF_HELPER_1(vzeroall, void, env) +DEF_HELPER_1(vzeroupper, void, env) +#ifdef TARGET_X86_64 +DEF_HELPER_1(vzeroall_hi8, void, env) +DEF_HELPER_1(vzeroupper_hi8, void, env) +#endif +#endif + #undef SHIFT #undef Reg #undef SUFFIX diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index bcd6d47fd0..ba70aeb039 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -3455,9 +3455,29 @@ static void gen_sse(CPUX86State *env, DisasContext *= s, int b, return; } if (b =3D=3D 0x77) { - /* emms */ - gen_helper_emms(cpu_env); - return; + if (s->prefix & PREFIX_VEX) { + CHECK_AVX(s); + if (s->vex_l) { + gen_helper_vzeroall(cpu_env); +#ifdef TARGET_X86_64 + if (CODE64(s)) { + gen_helper_vzeroall_hi8(cpu_env); + } +#endif + } else { + gen_helper_vzeroupper(cpu_env); +#ifdef TARGET_X86_64 + if (CODE64(s)) { + gen_helper_vzeroupper_hi8(cpu_env); + } +#endif + } + return; + } else { + /* emms */ + gen_helper_emms(cpu_env); + return; + } } /* prepare MMX state (XXX: optimize by storing fptt and fptags in the static cpu state) */ --=20 2.36.0