From patchwork Fri Sep 15 10:44:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 112704 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp450515edb; Fri, 15 Sep 2017 03:44:39 -0700 (PDT) X-Received: by 10.84.210.105 with SMTP id z96mr5539618plh.183.1505472278920; Fri, 15 Sep 2017 03:44:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505472278; cv=none; d=google.com; s=arc-20160816; b=lERaIwjrTyt9BlMUo1ygCCEoZBbZtap575/0n60gS91mfQqoPzygRYJFQ7U+Dy1fiS 9PJy4RxYtaSn5wtDPCGNgkR2yHpvxOz9nkxjBmxNGGSYgrySzC0eAZxmNwTftkqgxJZr fIgaGMnaNShgaXPD25UdDTZK5vgBxtJANHa/51LA8VMwHRyo/g3CwHN1gijCIaXEXcuu QTf2ch4XcOTaPCf1hOME/54AOWqVHimY6zGOqu8YyDbKRChpOjsoenDs9rhSk/OKO4Sb E/yG1I4Rfl2YveOSSqTGxxEkVQnreue/kTNVVJTC5VTtrn2Ps5PVA8v+8OfpGPpJ0OuD LxTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:date:subject:mail-followup-to:to :from:delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=7BjEr/YrcVYoFxOh943lXbwRKkTXJ615t4xadm7u+0o=; b=HLQAhAANm0YA/II9+KrAJtEo45gv05M13dLefEbBJPTmEH2w9sgu6UcRMBsh9rNKgY tBsDg4R0nR6JAVpI6GtP+yR5Tmd6JcsuTlGWOCyvWXdQ83CdxCvGma937f4h2ZDqieV8 4tVT8WZdHRYiy/C9VM0EkO6Yds6jhxDnfOecayiHhU9GQuqkPRXK+ZYUjFIypNvFlWnP 3e38MpwDKCLj1pxwXAgd6PshWWvKCPtZL64p1W0Pfi+hYJe2OS+Qb9XjEe9SHD0JrWL+ oJLn9mJKdCfwFb0TifqO59ytkHt+dblc7uwDuBiZ7BMiHv6HVmLgUVD5pNKe62cluH3M ql5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=RlmDYy+x; spf=pass (google.com: domain of gcc-patches-return-462216-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462216-patch=linaro.org@gcc.gnu.org; dmarc=fail (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 v5si460419pgj.247.2017.09.15.03.44.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Sep 2017 03:44:38 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-462216-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=RlmDYy+x; spf=pass (google.com: domain of gcc-patches-return-462216-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462216-patch=linaro.org@gcc.gnu.org; dmarc=fail (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:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=b3pdnkLyNRH8IaSRJXLoffFNHgyDzPu4O5r3pugy5sECRdNTf3+Xj QoWXxW1CSrQXPjRG5oUS8zRbUsrgiS34f49czfjcQb4OxZHjaZ0A4W33TGTbPne3 W9IIj16Ecna9cOBHOoetL1LyxleIACrzvNnVyG/4IS0ltxmou8splE= 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:subject:date:message-id:mime-version:content-type; s= default; bh=//mZE0I2UywyHFInuWt/Buv8cnk=; b=RlmDYy+xCJSm6rRyyb12 fU+UJiUsEbu6qt7Rz5zYhQeiMkgLsmpMf0zqj0sbmtSVR3Qu4PICiWF87HRTeZkS d5t4wljm3/oxfFQPB+irnPILlMImtJQhGbF3AtMNE5C8dwNfHHcp29zDX5koSjHG txPIpfRHlv/TSZ8GhVAsJl4= Received: (qmail 19124 invoked by alias); 15 Sep 2017 10:44:27 -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 17934 invoked by uid 89); 15 Sep 2017 10:44:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f45.google.com Received: from mail-wm0-f45.google.com (HELO mail-wm0-f45.google.com) (74.125.82.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 15 Sep 2017 10:44:25 +0000 Received: by mail-wm0-f45.google.com with SMTP id r68so7209358wmg.3 for ; Fri, 15 Sep 2017 03:44:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:date:message-id :user-agent:mime-version; bh=7BjEr/YrcVYoFxOh943lXbwRKkTXJ615t4xadm7u+0o=; b=tqqbx2ySRizywMoxJaGqwwbRV7bLqxd65HVC24hW/EdH+I+mj18KS/tRYbr7PwuZD0 ZLbh9L1jMvIAvCCj+9ggTFSdPHbT87HWCKgm/HiMeusESuFgVn1w+qliRY83rIeiVQWA TKKrJg5JHDvMAm61IYMdEor6QCvE5WjdMIfloxZuXVuUT5wW2pJUM+bJ3NWKKd4XA1sp TxWfrnIohKXH56pdfF/8CizWHZaJnk9SlzNnu1kuj1P3BZHRHD3CdZ47Rd3rkql9OruS ptZqH3JkHnEhgbIp//UwGvE2nAOxwEk6vtaP9JMHRj3cQUc7ymXJZai4pTyl2UYvzRxE U2QQ== X-Gm-Message-State: AHPjjUg6o4o39YtXmk9usmDmVlqIRHygIzdN3XMfF9/LwrUw+jjE6Vd9 tfg7KiYpe31NY1qPd66TevLvOscY7fo= X-Google-Smtp-Source: AOwi7QC0eebtMx5Qt6TWvOUzgBCpFYHBnDnJTZjd003geLz6JWzY4DwH8Txorp/8j4zjQeNhbu8K+g== X-Received: by 10.28.196.202 with SMTP id u193mr2279667wmf.120.1505472262996; Fri, 15 Sep 2017 03:44:22 -0700 (PDT) Received: from localhost (92.40.248.1.threembb.co.uk. [92.40.248.1]) by smtp.gmail.com with ESMTPSA id b89sm942967wrd.42.2017.09.15.03.44.21 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Sep 2017 03:44:22 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Invoke vectorizable_live_operation in a consistent way Date: Fri, 15 Sep 2017 11:44:19 +0100 Message-ID: <87ingknsvw.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 vect_transform_stmt calls vectorizable_live_operation for each live statement in an SLP node, but vect_analyze_stmt only called it the once. This patch makes vect_analyze_stmt consistent with vect_transform_stmt, which should be a bit more robust, and also means that a later patch can use slp_index when deciding validity. Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu. OK to install? Richard 2017-09-15 Richard Sandiford Alan Hayward David Sherwood gcc/ * tree-vect-stmts.c (can_vectorize_live_stmts): New function, split out from... (vect_transform_stmt): ...here. (vect_analyze_stmt): Use it instead of calling vectorizable_live_operation directly. Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2017-09-14 17:30:48.110211243 +0100 +++ gcc/tree-vect-stmts.c 2017-09-15 11:36:58.331030784 +0100 @@ -8479,6 +8479,35 @@ vectorizable_comparison (gimple *stmt, g return true; } +/* If SLP_NODE is nonnull, return true if vectorizable_live_operation + can handle all live statements in the node. Otherwise return true + if STMT is not live or if vectorizable_live_operation can handle it. + GSI and VEC_STMT are as for vectorizable_live_operation. */ + +static bool +can_vectorize_live_stmts (gimple *stmt, gimple_stmt_iterator *gsi, + slp_tree slp_node, gimple **vec_stmt) +{ + if (slp_node) + { + gimple *slp_stmt; + unsigned int i; + FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (slp_node), i, slp_stmt) + { + stmt_vec_info slp_stmt_info = vinfo_for_stmt (slp_stmt); + if (STMT_VINFO_LIVE_P (slp_stmt_info) + && !vectorizable_live_operation (slp_stmt, gsi, slp_node, i, + vec_stmt)) + return false; + } + } + else if (STMT_VINFO_LIVE_P (vinfo_for_stmt (stmt)) + && !vectorizable_live_operation (stmt, gsi, slp_node, -1, vec_stmt)) + return false; + + return true; +} + /* Make sure the statement is vectorizable. */ bool @@ -8685,17 +8714,13 @@ vect_analyze_stmt (gimple *stmt, bool *n /* Stmts that are (also) "live" (i.e. - that are used out of the loop) need extra handling, except for vectorizable reductions. */ - if (STMT_VINFO_LIVE_P (stmt_info) - && STMT_VINFO_TYPE (stmt_info) != reduc_vec_info_type) - ok = vectorizable_live_operation (stmt, NULL, node, -1, NULL); - - if (!ok) + if (STMT_VINFO_TYPE (stmt_info) != reduc_vec_info_type + && !can_vectorize_live_stmts (stmt, NULL, node, NULL)) { if (dump_enabled_p ()) { dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "not vectorized: live stmt not "); - dump_printf (MSG_MISSED_OPTIMIZATION, "supported: "); + "not vectorized: live stmt not supported: "); dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0); } @@ -8861,26 +8886,9 @@ vect_transform_stmt (gimple *stmt, gimpl /* Handle stmts whose DEF is used outside the loop-nest that is being vectorized. */ - if (slp_node) - { - gimple *slp_stmt; - int i; - if (STMT_VINFO_TYPE (stmt_info) != reduc_vec_info_type) - FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (slp_node), i, slp_stmt) - { - stmt_vec_info slp_stmt_info = vinfo_for_stmt (slp_stmt); - if (STMT_VINFO_LIVE_P (slp_stmt_info)) - { - done = vectorizable_live_operation (slp_stmt, gsi, slp_node, i, - &vec_stmt); - gcc_assert (done); - } - } - } - else if (STMT_VINFO_LIVE_P (stmt_info) - && STMT_VINFO_TYPE (stmt_info) != reduc_vec_info_type) + if (STMT_VINFO_TYPE (stmt_info) != reduc_vec_info_type) { - done = vectorizable_live_operation (stmt, gsi, slp_node, -1, &vec_stmt); + done = can_vectorize_live_stmts (stmt, gsi, slp_node, &vec_stmt); gcc_assert (done); }