From patchwork Wed Jun 19 20:59:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 805643 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp14392wrt; Wed, 19 Jun 2024 14:02:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVis0dNd/GHTPjEB5r9GnjWKKZYyyOT15JDj1+RQo92Ps/hhar5XwpU2+Cv/56e+CdO7eaaKlZIu9uf5sJhxJSF X-Google-Smtp-Source: AGHT+IE7kgtD6F4gtyCIO3VuQcDfFGJCrzSXJHYi6hny62Q14pSCXv7Wl4S6BStw9Y4aZdWu0bEK X-Received: by 2002:a05:620a:2990:b0:795:967d:b1f4 with SMTP id af79cd13be357-79bb3ee6c91mr385495285a.70.1718830951449; Wed, 19 Jun 2024 14:02:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718830951; cv=none; d=google.com; s=arc-20160816; b=TUywq02wbGc4SiujVrXd6NWXM+KlpreY3FEqFkclF3N5f5s5UHdXQWTX8UvFPusnCv Kd0DoPRECHx/ALNdU/WkwRhBOHDPqQQf/yUaXX7GUYVL7j6KF7/EyM8OlPoN8c/V4h7w ryczvIcbv0DdZNX8sOTnr/kU6qniEvpt+7S/UO9Y+WzZXRWQbnV7EyrSaHcdqjW4VOD+ 7zTsEc23/tRM+Fn1zqIRI0vnOroeLO1/VGf2rSUqbiNZKBlS7Yq1YNH/l8GiJy5fDn6b 0ywfDsjOt0QSDx+v5JEpxoCFCUUhEyNl7lHpkT0ybxKCCy/F0uAu6dFbHdKhquzeNFKm ht6g== 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=/+Ozu7ks7y96Kn86P8uNW/7FLhNhS83VVYtywBJAgxk=; fh=KXT8skN7RFTc7N6YjUNlSMSjM9WXZW43UAg6bOEDSoc=; b=nvLG5Y9PzoBJV7chsavKldtR/ry959vslp5eOzUISbDNhQM+Kb2KUo3pZnEyeozkKp xUvHu0fr5QW3QvA+ax3uIEYBweK4JlfDlqlyKIha0ByS4YgzCxuQdx1rqZDK/nZ+ehlp t0cNwx9HMiLedz3Ou8uwq65l6Ce6oBCQ3Ikza14KE4yZrCEQNg77n7rK05uq5nHX/qLC PwG32c6+r0UsRJTVbSqOwujbpdyf8uJMbv+yE51sbCJe/nOC4ItxpR119VmpRXwkiCnO s86JcL/n16doPfFdDDXq/+H7xTEc+UdQjpK94R4pbtZPsJeQWszMXaIekBmZGlP9X3co qoYw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H7n1dsR7; 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 af79cd13be357-798aac9bcfbsi1519569685a.93.2024.06.19.14.02.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Jun 2024 14:02:31 -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=H7n1dsR7; 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 1sK2Pd-0002Ge-Pd; Wed, 19 Jun 2024 17:00:13 -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 1sK2PZ-0002Dt-5d for qemu-devel@nongnu.org; Wed, 19 Jun 2024 17:00:09 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sK2PW-0000ZT-Gq for qemu-devel@nongnu.org; Wed, 19 Jun 2024 17:00:08 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1f9aa039327so1636525ad.2 for ; Wed, 19 Jun 2024 14:00:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718830805; x=1719435605; 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=/+Ozu7ks7y96Kn86P8uNW/7FLhNhS83VVYtywBJAgxk=; b=H7n1dsR7FOtmaJXG/rBsdgeq2GnelmMBK543ap3IeKuCJ9RVOHh9KQUXiC0U2gtbhe TdMDXbv7dNDXgtzzPCrmNrbpk+9OCeznIoiHFMFC5GaY+Vrw4h3ZRDzGmXW2YnMTsG/Q KWLgOZd4+hxxX4eGMUwcbUnyca2qfjPry6W5XuglvHm+dhKSAFn4h9XqTKxBK92QrDwK 08BmvgYiwcYOn3B+tFIVFjknzDOrE/QENITJsUddqSigbg+il6kkZjYFlHs5o1KuLeei K3Ayn5aLn5H6OJf3gJmlXPoQ/sZHfcze2/8ZiPQ2jT+5StYnlyWXJBBjd2xsZGQQO3TL Ermg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718830805; x=1719435605; 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=/+Ozu7ks7y96Kn86P8uNW/7FLhNhS83VVYtywBJAgxk=; b=TQdoSD+CBJiFnvVSuJ1w76yDQgwbRMCPZDLR7z2RpyC8FCc1oS73CTFG6rP+cqfofR puX6e8MGRWmaOB6+C3p2j9ydpItB0oAN0SW0Jm/7fhic35IcnGc7e3kzMjWrcPHzo9O8 WBNEdLgx9XymGQqi8xxzP3xxTrUnZxQi6kDgzb3ugqDOI5X2mo2nGKRtJYRo9psbeQwY B3tARyern/tishyGHT4iOqeDsZu5oJhY9Dqq31l/+qndfohCHWe4s3Pub3qKgneSGa2o DpbPbrQEZs3RVgI6zi/WcCne6D7dnIGRa7rXFprAJv3cKRKW0Y3DZgJyiYiGhMko/usR hjMw== X-Gm-Message-State: AOJu0Yzu8WIVMNkGqty0blx8JncipVoE0ZSsmqv/kB7JK7Lum0LijX1Z SetMFJK4lZhX6fyR3D3vfh/lmmdmMMUHvau8x48hhz5SDqNp2UTwX9uwaUIvDnn8GkdVI2Ki2k5 Y X-Received: by 2002:a17:903:22cd:b0:1f9:9ea4:6b50 with SMTP id d9443c01a7336-1f9aa44fc30mr39389665ad.52.1718830805110; Wed, 19 Jun 2024 14:00:05 -0700 (PDT) Received: from stoup.. ([71.212.132.216]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f98f8f8c42sm39183765ad.162.2024.06.19.14.00.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 14:00:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Song Gao Subject: [PULL 11/24] tcg/loongarch64: Simplify tcg_out_addsub_vec Date: Wed, 19 Jun 2024 13:59:39 -0700 Message-Id: <20240619205952.235946-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240619205952.235946-1-richard.henderson@linaro.org> References: <20240619205952.235946-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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 Reviewed-by: Song Gao Signed-off-by: Richard Henderson --- 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,