From patchwork Fri Oct 29 04:33:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 516418 Delivered-To: patch@linaro.org Received: by 2002:ad5:5208:0:0:0:0:0 with SMTP id p8csp413815iml; Thu, 28 Oct 2021 22:11:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxS/ugo2t+aIxrTKjwff/DEtLEkUFXpuPaGOB4lxKOJz98xWL/f/CSJiWH2FHZ9a5/4ahXG X-Received: by 2002:a9d:53c4:: with SMTP id i4mr6736605oth.176.1635484287172; Thu, 28 Oct 2021 22:11:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635484287; cv=none; d=google.com; s=arc-20160816; b=M3tLbgjK8V4NqJSDgguTJbRl6Z78seeNM9kRkFjYTf3t+7p89XyCVsCw5io4VjwCm0 H5lqpvTpizK9dV5YYDP22k5t55s6ixUBz4N0GnYSEvGa3u8od2FSkqfsv8yc6+K3JFjc EubOQvNBLYp17LAVy+r3p5dAZWaXRkzG7XIisK2FSZnXB0nO44DzUDEI+LUrwx/NhKp7 XvxuXqKMgm1nhrfRXfTSOCKgQzktPQyKhXbFUodXU3koJMNKi8KeomAq7uoECi7ds9dt e7RhXkZY22ML1Wi52nQEw4xdzZqxIqEjYU64JZGlLSYVrhzQ87rsirPCaiisl/ut/jUl uMDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=fwDfuaHLd2phF2WKQRX+NWoB84U/ilhRWeGAC07+3IE=; b=HTM5hn1CT/dABF8ZLLatTTh3sxFv9DDOB0mKC/oX72MzuriCozA21H2VFeVw02FFxt QEj+C47BL54rOMiEjVGW892w56LEwSDB+GNfI0iAPLk6CyIr6ESgioLwIFqVZRcqbOob qYsRpW0EWDood+EqNjSDSt6NSfzFqMIx9LT1gVDCrLZ+FRI0+HdB1XVswkaftZt/LbWG 5uC6LeFaBxt5AI+UbO2Ivw45uddjTE5qgnmUO7T2smk0XoJRfQGDDzCMpOLwzMnvt4S2 1Bxf640TeUTKwN8Bmn46Tp1BrPVWthXn+G10U107CV16cWdluaS2Tmm4CsRX/sbgJaMW JBPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UVNUDCIi; 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 l28si6600471otb.3.2021.10.28.22.11.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Oct 2021 22:11: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=UVNUDCIi; 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]:37026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mgKAo-0007UV-CT for patch@linaro.org; Fri, 29 Oct 2021 01:11:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgJab-0004h6-R2 for qemu-devel@nongnu.org; Fri, 29 Oct 2021 00:34:01 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:41655) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mgJaZ-0007zj-E3 for qemu-devel@nongnu.org; Fri, 29 Oct 2021 00:34:01 -0400 Received: by mail-pf1-x42f.google.com with SMTP id p40so3262153pfh.8 for ; Thu, 28 Oct 2021 21:33:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fwDfuaHLd2phF2WKQRX+NWoB84U/ilhRWeGAC07+3IE=; b=UVNUDCIi8oo7GgsRAPn4roqf63wNKHhN97v7vTQz/K8xRLkVyGuR0XRr2TEQIHUT05 6LMlL6NoxZEp1F4vcJnx4UevWLcT+uVQna0fnF2JOO2mJlNkjm1Of0qELHyT7Pmd2eQ5 L9PpmFSBhbXFBFi0wNQa0o1ZSZYbiFL/lWfD947PSSXvg4SKMll9GyVwIMtaBl3ue7uo m+ZnHj4ffPfKBykpE/nHZNpGxO0oDncaBUxVi7oheY4q3uJiIsu0TzeTmhepfEVce3i2 s8vJRoe0KbgmsRjsPlmbEFt1A8X9yWfRDDltsZCyqU2lchkycGI6Msq9HEraPrspLtUs b1pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fwDfuaHLd2phF2WKQRX+NWoB84U/ilhRWeGAC07+3IE=; b=YFglWLM7XdvNv611voqzd/cLlWKyKVRNcmpHgXNKJhVCrQdZImU3OIRmc1Eyr4qbCW /KWXmDwcMusxu9XjVII3Ze/aEFskvpeWsS4UIFi/zf46rFkLMyMZVQgRM5D/htBIKs7q NWnZD/+R4nHY6btHds2qL3EW8ZejuEbpSLbmTQBvWYC9sRWosecYJs0JwlnGrFD5hv+K Ap7MXiWDeos8dT5xsomFqcfnpw+cR7WisrschVOCDkNC0tXcMHt41X1K7ftG3lQceoiq gEKwxgONCJbmWfLft9ycJhn7Zrq/E3dJHYU5+KGeReNcQKMnLTe2c2taG6fNji0mqvBL sq+w== X-Gm-Message-State: AOAM532lWHpv/uoRaesPEKIiRiyGHRmEKoMqi8zlDz8zOjORNbGDNVrg R8vp5OFjSlbc/s9YSNiB4cNjNWp5RVf0hg== X-Received: by 2002:a63:874a:: with SMTP id i71mr6421336pge.200.1635482038129; Thu, 28 Oct 2021 21:33:58 -0700 (PDT) Received: from localhost.localdomain (174-21-75-75.tukw.qwest.net. [174.21.75.75]) by smtp.gmail.com with ESMTPSA id i11sm4120257pgp.18.2021.10.28.21.33.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 21:33:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL v2 33/60] tcg/optimize: Split out fold_dup, fold_dup2 Date: Thu, 28 Oct 2021 21:33:02 -0700 Message-Id: <20211029043329.1518029-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211029043329.1518029-1-richard.henderson@linaro.org> References: <20211029043329.1518029-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Luis Pires , =?utf-8?q?Philippe_Mathieu-Da?= =?utf-8?q?ud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Luis Pires Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/optimize.c | 53 +++++++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 22 deletions(-) -- 2.25.1 diff --git a/tcg/optimize.c b/tcg/optimize.c index 5374c230da..8524fe1f8a 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -920,6 +920,31 @@ static bool fold_divide(OptContext *ctx, TCGOp *op) return fold_const2(ctx, op); } +static bool fold_dup(OptContext *ctx, TCGOp *op) +{ + if (arg_is_const(op->args[1])) { + uint64_t t = arg_info(op->args[1])->val; + t = dup_const(TCGOP_VECE(op), t); + return tcg_opt_gen_movi(ctx, op, op->args[0], t); + } + return false; +} + +static bool fold_dup2(OptContext *ctx, TCGOp *op) +{ + if (arg_is_const(op->args[1]) && arg_is_const(op->args[2])) { + uint64_t t = deposit64(arg_info(op->args[1])->val, 32, 32, + arg_info(op->args[2])->val); + return tcg_opt_gen_movi(ctx, op, op->args[0], t); + } + + if (args_are_copies(op->args[1], op->args[2])) { + op->opc = INDEX_op_dup_vec; + TCGOP_VECE(op) = MO_32; + } + return false; +} + static bool fold_eqv(OptContext *ctx, TCGOp *op) { return fold_const2(ctx, op); @@ -1731,28 +1756,6 @@ void tcg_optimize(TCGContext *s) done = tcg_opt_gen_mov(&ctx, op, op->args[0], op->args[1]); break; - case INDEX_op_dup_vec: - if (arg_is_const(op->args[1])) { - tmp = arg_info(op->args[1])->val; - tmp = dup_const(TCGOP_VECE(op), tmp); - tcg_opt_gen_movi(&ctx, op, op->args[0], tmp); - continue; - } - break; - - case INDEX_op_dup2_vec: - assert(TCG_TARGET_REG_BITS == 32); - if (arg_is_const(op->args[1]) && arg_is_const(op->args[2])) { - tcg_opt_gen_movi(&ctx, op, op->args[0], - deposit64(arg_info(op->args[1])->val, 32, 32, - arg_info(op->args[2])->val)); - continue; - } else if (args_are_copies(op->args[1], op->args[2])) { - op->opc = INDEX_op_dup_vec; - TCGOP_VECE(op) = MO_32; - } - break; - default: break; @@ -1796,6 +1799,12 @@ void tcg_optimize(TCGContext *s) CASE_OP_32_64(divu): done = fold_divide(&ctx, op); break; + case INDEX_op_dup_vec: + done = fold_dup(&ctx, op); + break; + case INDEX_op_dup2_vec: + done = fold_dup2(&ctx, op); + break; CASE_OP_32_64(eqv): done = fold_eqv(&ctx, op); break;