From nobody Thu Nov 28 10:40:50 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1692822439; cv=none; d=zohomail.com; s=zohoarc; b=aVGjwd75pgjmzfx+I6ptljCn2772RqlBtDEmtL045OT10m4Z3mQUoOgb5DjkmekycabtjB7J6d3ydVu6oXRo1DM4aoRwpf0nbXmMVT4eDwEXBoJMWw1lA2VKxcJ5QgLy2+iTRwGonmqnslzgxz5MaeG3Ij/dq3H1o+1ufqwUgXA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692822439; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9xk1+CqOJWdeIJliIlUjmMI38qlOB1/l73hqKwcbuPU=; b=JgBEroZ9zgcGKtai4kcC+fVzGJxQD1RxQs052fomMSO/pgd64Lk5QysiwFx7VB5XFFI8BOctzAjOow1B0SZ74VPsHeTYNYIxLkCJBEcoUGCTo5NOFzCIRmkjyP3qiHpF4pUOK5WidlKd8+6ot03ylz8rQDPpWZvHbWuQ7QcoUd0= 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 1692822439360298.61975752910143; Wed, 23 Aug 2023 13:27:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qYuOi-0000JZ-8M; Wed, 23 Aug 2023 16:24:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qYuOb-0008Sm-Ql for qemu-devel@nongnu.org; Wed, 23 Aug 2023 16:24:05 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qYuOX-0005Y8-Ga for qemu-devel@nongnu.org; Wed, 23 Aug 2023 16:24:05 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-68bed2c786eso170186b3a.0 for ; Wed, 23 Aug 2023 13:24:00 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:72f0:1ea7:85d2:141e]) by smtp.gmail.com with ESMTPSA id iz22-20020a170902ef9600b001b9da42cd7dsm11418641plb.279.2023.08.23.13.23.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 13:23:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692822240; x=1693427040; 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=9xk1+CqOJWdeIJliIlUjmMI38qlOB1/l73hqKwcbuPU=; b=FGsldhpldi5c+MmYENtFBEeKgglocEIXXd3mfsgrDSlezn99WSuFxwrd+pYype+rhC qsnRwzI8Gc8xKkMm07LWmlHQHml1JMSusnUJOsiiMeAJEq27B3uz1FuDcKZlWiVHbePk f1wME7UehBvyBacLZWXqvLZhCK0Q5AE8dIbG5jrOwS5Q35vjqr6IkY8Z1VOBWxXE29MQ VxyV0ppiBZ0o3IKFjjWE2KIbumZhkeWbryqXNOJTNxB7SuGl4A4RmNtkQg6RVRs5cLR1 7JPAFpdryIB2fmMbw5qyptqRWE8EzlmjAle6a8vPFj7AwT4uvedSriBxq/Y8JDYgcHPv ppBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692822240; x=1693427040; 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=9xk1+CqOJWdeIJliIlUjmMI38qlOB1/l73hqKwcbuPU=; b=T88cJh173wiA0dJs0H7YET9RGjIZtuiA0HXu4i+UXMoxkd/iB5VQHDlGO4TwwQ2Uk6 23hqny16D+vSeMjNjnMfOtyNqqDu45ROUWeBVgFwi1AcWvJGOM/M+2nQwV7KPSDp7rak SVQMtKJLJCGmmi/FwjqXg3r5APVvVIX+7VdQDUnc3vSxOepO6Cj9SyYkSUTZ9C2SILEq R9G7BiNR3WNNIthLWtmymiGi7J6iRW66WSHE+AwMOS3gfHl1PpSxfwbI19RpmNWjBO9E ZRuvNpMJimcp+fggxKntL3qidWmyHf3dvTDjtLbvMhIkx12pBQCVthdSOKFcafScHLGI fxcA== X-Gm-Message-State: AOJu0YyXAjch1LSfxt2yXy84fiKZeHo6aOIWeBNnBZI6xfYFLwYpMk+O JoiIhdUgOoRpXaoke0w2kVnWFNWlgac65V7Yph0= X-Google-Smtp-Source: AGHT+IESF6wfuKvMlVqVlXFRT49MUbdXMT91tpr5P4FHUwZcewZmY0tJLkge6aSNer/DPp4DMkUzUQ== X-Received: by 2002:a05:6a20:969a:b0:147:d309:be7b with SMTP id hp26-20020a056a20969a00b00147d309be7bmr9855861pzc.62.1692822240060; Wed, 23 Aug 2023 13:24:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Peter Maydell Subject: [PULL 35/48] tcg/i386: Use CMP+SBB in tcg_out_setcond Date: Wed, 23 Aug 2023 13:23:13 -0700 Message-Id: <20230823202326.1353645-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230823202326.1353645-1-richard.henderson@linaro.org> References: <20230823202326.1353645-1-richard.henderson@linaro.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=2607:f8b0:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.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 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 @linaro.org) X-ZM-MESSAGEID: 1692822441319100005 Content-Type: text/plain; charset="utf-8" Use the carry bit to optimize some forms of setcond. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.c.inc | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 1542afd94d..4d7b745a52 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1531,6 +1531,56 @@ static void tcg_out_setcond(TCGContext *s, int rexw,= TCGCond cond, TCGArg dest, TCGArg arg1, TCGArg arg2, int const_arg2) { + bool inv =3D false; + + switch (cond) { + case TCG_COND_NE: + inv =3D true; + /* fall through */ + case TCG_COND_EQ: + /* If arg2 is 0, convert to LTU/GEU vs 1. */ + if (const_arg2 && arg2 =3D=3D 0) { + arg2 =3D 1; + goto do_ltu; + } + break; + + case TCG_COND_LEU: + inv =3D true; + /* fall through */ + case TCG_COND_GTU: + /* If arg2 is a register, swap for LTU/GEU. */ + if (!const_arg2) { + TCGReg t =3D arg1; + arg1 =3D arg2; + arg2 =3D t; + goto do_ltu; + } + break; + + case TCG_COND_GEU: + inv =3D true; + /* fall through */ + case TCG_COND_LTU: + do_ltu: + /* + * Relying on the carry bit, use SBB to produce -1 if LTU, 0 if GE= U. + * We can then use NEG or INC to produce the desired result. + * This is always smaller than the SETCC expansion. + */ + tcg_out_cmp(s, arg1, arg2, const_arg2, rexw); + tgen_arithr(s, ARITH_SBB, dest, dest); /* T:-1 F:0 */ + if (inv) { + tgen_arithi(s, ARITH_ADD, dest, 1, 0); /* T:0 F:1 */ + } else { + tcg_out_modrm(s, OPC_GRP3_Ev, EXT3_NEG, dest); /* T:1 F:0 */ + } + return; + + default: + break; + } + tcg_out_cmp(s, arg1, arg2, const_arg2, rexw); tcg_out_modrm(s, OPC_SETCC | tcg_cond_to_jcc[cond], 0, dest); tcg_out_ext8u(s, dest, dest); --=20 2.34.1