From patchwork Fri Jan 19 23:23:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 763964 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:10c4:b0:337:62d3:c6d5 with SMTP id b4csp109527wrx; Fri, 19 Jan 2024 15:24:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGCGbFby2TCWBXQX99aOJ3SDi90Gf2Z/FPQZ+U5yjz8nmOj4j7eGNd9ZQvwj2XVLUhaP8vj X-Received: by 2002:a05:620a:4102:b0:783:9227:82a7 with SMTP id j2-20020a05620a410200b00783922782a7mr95521qko.4.1705706670055; Fri, 19 Jan 2024 15:24:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705706670; cv=none; d=google.com; s=arc-20160816; b=WRErUW5LnSjbzkWj7QYIJ5ZXbMfvYzUk8IbbwOpeVKIzX3SFB5CpApfC7au9tVNmQ5 xk9IkBwzmVzV58BNf11tVXke3SR4jOQtALE6sdvwivA2O1pS6gMTXDVdvLqwrl4A1gfn 1tNs3zCmGUyKWlPfMHQBFshbWWTvYiyTmScnWCv6/60sasE2S/HHSoWWp6g4rKh1HLGC rqrDfTmBmNBAiYoXtfgKxXylM0eBEtjaFZg14zosC61LAkeiYiAc4zZtk6SUxljJUQOa c2F08AjYTRJ7dtNPEST77j3Nw9xv+fbKDbcyWUge69hm7cpIoLK3AqulC6qnM+Fjr9pc V+Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vIz5d9b5T7LFW05WUUJ9h1myyFYL4h2BqUyq/mWZyYE=; fh=04ycLKTWno9tnkGng2eIaNWueAwLX2fvg2ZFcmhcji4=; b=DfFd3Q9+Bpxh1pUDkN/FEvWdZ+Zv+UYDz2zjCDjlaDnE/54Jp69dcKE8WtufyGI/tD IOPK28EY+KDw293KKM+j+akCBc9hzN0OcPauqwtZzC3tF8ulrgUqjip72RSTHdfxfTWc vyf8evS5lBH+lVPqGvPEOr2Sd20e56wJDUGeq/08z82kZ6jnylTsOvp7fymKQevlLdBA xdWLUulbMcctIAv3n+7wFGRDOKAcp7vh7GJEEZj37SEtkUVt9MnMcQgEN3RixnVYMWn3 NXNVEIQ/QcJioRNPmrovkLZ5HJAg6RMUYlLmrC1IOx38mJ7Zq8o4Mbkah1tg4ct7JPsF dh3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ARmT+CX6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v15-20020a05620a0a8f00b0078337e502f8si306374qkg.688.2024.01.19.15.24.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jan 2024 15:24:30 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ARmT+CX6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQyCw-0000as-HL; Fri, 19 Jan 2024 18:23:30 -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 1rQyCv-0000a6-3I for qemu-devel@nongnu.org; Fri, 19 Jan 2024 18:23:29 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rQyCt-0008Ir-Gy for qemu-devel@nongnu.org; Fri, 19 Jan 2024 18:23:28 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40ea34df934so1926735e9.2 for ; Fri, 19 Jan 2024 15:23:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705706606; x=1706311406; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vIz5d9b5T7LFW05WUUJ9h1myyFYL4h2BqUyq/mWZyYE=; b=ARmT+CX6lA5xohdQUMVcmHbVZfaZiMSfUmZGGWRt+EFmWCUwLOcXGgeODyR1SOSUda rqJ8taiE6zuXCxc0FWQZy5Txl9a3znHVbF0r8nR3p5IAH3Zqpn1e9RPloBcb0gLcUOLK y6G/NgDv3nlTVrxgX2NONBeE5aN/xjwFuF+hPxsjswiGbgfpCxW3Ts+AWTBU5Qv4mkRp QoWVqlzEUlo6zvFAmq85U/20C1OYOfvzZQBVY57uXL3FoknSouXuH58rVZfEaKTa3Q4n gQuyMD1hPypqczHPlhL1b/gbZV7nk6pEL4097flh3RzbU0sK0iDfX0VJgr64orPChn77 FE3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705706606; x=1706311406; 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=vIz5d9b5T7LFW05WUUJ9h1myyFYL4h2BqUyq/mWZyYE=; b=PX/QTeKS5Jn5n+/t4lqPmXWJiXzMxiM1PxurjNbOb7Z+T5VOzNTA9Znyaxth2zSckG UwWUs5MoEFYlqM3CB3pzc6hp9LLHgUV/4hyZ6419XmLE6ubVPS5pgTjuY7zmK7rslm7X ++Pc9TZc3HCTGLensVGuHEu/mslOdzrGIkk+TJQIyzevGrnQe4YYM9kKlgyswN122jsI yiSf7WH8dBB7D6mrrsAg55IEdaKPH+XYZyw++B8L+z+5GeV+2agtcwl+15kJ4M5h0/aJ wx/49gGyZQlsOGZdtsrIk9z/BRIuHJ41Wqz5KLaviKvvYoTBMxEK39eNaEzzNIR1zCHs ZR/w== X-Gm-Message-State: AOJu0Yz9MlQ69Z0autRTXqMtOw6ww6bOccwkK6HRQooHQFfU4ue7WtUK EnJl2Le3NWweCMj8hDWLfolhCCgqGxaaUzzN8+aO8XQ734ECDHJkHPhvo74TZer2pLC5hmejvoH J X-Received: by 2002:a05:600c:3553:b0:40e:5a80:7e7c with SMTP id i19-20020a05600c355300b0040e5a807e7cmr269027wmq.7.1705706606004; Fri, 19 Jan 2024 15:23:26 -0800 (PST) Received: from localhost.localdomain (91-163-26-170.subs.proxad.net. [91.163.26.170]) by smtp.gmail.com with ESMTPSA id je14-20020a05600c1f8e00b0040e3635ca65sm34333850wmb.2.2024.01.19.15.23.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jan 2024 15:23:25 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , David Hildenbrand , Thomas Huth , qemu-s390x@nongnu.org, Ilya Leoshkevich , =?utf-8?q?Phil?= =?utf-8?q?ippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 15/38 6/6] target/s390x: Improve general case of disas_jcc Date: Sat, 20 Jan 2024 00:23:02 +0100 Message-ID: <20240119232302.50393-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240110224408.10444-16-richard.henderson@linaro.org> References: <20240110224408.10444-16-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson Avoid code duplication by handling 7 of the 14 cases by inverting the test for the other 7 cases. Use TCG_COND_TSTNE for cc in {1,3}. Use (cc - 1) <= 1 for cc in {1,2}. Signed-off-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Acked-by: Ilya Leoshkevich --- target/s390x/tcg/translate.c | 52 +++++++++++------------------------- 1 file changed, 15 insertions(+), 37 deletions(-) diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c index 93c64db33e..030c026699 100644 --- a/target/s390x/tcg/translate.c +++ b/target/s390x/tcg/translate.c @@ -885,67 +885,45 @@ static void disas_jcc(DisasContext *s, DisasCompare *c, uint32_t mask) case CC_OP_STATIC: c->is_64 = false; c->u.s32.a = cc_op; - switch (mask) { + + /* Fold half of the cases using bit 3 to invert. */ + switch (mask & 8 ? mask ^ 0xf : mask) { case 0x1: /* cc == 3 */ cond = TCG_COND_EQ; c->u.s32.b = tcg_constant_i32(3); break; - case 0x8 | 0x4 | 0x2: /* cc != 3 */ - cond = TCG_COND_NE; - c->u.s32.b = tcg_constant_i32(3); - break; case 0x2: /* cc == 2 */ cond = TCG_COND_EQ; c->u.s32.b = tcg_constant_i32(2); break; - case 0x8 | 0x4 | 0x1: /* cc != 2 */ - cond = TCG_COND_NE; - c->u.s32.b = tcg_constant_i32(2); - break; case 0x4: /* cc == 1 */ cond = TCG_COND_EQ; c->u.s32.b = tcg_constant_i32(1); break; - case 0x8 | 0x2 | 0x1: /* cc != 1 */ - cond = TCG_COND_NE; - c->u.s32.b = tcg_constant_i32(1); - break; - case 0x8 | 0x4: /* cc < 2 */ - cond = TCG_COND_LTU; - c->u.s32.b = tcg_constant_i32(2); - break; - case 0x2 | 0x1: /* cc > 1 */ + case 0x2 | 0x1: /* cc == 2 || cc == 3 => cc > 1 */ cond = TCG_COND_GTU; c->u.s32.b = tcg_constant_i32(1); break; case 0x4 | 0x1: /* cc == 1 || cc == 3 => (cc & 1) != 0 */ - cond = TCG_COND_NE; - c->u.s32.a = tcg_temp_new_i32(); - c->u.s32.b = tcg_constant_i32(0); - tcg_gen_andi_i32(c->u.s32.a, cc_op, 1); + cond = TCG_COND_TSTNE; + c->u.s32.b = tcg_constant_i32(1); break; - case 0x8 | 0x2: /* cc == 0 || cc == 2 => (cc & 1) == 0 */ - cond = TCG_COND_EQ; + case 0x4 | 0x2: /* cc == 1 || cc == 2 => (cc - 1) <= 1 */ + cond = TCG_COND_LEU; c->u.s32.a = tcg_temp_new_i32(); - c->u.s32.b = tcg_constant_i32(0); - tcg_gen_andi_i32(c->u.s32.a, cc_op, 1); + c->u.s32.b = tcg_constant_i32(1); + tcg_gen_addi_i32(c->u.s32.a, cc_op, -1); break; case 0x4 | 0x2 | 0x1: /* cc != 0 */ cond = TCG_COND_NE; c->u.s32.b = tcg_constant_i32(0); break; - case 0x8: /* cc == 0 */ - cond = TCG_COND_EQ; - c->u.s32.b = tcg_constant_i32(0); - break; default: - /* CC is masked by something else: (8 >> cc) & mask. */ - cond = TCG_COND_NE; - c->u.s32.a = tcg_temp_new_i32(); - c->u.s32.b = tcg_constant_i32(0); - tcg_gen_shr_i32(c->u.s32.a, tcg_constant_i32(8), cc_op); - tcg_gen_andi_i32(c->u.s32.a, c->u.s32.a, mask); - break; + /* case 0: never, handled above. */ + g_assert_not_reached(); + } + if (mask & 8) { + cond = tcg_invert_cond(cond); } break;