From patchwork Wed Sep 9 00:16:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 249418 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp5018340ilg; Tue, 8 Sep 2020 17:28:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfEuz7Cee/4JDsS27VpiqGKJmAKmVb9/8HFQdbnSpNh8ea5UgCUkuFjVcoOXX2Al4juFSc X-Received: by 2002:a25:7309:: with SMTP id o9mr2188239ybc.375.1599611321357; Tue, 08 Sep 2020 17:28:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599611321; cv=none; d=google.com; s=arc-20160816; b=yFp0Xn5w3b8ubkxUb8nFHbM9+vaktRB6NVyQo9unveDZ1u0tvzbQnztR4/E4CZO2VJ 8vU4yKNzSYZzpQGqA6c9IM0pXdDTJmaQSv2BDlqXM4Q+5adz3AIzqfgrzfAwkAyMMlMw YxaMcXOKzSWAq0Y3rZKBocO8nOCKbzx53Jrpm+t09kNyKwpRUrbCmWK0cGKGB1J7yGcf PZNtGmuZ6NV7mSEobAFKLrOjyLPShkeQV9ggQBL0xtYRbw/sfWZfEszKOE6dfJ9MlfDK 8IXY8jozXZ+HMpHW8BkJljPZwkj69Z2wPOFitUgZoZ4KWdYXBuYhqa2ligypLjsTYNN2 KIGA== 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:to:from :dkim-signature; bh=w6xHshvWLLck3lt1rEDIti2QJ7z0XrDN3U8gYB8E2NY=; b=uCeWJEn/2cfLPRzAlxoU2IwaDE7ExfPSkd/Yy8Yl1jrJU3YheefwkKgsLOIOlN6cHU sg3GB0eYQG+bT8D3pzPLj/V+3FjrUYcedaLSL68KC5zpWcnxFiPcFkNWXHpHbjIakWbb fxeOr7vW1I055mXbtKy4f8DRdNBx0di/C6M4ISyoKyOEPjLzs9CA/ezeqPWAzgBq0jzX cjaY7V1kk77tN9MkAPWQAiNzMc6ap6qzzUWm00+1Q5S4NLJ37s7q+xegBoiXqDufacu2 kz4tlyZmp++PRVM0nNyHDVlYpy9OiThY274AVgYqxhiMJkRg5kTTBknOoKiKdK7/YDru p0HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y694efuf; 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 o185si904561ybc.394.2020.09.08.17.28.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Sep 2020 17:28:41 -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=Y694efuf; 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]:60364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kFnya-0000jC-TM for patch@linaro.org; Tue, 08 Sep 2020 20:28:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kFnnl-0000OD-RV for qemu-devel@nongnu.org; Tue, 08 Sep 2020 20:17:29 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:46095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kFnnk-0002Ir-0G for qemu-devel@nongnu.org; Tue, 08 Sep 2020 20:17:29 -0400 Received: by mail-pf1-x444.google.com with SMTP id b124so530199pfg.13 for ; Tue, 08 Sep 2020 17:17:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=w6xHshvWLLck3lt1rEDIti2QJ7z0XrDN3U8gYB8E2NY=; b=Y694efufjNhb2dvtkeVzSQ/8mpsOQtfCpS4XEDU79oDboEw3YSXINWYrpvQPqtKvLr lCohCdqL1usgkV+MdH+sEOn6fZmC6q1X57ogWyA4a39/dH+OMKK2TF7bX8KSYp0PJdXE t5yGF2rVYeBcPrayl9KjgXUYeOWhHBeh63VvqtD2iSfPqOCRqe0zBvBJjFIl8sg0qxTe IC+aKHrGnVa37GWsyT0E+PHA8MRMH/7auFEJaGeUKX3DGWcGk4L3Y5zHl/F/TzsI6vJ5 4gnL0KDEyiIfPf/letLbP5KGly0sJjWfsGq+n0w24rj31N6zx4ZS4VuufjINjYw8713R dPYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w6xHshvWLLck3lt1rEDIti2QJ7z0XrDN3U8gYB8E2NY=; b=BOsuSQetMh9S31gcLhx/lJf+hGp98OXh/4ZSOQhXtbeMu3NRNbyNUg+VGQ5ZUeVNA4 Fk6N7ZVw6bWZa4GosdmDPVufWyS9bVeFLfk49kl/n2Jh5dRWcD2i2gguREQGHCPj0dhB kDhKgYuYwdmREP6c/H/qe/Q3QF9GyC0zZa31+t0GSJrR6N8oFU6eIllw9QdCWgiTa7Ye hq1rZGkAb9wtUkhLGYp9MKCajWhGkl0a9Ci2ogtFkCznnBo8dOqKw3Yj9qcCVgTWjFmv sJs9bbTMZWa552ISXoYFVCmRLVYDsA2BP0t6zU8xvpp06LhWT6+FqRnbJEsQdw/Txyx9 CR5A== X-Gm-Message-State: AOAM5336ThPJb5niYL0Ivk1AG8qZDweWLTTLZe1JpMYFpdkSAmZkGGRY 6lpNkWmohTXJUFX441+XPb6X1KUMd2dx/w== X-Received: by 2002:a65:66c6:: with SMTP id c6mr996275pgw.206.1599610646306; Tue, 08 Sep 2020 17:17:26 -0700 (PDT) Received: from localhost.localdomain ([71.212.141.89]) by smtp.gmail.com with ESMTPSA id 137sm505437pfu.149.2020.09.08.17.17.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Sep 2020 17:17:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 29/43] tcg: Add tcg_reg_alloc_dup2 Date: Tue, 8 Sep 2020 17:16:33 -0700 Message-Id: <20200909001647.532249-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200909001647.532249-1-richard.henderson@linaro.org> References: <20200909001647.532249-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::444; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x444.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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.23 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" There are several ways we can expand a vector dup of a 64-bit element on a 32-bit host. Signed-off-by: Richard Henderson --- tcg/tcg.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) -- 2.25.1 diff --git a/tcg/tcg.c b/tcg/tcg.c index f9c6450837..507c95cd39 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3954,6 +3954,100 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) } } +static void tcg_reg_alloc_dup2(TCGContext *s, const TCGOp *op) +{ + const TCGLifeData arg_life = op->life; + TCGTemp *ots, *itsl, *itsh; + TCGType vtype = TCGOP_VECL(op) + TCG_TYPE_V64; + + /* This opcode is only valid for 32-bit hosts, for 64-bit elements. */ + tcg_debug_assert(TCG_TARGET_REG_BITS == 32); + tcg_debug_assert(TCGOP_VECE(op) == MO_64); + + ots = arg_temp(op->args[0]); + itsl = arg_temp(op->args[1]); + itsh = arg_temp(op->args[2]); + + /* ENV should not be modified. */ + tcg_debug_assert(!temp_readonly(ots)); + + /* Allocate the output register now. */ + if (ots->val_type != TEMP_VAL_REG) { + TCGRegSet allocated_regs = s->reserved_regs; + TCGRegSet dup_out_regs = + tcg_op_defs[INDEX_op_dup_vec].args_ct[0].regs; + + /* Make sure to not spill the input registers. */ + if (!IS_DEAD_ARG(1) && itsl->val_type == TEMP_VAL_REG) { + tcg_regset_set_reg(allocated_regs, itsl->reg); + } + if (!IS_DEAD_ARG(2) && itsh->val_type == TEMP_VAL_REG) { + tcg_regset_set_reg(allocated_regs, itsh->reg); + } + + ots->reg = tcg_reg_alloc(s, dup_out_regs, allocated_regs, + op->output_pref[0], ots->indirect_base); + ots->val_type = TEMP_VAL_REG; + ots->mem_coherent = 0; + s->reg_to_temp[ots->reg] = ots; + } + + /* Promote dup2 of immediates to dupi_vec. */ + if (itsl->val_type == TEMP_VAL_CONST && itsh->val_type == TEMP_VAL_CONST) { + uint64_t val = deposit64(itsl->val, 32, 32, itsh->val); + MemOp vece = MO_64; + + if (val == dup_const(MO_8, val)) { + vece = MO_8; + } else if (val == dup_const(MO_16, val)) { + vece = MO_16; + } else if (val == dup_const(MO_32, val)) { + vece = MO_32; + } + + tcg_out_dupi_vec(s, vtype, vece, ots->reg, val); + goto done; + } + + /* If the two inputs form one 64-bit value, try dupm_vec. */ + if (itsl + 1 == itsh && + itsl->base_type == TCG_TYPE_I64 && + itsh->base_type == TCG_TYPE_I64) { + if (!itsl->mem_coherent) { + temp_sync(s, itsl, s->reserved_regs, 0, 0); + } + if (!itsl->mem_coherent) { + temp_sync(s, itsl, s->reserved_regs, 0, 0); + } +#ifdef HOST_WORDS_BIGENDIAN + TCGTemp *its = itsh; +#else + TCGTemp *its = itsl; +#endif + if (tcg_out_dupm_vec(s, vtype, MO_64, ots->reg, + its->mem_base->reg, its->mem_offset)) { + goto done; + } + } + + /* Fall back to generic expansion. */ + tcg_reg_alloc_op(s, op); + return; + + done: + if (IS_DEAD_ARG(1)) { + temp_dead(s, itsl); + } + if (IS_DEAD_ARG(2)) { + temp_dead(s, itsh); + } + if (NEED_SYNC_ARG(0)) { + temp_sync(s, ots, s->reserved_regs, 0, IS_DEAD_ARG(0)); + } else if (IS_DEAD_ARG(0)) { + temp_dead(s, ots); + } +} + #ifdef TCG_TARGET_STACK_GROWSUP #define STACK_DIR(x) (-(x)) #else @@ -4345,6 +4439,9 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) case INDEX_op_dup_vec: tcg_reg_alloc_dup(s, op); break; + case INDEX_op_dup2_vec: + tcg_reg_alloc_dup2(s, op); + break; case INDEX_op_insn_start: if (num_insns >= 0) { size_t off = tcg_current_code_size(s);