From patchwork Mon May 27 21:19:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 799253 Delivered-To: patch@linaro.org Received: by 2002:a5d:6a08:0:b0:354:fb4b:99cd with SMTP id m8csp26209wru; Mon, 27 May 2024 14:21:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVPaXYETeK5vLfVWB+SZ7ci1n7dhrtyofVxBQwohUF8yKTIfY7h1R6mgIlAk91CGt5TURsFe4M0dfGoI+43tAhG X-Google-Smtp-Source: AGHT+IFJ+GTy3XdGIKgdNEBFvP7pdrelxDynbtbiU093BShnZ1tyHa0XOvD5hcSpBYLDz5H0ieYd X-Received: by 2002:a05:6214:3d87:b0:6ab:898b:42e7 with SMTP id 6a1803df08f44-6abcda62be8mr118749036d6.65.1716844887647; Mon, 27 May 2024 14:21:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716844887; cv=none; d=google.com; s=arc-20160816; b=a0fjXBmKuY7Lk8u4/2VEVGr9lYMOr6q4dP4ZVj7VhvjNUyOJHbw1ilOl3UB6fLkrvq jh1lKKNcYj3cKOqu6A/aNrtX5uLudyrgjliwx4TiDWZJIA7ukSpvbJR6KqBqT9vaStis IhJYwScHDx4YDjpPERkFSzfg51cC0kdFS0mD5IkJfYwtmT1AXda5oTQmczwUdE6c3g0B Y1V1y9m7LGVAH03RNhkJxyBN5RQkfjv8fX0vqvxFR+3CcA+j6xeYCcjC+rdqanBECfYb PeOCJk7F9L9rMBlFAzN3ur1IgfD1Z2od6Tc11KBdBeL1OPHQqon/1zlVPaWRC6V91NCK DTJA== 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=KXObFDu8a3M57Hv1fEFHdefFhD2xo5Ijf75RZMjb8TM=; fh=hzNNYKTacOnX/pFrTgMTyElWGK9kyvH1o007fnxf7fU=; b=SaoOOE3qvAJIivQKp0wVqQ7CwbBfPLHHv2TFTYuUw/0ilnaICoPduI59/mFv+nHVeH P4jB3d0EKyv+ZgXJFbNKVHWVE03Xbqu29vsEFK6uYKd6QqKV4R3qPU7svEMk8ne2fL9S G7TEmpqzXH7N8Kn1VH7cdEA5GqWkzS5f3ozI+fXWbWIilU/nAeViR4/UjJQU6lX/SgyY MxmLgD+IQc3+iM0RV0FHMhEAEzhOZ2a09IAmOu85fZ7jRd85pzNB/AZwmBKTKUEzKf0T bDctd7w5uTXhozFZFUZXn9DEI65m0pyo28kvg/lnPCBgJ72cGY+dLSTUP7/HgzDi2ss6 2G+g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RO+mzuhA; 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 6a1803df08f44-6ac06f4eeafsi89053076d6.8.2024.05.27.14.21.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 May 2024 14:21:27 -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=RO+mzuhA; 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 1sBhke-0007EB-3C; Mon, 27 May 2024 17:19:28 -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 1sBhkc-0007Cj-NO for qemu-devel@nongnu.org; Mon, 27 May 2024 17:19:26 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sBhkb-0003eE-3i for qemu-devel@nongnu.org; Mon, 27 May 2024 17:19:26 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6f8e9555eabso104817b3a.1 for ; Mon, 27 May 2024 14:19:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716844764; x=1717449564; 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=KXObFDu8a3M57Hv1fEFHdefFhD2xo5Ijf75RZMjb8TM=; b=RO+mzuhAk+FNhSya1eBk4xlxLcPDfN8jeYOE6dtj1Lhu36rDdQHsVa/dc5wIz5+jps /s1u4dTJsT5KlyyENTFSKdqxgcvfOsOgU9+Cudv6+whdytSBDKx6PJRZQ40KFiYYSDdw MvJjE6rHWuC4cHwNu7TDZ6pAQCFZlnOcLBYVnLRCZwY8RsEdPnVuKHIq+vsN2ci3Vika zcEgSn+atf3ZfaRAL0HfgR+XPegSNqLtXakawHPMhthyt1IGCk9bsbuKiHa22qMPC4vG pnltI4QOcElZae8cSRiQS+cDr0Ej56uP0YaFCWFCTOR+JG95bR8E2zQxjNj7op8FZxzD B+8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716844764; x=1717449564; 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=KXObFDu8a3M57Hv1fEFHdefFhD2xo5Ijf75RZMjb8TM=; b=X9lHSSMSgvppBvmP716mNP4O5vifU63udkCLNRhdV74dKzY3LuZ2JHYJoqZKH04B2P lcn2ME0tkmYQFCNzoGfB/acP5u7l8EZcSsxENWmOmoxkbB0yfMho/KnypCIquqOl80Sm scJVv/sFxTKK1MD3y9DlKiBM5HYUDQ1JM0O9BquzZe56K87dDxVNtpeRrk5sUCxvDtZW JR1hcttcmo/sR7oAfnmHT4DKs80dmJYz7X7/US155yXPTQCd8VnJwyjfNVQQ/4GeuGgO b63C6sCPKYtwYl1INthhyShu93uO36DMypYYjS0HBkAuElS2KvypRQtUt0OzmvcF5V0+ SmDQ== X-Gm-Message-State: AOJu0YxRLyZrt5vreySoyDXYSWH00MnvGbqKDcS6xOPG8dgNSGCYBlhv BaSiU+TkRITdQwfIZ4ZKBUri6v/oLajEgXv6xN6qQM57SpXor9E/6pxEguIYEbfrygLtE5I4egB s X-Received: by 2002:a05:6a00:4c12:b0:6ed:41f3:431d with SMTP id d2e1a72fcca58-6f8f1a6a5aemr11447070b3a.0.1716844763798; Mon, 27 May 2024 14:19:23 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f8fd1d4d5fsm5265876b3a.165.2024.05.27.14.19.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 14:19:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: git@xen0n.name, gaosong@loongson.cn Subject: [PATCH 11/18] tcg/loongarch64: Simplify tcg_out_addsub_vec Date: Mon, 27 May 2024 14:19:05 -0700 Message-Id: <20240527211912.14060-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240527211912.14060-1-richard.henderson@linaro.org> References: <20240527211912.14060-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.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=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: Song Gao --- tcg/loongarch64/tcg-target.c.inc | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc index c7d0c7839b..47011488dd 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -1774,33 +1774,34 @@ static void tcg_out_addsub_vec(TCGContext *s, unsigned vece, const TCGArg a0, static const LoongArchInsn sub_vec_imm_insn[4] = { OPC_VSUBI_BU, OPC_VSUBI_HU, OPC_VSUBI_WU, OPC_VSUBI_DU }; + LoongArchInsn insn; if (a2_is_const) { int64_t value = sextract64(a2, 0, 8 << vece); + if (!is_add) { value = -value; } - - /* Try vaddi/vsubi */ - if (0 <= value && value <= 0x1f) { - tcg_out32(s, encode_vdvjuk5_insn(add_vec_imm_insn[vece], a0, \ - a1, value)); - return; - } else if (-0x1f <= value && value < 0) { - tcg_out32(s, encode_vdvjuk5_insn(sub_vec_imm_insn[vece], a0, \ - a1, -value)); - return; + if (value < 0) { + insn = sub_vec_imm_insn[vece]; + value = -value; + } else { + insn = add_vec_imm_insn[vece]; } - /* constraint TCG_CT_CONST_VADD ensures unreachable */ - g_assert_not_reached(); + /* Constraint TCG_CT_CONST_VADD ensures validity. */ + tcg_debug_assert(0 <= value && value <= 0x1f); + + tcg_out32(s, encode_vdvjuk5_insn(insn, a0, a1, value)); + return; } if (is_add) { - tcg_out32(s, encode_vdvjvk_insn(add_vec_insn[vece], a0, a1, a2)); + insn = add_vec_insn[vece]; } else { - tcg_out32(s, encode_vdvjvk_insn(sub_vec_insn[vece], a0, a1, a2)); + insn = sub_vec_insn[vece]; } + tcg_out32(s, encode_vdvjvk_insn(insn, a0, a1, a2)); } static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc,