From patchwork Tue Apr 15 19:24:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 881329 Delivered-To: patch@linaro.org Received: by 2002:adf:f902:0:b0:38f:210b:807b with SMTP id b2csp638721wrr; Tue, 15 Apr 2025 13:09:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUkozbe4gUBV1wJ+TE2G/nA9hH8vnzUiPfAZECHHWxNwR9bacjiMcOFBsmhnV8t3r8xxwA3jQ==@linaro.org X-Google-Smtp-Source: AGHT+IGsb7Ws82cnVr7BOp/j8/Nz90cgcis1ykdBeJ3lwFxcYOj8P4wRIOygRWSOhkT3js3b918s X-Received: by 2002:a05:620a:3188:b0:7c5:4be5:b0b1 with SMTP id af79cd13be357-7c914240fbemr121282885a.35.1744747753057; Tue, 15 Apr 2025 13:09:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1744747753; cv=none; d=google.com; s=arc-20240605; b=F+c3Cuqivtc1xEd8mnf4Jcj2YkYRhT9ok9gMi+5XTvbwS4zy/aQ+jGVpQZpJ+nB5dk OGUoYKsMrWS2BumANXbdUfw2f1hrbf/kN/FXjXT+xK+r8I9a/xQXO74R7dU+h6X62KJk Gbc9I8O5ypPmy1zu85sNCdirtBMwjNNJQREkCezZtQAbeSYJhyYVh7RfDTQws2+jt2WN l+358Z2wDvLBxF8fiT52BE6t/AhmV2WXwcrVSxpZgTrU/dZXkNySlMS8e3MhzJcSdPeK oeb+zuat+M9A7YPs99Ub72ENQVLO3RhmKLQ1IxUg7aJfUyQ5mbdFtoy9rin34WpNaWiS XRiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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:to:from :dkim-signature; bh=nI/M/IwczebCOlajrhzp8aQhsqTUe7nxt6KRZlFvdew=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=kFyIFPtRmD6msoMENfqQSRZHja+d3dK0sa5O9H3a57/xf2VI7ft9FTntY+YLxrAMqc kzLQVeVL3ylk1UzxbKcysELIERMonPLCXQXMZbXz15WT2bHWebjxgDHuvWhVrFIwiRLe xnS1rS7ibO3UqaehF5nRW54MJDK2AlVbI/dXscJRgtxyDBrqu5RHNgplsiZr+5o75i4K fpyKOxecN85Dhujo1g5/HlcXC2Ee5gWwb1kua/1NtU6/k0fbDfLG5zmk9eNzKMrED0Zh D9KdQGl7blvaRwjN/E5g8qNAUUvqv9nqmEPC0ub/euG6QFNDTDGJmLl0MbwJTwu8IeKK duSg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C6wT4vEX; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7c7a89f5116si1124334485a.225.2025.04.15.13.09.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Apr 2025 13:09:13 -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=C6wT4vEX; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u4mB5-0008NN-Am; Tue, 15 Apr 2025 15:42:39 -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 1u4m2r-0004ru-3I for qemu-devel@nongnu.org; Tue, 15 Apr 2025 15:34:11 -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 1u4m1k-0002xC-QD for qemu-devel@nongnu.org; Tue, 15 Apr 2025 15:34:06 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-2264aefc45dso88975615ad.0 for ; Tue, 15 Apr 2025 12:32:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1744745569; x=1745350369; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=nI/M/IwczebCOlajrhzp8aQhsqTUe7nxt6KRZlFvdew=; b=C6wT4vEXZOj92v5ecQLl7I8xx63GHQZfgu6DdrlNz3vaeVzSbo+MsAXAhieJ3lCfQO vFd75/90Lue8NhYAyJuaq6HTG6bMX6CRZCUG3nYWSS/LmoAGatT2MIabE/ou3pHXLpCS 1F6/sYVKmT9QED+v+Ha/TfL0zOoPp9oeYmun3eryQ7ItwhPrjSFeqi+FTj4/d7c5CpM/ q6gH3aK83xKHErFfUKt84Zh5UEGB0wJ2nkdYqb+g52dFOiFQnTgSIoNqIjRWJgWGr/KE hE0brQf8SdBCMKR3TXCOBhFYttS0JIKnzvVwG5x5uYaDONq2gbShrLTnb7qZQ2pBiQHS T83w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744745569; x=1745350369; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nI/M/IwczebCOlajrhzp8aQhsqTUe7nxt6KRZlFvdew=; b=F5Va7Ga+JOsXpM0xJX7p/SWrrEW4UM/TNYlk5fyi19onfac4GvVMJx3bj1X0+ZqCOJ PQg9J/BuHFtwZY6IBiP9GmODLkm8kH1GJFpUVPTixaTt8Qmyhpjih/AKb7ytfRllUTp/ i1bCpq51R71bExnrjjJMKnsrrvS87QRuPNbECmkn+5EyEXKDkhuZ5atOC0iirN/FMiLy /TgfCXowevF5/CqusBzCadiBlEfLZwa6GaW+OPmkn2UZ9ONyxMLvlsQa73XoSMtC91+p VaUmvDXPb7lo619coMQWValF4pjA5LbxIU385qcnQ+JJOfvZYVu2iqPIsYKMvSipfA5o owJA== X-Gm-Message-State: AOJu0YxsuBVaGGoVvA8HY7zDubIjEgy4e71IBvxKTeCJ89nxQ7ItDEqq 4uE/1YFRSysu39QGZz7/UsluLjpvExQskVzefxiFvLil1s8tg909k+Ds9sF5/fkh3QLC74ceIP7 t X-Gm-Gg: ASbGncuS1vxbhf/hdJUB5LNfpBoQ5PATKllwnw1k9h4zQRb8Kg9GUoTv3iol+tD/xVi SIGLpKjb/O+fnSnilN8bUkQWTiPLkSROSNpt5clEwMG/YjL3ztVjB6JP+1zlIfMwGNer9xAY1qX YMi6rw8jMwZdQfP2KHmVO+E+e2UCUBb0nT3hSkI7BPsJNiaFwQGvgoUNNeXHHukmihCpM4clVnJ DynCT/7yhBpCI3xH7TOlxGFaWba3x5fVopdr0PFBSIo0QtZsFzGFZY3PspgYzd0oKaN129icZfL HdqBemOCQR4IFmSdGwXjQWJpj6FCLJhrUDgH9zw4P4TlTdnaOD3pO418/yXrLZUQgQDv3fo6lXc = X-Received: by 2002:a17:902:db07:b0:224:23be:c569 with SMTP id d9443c01a7336-22c319effd7mr4838385ad.22.1744745569225; Tue, 15 Apr 2025 12:32:49 -0700 (PDT) Received: from stoup.. (71-212-47-143.tukw.qwest.net. [71.212.47.143]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22ac7ccbd5esm122062355ad.248.2025.04.15.12.32.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Apr 2025 12:32:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 110/163] tcg/riscv: Drop support for add2/sub2 Date: Tue, 15 Apr 2025 12:24:21 -0700 Message-ID: <20250415192515.232910-111-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250415192515.232910-1-richard.henderson@linaro.org> References: <20250415192515.232910-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 We now produce exactly the same code via generic expansion. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier --- tcg/riscv/tcg-target-con-set.h | 1 - tcg/riscv/tcg-target-has.h | 6 +-- tcg/riscv/tcg-target.c.inc | 86 +--------------------------------- 3 files changed, 3 insertions(+), 90 deletions(-) diff --git a/tcg/riscv/tcg-target-con-set.h b/tcg/riscv/tcg-target-con-set.h index 5ff2c2db60..0fc26d3f98 100644 --- a/tcg/riscv/tcg-target-con-set.h +++ b/tcg/riscv/tcg-target-con-set.h @@ -18,7 +18,6 @@ C_O1_I2(r, r, ri) C_O1_I2(r, r, rI) C_N1_I2(r, r, rM) C_O1_I4(r, r, rI, rM, rM) -C_O2_I4(r, r, rz, rz, rM, rM) C_O0_I2(v, r) C_O1_I1(v, r) C_O1_I1(v, v) diff --git a/tcg/riscv/tcg-target-has.h b/tcg/riscv/tcg-target-has.h index b2814f8ef9..c95dc1921e 100644 --- a/tcg/riscv/tcg-target-has.h +++ b/tcg/riscv/tcg-target-has.h @@ -10,13 +10,11 @@ #include "host/cpuinfo.h" /* optional instructions */ -#define TCG_TARGET_HAS_add2_i32 1 -#define TCG_TARGET_HAS_sub2_i32 1 #define TCG_TARGET_HAS_qemu_st8_i32 0 #define TCG_TARGET_HAS_extr_i64_i32 1 -#define TCG_TARGET_HAS_add2_i64 1 -#define TCG_TARGET_HAS_sub2_i64 1 +#define TCG_TARGET_HAS_add2_i64 0 +#define TCG_TARGET_HAS_sub2_i64 0 #define TCG_TARGET_HAS_qemu_ldst_i128 0 diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index d74ac7587a..dce46dcba6 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -401,7 +401,7 @@ static bool tcg_target_const_match(int64_t val, int ct, } /* * Sign extended from 12 bits, +/- matching: [-0x7ff, 0x7ff]. - * Used by addsub2 and movcond, which may need the negative value, + * Used by movcond, which may need the negative value, * and requires the modified constant to be representable. */ if ((ct & TCG_CT_CONST_M12) && val >= -0x7ff && val <= 0x7ff) { @@ -1073,67 +1073,6 @@ static bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, return false; } -static void tcg_out_addsub2(TCGContext *s, - TCGReg rl, TCGReg rh, - TCGReg al, TCGReg ah, - TCGArg bl, TCGArg bh, - bool cbl, bool cbh, bool is_sub, bool is32bit) -{ - const RISCVInsn opc_add = is32bit ? OPC_ADDW : OPC_ADD; - const RISCVInsn opc_addi = is32bit ? OPC_ADDIW : OPC_ADDI; - const RISCVInsn opc_sub = is32bit ? OPC_SUBW : OPC_SUB; - TCGReg th = TCG_REG_TMP1; - - /* If we have a negative constant such that negating it would - make the high part zero, we can (usually) eliminate one insn. */ - if (cbl && cbh && bh == -1 && bl != 0) { - bl = -bl; - bh = 0; - is_sub = !is_sub; - } - - /* By operating on the high part first, we get to use the final - carry operation to move back from the temporary. */ - if (!cbh) { - tcg_out_opc_reg(s, (is_sub ? opc_sub : opc_add), th, ah, bh); - } else if (bh != 0 || ah == rl) { - tcg_out_opc_imm(s, opc_addi, th, ah, (is_sub ? -bh : bh)); - } else { - th = ah; - } - - /* Note that tcg optimization should eliminate the bl == 0 case. */ - if (is_sub) { - if (cbl) { - tcg_out_opc_imm(s, OPC_SLTIU, TCG_REG_TMP0, al, bl); - tcg_out_opc_imm(s, opc_addi, rl, al, -bl); - } else { - tcg_out_opc_reg(s, OPC_SLTU, TCG_REG_TMP0, al, bl); - tcg_out_opc_reg(s, opc_sub, rl, al, bl); - } - tcg_out_opc_reg(s, opc_sub, rh, th, TCG_REG_TMP0); - } else { - if (cbl) { - tcg_out_opc_imm(s, opc_addi, rl, al, bl); - tcg_out_opc_imm(s, OPC_SLTIU, TCG_REG_TMP0, rl, bl); - } else if (al == bl) { - /* - * If the input regs overlap, this is a simple doubling - * and carry-out is the input msb. This special case is - * required when the output reg overlaps the input, - * but we might as well use it always. - */ - tcg_out_opc_imm(s, OPC_SLTI, TCG_REG_TMP0, al, 0); - tcg_out_opc_reg(s, opc_add, rl, al, al); - } else { - tcg_out_opc_reg(s, opc_add, rl, al, bl); - tcg_out_opc_reg(s, OPC_SLTU, TCG_REG_TMP0, - rl, (rl == bl ? al : bl)); - } - tcg_out_opc_reg(s, opc_add, rh, th, TCG_REG_TMP0); - } -} - static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, TCGReg dst, TCGReg src) { @@ -2608,23 +2547,6 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, TCGType type, tcg_out_ldst(s, OPC_SD, a0, a1, a2); break; - case INDEX_op_add2_i32: - tcg_out_addsub2(s, a0, a1, a2, args[3], args[4], args[5], - const_args[4], const_args[5], false, true); - break; - case INDEX_op_add2_i64: - tcg_out_addsub2(s, a0, a1, a2, args[3], args[4], args[5], - const_args[4], const_args[5], false, false); - break; - case INDEX_op_sub2_i32: - tcg_out_addsub2(s, a0, a1, a2, args[3], args[4], args[5], - const_args[4], const_args[5], true, true); - break; - case INDEX_op_sub2_i64: - tcg_out_addsub2(s, a0, a1, a2, args[3], args[4], args[5], - const_args[4], const_args[5], true, false); - break; - case INDEX_op_qemu_ld_i32: tcg_out_qemu_ld(s, a0, a1, a2, TCG_TYPE_I32); break; @@ -2897,12 +2819,6 @@ tcg_target_op_def(TCGOpcode op, TCGType type, unsigned flags) case INDEX_op_st_i64: return C_O0_I2(rz, r); - case INDEX_op_add2_i32: - case INDEX_op_add2_i64: - case INDEX_op_sub2_i32: - case INDEX_op_sub2_i64: - return C_O2_I4(r, r, rz, rz, rM, rM); - case INDEX_op_qemu_ld_i32: case INDEX_op_qemu_ld_i64: return C_O1_I1(r, r);