From patchwork Wed May 15 02:39:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 164256 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp200032ili; Tue, 14 May 2019 19:40:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqMY3E8Q8AsE9X74ke3N+cY4foGA+Kbv9NLS4vEmorD2pGqXwvcDSujpyNyTK9UGuGy9nG X-Received: by 2002:a62:1846:: with SMTP id 67mr25553475pfy.33.1557888041358; Tue, 14 May 2019 19:40:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557888041; cv=none; d=google.com; s=arc-20160816; b=dm5e1k8WdJjrNumtiCIfWSUPHHhDI3jgn2I1vDhVa9Qcun0u6Akmy4/WK6Yt7GXVx4 0tSuZQ1SRk46WsjzNcliAhLH1DuhlCg+/f2RE+goXPM7Zk0OUG65d7uf/vWXfPlYVQ0n hxPNiC3lanUVifZvgsiQtYxbKIzChKBlBhWGXlccTBAcZuT7zXpWqSpisH6A33txHDM5 /ZGgD+6bHV1j5JYTIZCv7xWQ4ZBnzBXYh+iXTTsv+tXM1vn34/JBo3DDmE39w7gg64uq vsY97fGdyqZ3HOO6tpOm1hejKBtxhI2QFYLoSsIijfoLXk/E8+K6kVloU4L8dw1m62Gx jJLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature; bh=X1X+Tbg9NC9Te/t+8KuHGYFXHkCx/ITWin5MF4CWBG0=; b=yjrfL399tBVodnJCC1UfyABE40yvXtIUQSySyw2CIlSVx4btEYGv71LWYgYa12Tq4Y yMHiT+Hf+2ZmB6dYvsNcSqyBV0ABPaWvFuumgaQeAhFBe0EDt/C3Ouxvv/0G5pj7hWew G1GaN+Dc2D795irBVvD6vBj7CzQq3qSgM3CAelsbtGj0k5jPfeyN6Y3U813NCPv1ioKs yQ/p4PMmBNgr0EriI/nI7pDiOowR7uFbqm8xJZYUhYWcX7Q1efGwjOS9QYL+aSPJt/Vf lH1jMMlttFsiGo+jfTjvgbc3REs2C61pwjLDrA+FM/BHKoUeH3oSxVeqFnZM1xa7qf+X gD2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="Srl/Okd5"; dkim=pass header.i=@linaro.org header.s=google header.b=sAc24U0l; spf=pass (google.com: domain of gcc-patches-return-500708-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-500708-patch=linaro.org@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id t10si601473pgv.533.2019.05.14.19.40.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 May 2019 19:40:41 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-500708-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="Srl/Okd5"; dkim=pass header.i=@linaro.org header.s=google header.b=sAc24U0l; spf=pass (google.com: domain of gcc-patches-return-500708-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-500708-patch=linaro.org@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=oC0KvNUUIglllzZhEUtBrNXV0BiMQDYGRUnrKEafhpwIf6MwfNYei NFMBlqza0DTFwEFTZw2jOxJJBNkTqR64+MnW+WKmYCFc3RlZU1eX9bjSsrlmucza aSlrVWyFaopZfZZbr/keIfZumcnqaVvuN6Btoifd7uDrASV9SzmYZQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=REgp9HJCp0npKKgavGRU3mTfkdw=; b=Srl/Okd5HBVX98s+TiJ6 J+YMeKXYvPOkViBnCIpGXcINtgiuMCwNN38FBnmX94Cgboz1DgAA7bU40YSlh0Ic XphcaQuiyHDfpQD5DNxpunFkD73lsoYn5Ap6AVjVUKzQbuxUiTUOuIUtJGlTW3w2 +Cx/BtqkBs8HLQ6bcRMkP44= Received: (qmail 52905 invoked by alias); 15 May 2019 02:40:25 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 52843 invoked by uid 89); 15 May 2019 02:40:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=UD:is_constant X-HELO: mail-pg1-f169.google.com Received: from mail-pg1-f169.google.com (HELO mail-pg1-f169.google.com) (209.85.215.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 15 May 2019 02:40:23 +0000 Received: by mail-pg1-f169.google.com with SMTP id c13so555221pgt.1 for ; Tue, 14 May 2019 19:40:22 -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; bh=X1X+Tbg9NC9Te/t+8KuHGYFXHkCx/ITWin5MF4CWBG0=; b=sAc24U0lLJxAhhBvyHREZ5p/1ecG0G/cq1D1wiIUEyveQuoyoBTTFgA3qmj08Nisn4 pSzl93f3tqvWk5Dqau/z7NlB5qmd8sxYUe8H1urnB2fMg7UY+dscKgf4U819c49rTURf 2Qdf266jg+305yXMgE1Uay+sjWo8wR/6fazEeZ47UpetNilpV1jlYvzTJbPEvX8ZXZUq mci+VGMkuOr1QuASdU4gcas7+k9oBr6lZroMlkLSds4VoKif6iyvh2Ci9UIiLJUOBaEk K3/JgBjh4BHAfdqz0IoR56ls9KmCSYWofJj2Mz7t7exvOcHyxFCKl63IcjPp+kwrpC1H R3LQ== Return-Path: Received: from localhost.localdomain (203-219-253-77.static.tpgi.com.au. [203.219.253.77]) by smtp.gmail.com with ESMTPSA id c5sm457976pgh.86.2019.05.14.19.40.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 May 2019 19:40:20 -0700 (PDT) From: kugan.vivekanandarajah@linaro.org To: gcc-patches@gcc.gnu.org Cc: Kugan Vivekanandarajah Subject: [PATCH 1/2] Add support for IVOPT Date: Wed, 15 May 2019 12:39:49 +1000 Message-Id: <1557887990-18668-2-git-send-email-kugan.vivekanandarajah@linaro.org> In-Reply-To: <1557887990-18668-1-git-send-email-kugan.vivekanandarajah@linaro.org> References: <1557887990-18668-1-git-send-email-kugan.vivekanandarajah@linaro.org> X-IsSubscribed: yes From: Kugan Vivekanandarajah gcc/ChangeLog: 2019-05-15 Kugan Vivekanandarajah PR target/88834 * tree-ssa-loop-ivopts.c (get_mem_type_for_internal_fn): Handle IFN_MASK_LOAD_LANES and IFN_MASK_STORE_LANES. (find_interesting_uses_stmt): Likewise. (get_alias_ptr_type_for_ptr_address): Likewise. (add_iv_candidate_for_use): Add scaled index candidate if useful. Change-Id: I8e8151fe2dde2845dedf38b090103694da6fc9d1 --- gcc/tree-ssa-loop-ivopts.c | 60 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 9864b59..115a70c 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -2451,11 +2451,13 @@ get_mem_type_for_internal_fn (gcall *call, tree *op_p) switch (gimple_call_internal_fn (call)) { case IFN_MASK_LOAD: + case IFN_MASK_LOAD_LANES: if (op_p == gimple_call_arg_ptr (call, 0)) return TREE_TYPE (gimple_call_lhs (call)); return NULL_TREE; case IFN_MASK_STORE: + case IFN_MASK_STORE_LANES: if (op_p == gimple_call_arg_ptr (call, 0)) return TREE_TYPE (gimple_call_arg (call, 3)); return NULL_TREE; @@ -2545,7 +2547,7 @@ find_interesting_uses_stmt (struct ivopts_data *data, gimple *stmt) return; } - /* TODO -- we should also handle address uses of type + /* TODO -- we should also handle all address uses of type memory = call (whatever); @@ -2553,6 +2555,27 @@ find_interesting_uses_stmt (struct ivopts_data *data, gimple *stmt) call (memory). */ } + else if (is_gimple_call (stmt)) + { + gcall *call = dyn_cast (stmt); + if (call + && gimple_call_internal_p (call) + && (gimple_call_internal_fn (call) == IFN_MASK_LOAD_LANES + || gimple_call_internal_fn (call) == IFN_MASK_STORE_LANES)) + { + tree *arg = gimple_call_arg_ptr (call, 0); + struct iv *civ = get_iv (data, *arg); + tree mem_type = get_mem_type_for_internal_fn (call, arg); + if (civ && mem_type) + { + civ = alloc_iv (data, civ->base, civ->step); + record_group_use (data, arg, civ, stmt, USE_PTR_ADDRESS, + mem_type); + return; + } + } + } + if (gimple_code (stmt) == GIMPLE_PHI && gimple_bb (stmt) == data->current_loop->header) @@ -3500,6 +3523,39 @@ add_iv_candidate_for_use (struct ivopts_data *data, struct iv_use *use) basetype = sizetype; record_common_cand (data, build_int_cst (basetype, 0), iv->step, use); + /* Compare the cost of an address with an unscaled index with the cost of + an address with a scaled index and add candidate if useful. */ + if (use != NULL && use->type == USE_PTR_ADDRESS) + { + struct mem_address parts = {NULL_TREE, integer_one_node, + NULL_TREE, NULL_TREE, NULL_TREE}; + poly_uint64 temp; + poly_int64 fact; + bool speed = optimize_loop_for_speed_p (data->current_loop); + poly_int64 poly_step = tree_to_poly_int64 (iv->step); + machine_mode mem_mode = TYPE_MODE (use->mem_type); + addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (use->iv->base)); + + fact = GET_MODE_SIZE (GET_MODE_INNER (TYPE_MODE (use->mem_type))); + parts.index = integer_one_node; + + if (fact.is_constant () + && can_div_trunc_p (poly_step, fact, &temp)) + { + /* Addressing mode "base + index". */ + rtx addr = addr_for_mem_ref (&parts, as, false); + unsigned cost = address_cost (addr, mem_mode, as, speed); + tree step = wide_int_to_tree (sizetype, + exact_div (poly_step, fact)); + parts.step = wide_int_to_tree (sizetype, fact); + /* Addressing mode "base + index << scale". */ + addr = addr_for_mem_ref (&parts, as, false); + unsigned new_cost = address_cost (addr, mem_mode, as, speed); + if (new_cost < cost) + add_candidate (data, size_int (0), step, true, NULL); + } + } + /* Record common candidate with constant offset stripped in base. Like the use itself, we also add candidate directly for it. */ base = strip_offset (iv->base, &offset); @@ -7112,6 +7168,8 @@ get_alias_ptr_type_for_ptr_address (iv_use *use) { case IFN_MASK_LOAD: case IFN_MASK_STORE: + case IFN_MASK_LOAD_LANES: + case IFN_MASK_STORE_LANES: /* The second argument contains the correct alias type. */ gcc_assert (use->op_p = gimple_call_arg_ptr (call, 0)); return TREE_TYPE (gimple_call_arg (call, 1));