From patchwork Sat Oct 28 19:45:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 738954 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c47:0:b0:32d:baff:b0ca with SMTP id n7csp481123wrt; Sat, 28 Oct 2023 12:47:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFU3v5GbiTF4ZDKOzpxKC8JB5J9jAUu4sbBfCfZW+hYUiWGluiKozvgJJRV0JuRCk3kUtFT X-Received: by 2002:a05:620a:2589:b0:778:94cc:723 with SMTP id x9-20020a05620a258900b0077894cc0723mr7046017qko.1.1698522460387; Sat, 28 Oct 2023 12:47:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698522460; cv=none; d=google.com; s=arc-20160816; b=Uv8QV+TkDi3ro7k0zN3eXLAznu/rGE6bgHYztU60f07O2XBch6FQInhZs+b4Jcq7ys s+0DK+doBuUWuu/g8ddfnD++mQTtBHvRJltvcvgZuHasIe5at4s25gNX0QtWidpOhIOo IrjuzPcGWOwi2YMh0HjXfQ3GJ0OLBmXYFN7HFHNtAOSbd7jRrEasqsf7mu+mbsFo3oHd azNGt4DosL77FSP/PjOEHoaSahgRezIUgX9RuANBu8VahmBLBM7Mq69rqhhGvyrooHwm CrxVJRfw9Rw7w3GE/xzWaCY2sUXKxQ/RzoPnipDVC18Oc88x8dLTaCgL7Ka/nTkb/D6N 5xYA== 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=JJ1WN/0iuBwc2NCK63JpHvn6inIzrDX6DykcbHZYqkQ=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=dqnIfFcSb2GhFLEMoesRfUyuv/ReuyyS2eAfrffurYpMI057nTog66yHcy3Xsr6YT3 FACL1fqsD3VFkGDsta/U31CDEtVjdhtrpCd2q8hpD98zunY/OtEg9s4FdsVfv8HJn4DZ CAAAyP38dpuCMDGSunPFSZyD54Nu64Fl1lRl/cjEBZbF+23ze42j91I12jRkEBZH9/al +KYyhkR2dcT/Dz09Yw2nytVNs5xFUaxNOVlZT0952TThKYxincusuZ3mbDqFeHsOsDuU shVQVa7xv7XTqmKAQhgcnpW/Ai1nFhvYSJSEsreGLw2qqvXIuOA/8Q91qzpPlAXQLXGu Oysg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lCQZL2vN; 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 i1-20020a05620a404100b00767dfe07ec4si2867458qko.164.2023.10.28.12.47.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 28 Oct 2023 12:47:40 -0700 (PDT) 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=lCQZL2vN; 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 1qwpFz-0004uR-2O; Sat, 28 Oct 2023 15:46:03 -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 1qwpFg-0004kn-3I for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:49 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwpFe-00048a-Dg for qemu-devel@nongnu.org; Sat, 28 Oct 2023 15:45:43 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1cc0d0a0355so20257935ad.3 for ; Sat, 28 Oct 2023 12:45:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698522340; x=1699127140; 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=JJ1WN/0iuBwc2NCK63JpHvn6inIzrDX6DykcbHZYqkQ=; b=lCQZL2vNTmhwUS/CqGbpr96K3gD6oh4v7DKcV+QfcJWC1X8zITg4t5sQ5HLh6gNUR8 HHt9VkFLVemHlPE4pQfsIzp6NBd1RbCEeql7YeACYkgkyB+MfOqbgI2FFBWoSDo4E/b3 NoxSoTnzGPyrlh8hwfmGnzhpdi4FXI6MOZHB56kE8LlLP3gmyC7SxYI0cIOdjWi00isf SA+BhP7ltvmX3M3HF//C4lSXpd+QSxO1DYsh5nXnGtwE7Ov4Z45YxbOSbUTjXGaCopA4 d9fZON+rsZ1hhudkZimuEeLHfi/tdgwhcE0+UNk1Rc/ipbl9t+x5he2vpLwVSIH1DXbu 2B9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698522340; x=1699127140; 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=JJ1WN/0iuBwc2NCK63JpHvn6inIzrDX6DykcbHZYqkQ=; b=mMw2pYWuph2awWpNYdlY8n0GzU+k4GWkycm0szV1IbvyrrXCSs+zR2dNCzuna4D1Bu F0yZZPmT8ASttVRuIfpTjwy4DmvBmHUSHjHH2xJtsR3bsbDbCm4C8t1J/gyP040ojuFn Jh1cbYXXZmqDgXL5z08bRY/zY79MkxfY4Pvo+E1rNXFgQSKiy3KCuDH92XyofzIT7C9g wk/8+xfKvhcuPqiNgKp9aohRlvobkFLQxuyFg8xzRvrEI76qH6gDphkFg8n0R5zx5cTo UNzIY6mZOt8aQ64OR9tsODFI5H1AqL+L24XB7lkVQz3gGV4sjQQuHnT9Hz50Nogf7J7T BPpw== X-Gm-Message-State: AOJu0YwwkuVSMqHqUh90HdNx1dyaX38jlpBRvDmF+FF3u9bOa3DihdV1 BBxAKHq3VJm+o4AqcKYlSxhaJRF9ryhl1tgfb8k= X-Received: by 2002:a17:902:fa4e:b0:1c9:d667:4e85 with SMTP id lb14-20020a170902fa4e00b001c9d6674e85mr4449665plb.40.1698522340613; Sat, 28 Oct 2023 12:45:40 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id h9-20020a170902f7c900b001b8a3e2c241sm3600096plw.14.2023.10.28.12.45.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 12:45:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v2 18/35] tcg/riscv: Support TCG_COND_TST{EQ,NE} Date: Sat, 28 Oct 2023 12:45:05 -0700 Message-Id: <20231028194522.245170-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231028194522.245170-1-richard.henderson@linaro.org> References: <20231028194522.245170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tcg/riscv/tcg-target.c.inc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 639363039b..358579b3fd 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -799,8 +799,14 @@ static const struct { static void tcg_out_brcond(TCGContext *s, TCGCond cond, TCGReg arg1, TCGReg arg2, TCGLabel *l) { - RISCVInsn op = tcg_brcond_to_riscv[cond].op; + RISCVInsn op; + if (is_tst_cond(cond)) { + tcg_out_opc_reg(s, OPC_AND, TCG_REG_TMP0, arg1, arg2); + cond = tcg_tst_eqne_cond(cond); + } + + op = tcg_brcond_to_riscv[cond].op; tcg_debug_assert(op != 0); if (tcg_brcond_to_riscv[cond].swap) { @@ -828,6 +834,7 @@ static int tcg_out_setcond_int(TCGContext *s, TCGCond cond, TCGReg ret, case TCG_COND_GEU: /* -> LTU */ case TCG_COND_GT: /* -> LE */ case TCG_COND_GTU: /* -> LEU */ + case TCG_COND_TSTEQ: /* -> TSTNE */ cond = tcg_invert_cond(cond); flags ^= SETCOND_INV; break; @@ -887,6 +894,15 @@ static int tcg_out_setcond_int(TCGContext *s, TCGCond cond, TCGReg ret, } break; + case TCG_COND_TSTNE: + flags |= SETCOND_NEZ; + if (c2) { + tcg_out_opc_imm(s, OPC_ANDI, ret, arg1, arg2); + } else { + tcg_out_opc_reg(s, OPC_AND, ret, arg1, arg2); + } + break; + case TCG_COND_LT: if (c2) { tcg_out_opc_imm(s, OPC_SLTI, ret, arg1, arg2); @@ -1080,7 +1096,7 @@ static void tcg_out_movcond(TCGContext *s, TCGCond cond, TCGReg ret, int tmpflags; TCGReg t; - if (!have_zicond && (!c_cmp2 || cmp2 == 0)) { + if (!have_zicond && (!c_cmp2 || cmp2 == 0) && !is_tst_cond(cond)) { tcg_out_movcond_br2(s, cond, ret, cmp1, cmp2, val1, c_val1, val2, c_val2); return;