From patchwork Mon Oct 23 17:29:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 116817 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4894081qgn; Mon, 23 Oct 2017 10:30:17 -0700 (PDT) X-Received: by 10.99.124.75 with SMTP id l11mr12101752pgn.439.1508779816987; Mon, 23 Oct 2017 10:30:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508779816; cv=none; d=google.com; s=arc-20160816; b=RhENDgM9TpTefoCv6EsIErmZzVwKAdZPe9LIcQBGaQ3rujElm6ZLk2mmEIUCy8oS4p GVazMVJ2AkTXwi9OXdHhlt9ZcuzQJC3EGmxquKHh5pFihj84uW927OTuyHXIXHLpcMTL JHO5GesYaGftkdyUj9sTCx9uhL7MGkS5GM+DOycU7f+rWw9ps+maCIB/SkDzxhV3YEV5 T9bOtV6CEfzHqFJNhZb8E2oC8FL5l6uRu82eUL0VO2GvRGga6LFRtWN87FNYydVqWE9T 2exOXR5svIEpXcO1Qd7zku8SD5GS11aI7tHxINxnvUZVkJU9ifzajrD0U2fuL2dwlyqZ 4EzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:in-reply-to:date:references :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=AabpaKJTWrk1oSVWuHO6MNE/yB+MJ3/X3YPXrkFj2y0=; b=Jy565yZGlTP2KZ4dShxMTKNPyOjoPxqqeAyKGcfjXs7lB4ZFo/UNJ5leQo1drUyawh dJ9WW45XuGCpWBElUH2HcAsY/88ndXVb0YMN7pjh+Ol1gUtXw1uhI00W/m+mDNo855gp s9V1gtZtmhsPe67rFAGs6kk0xgbc4cXM0L9Wzk5ebZhfGdsNaX+rhY7XtIeo8bNLXlxn BJVnT9fvVFefROLvFZMj7MqkG39SwT6G5faLdfOoR4D2OOAJSD6vcfLipxjXftK3doQ1 YutnoOFWsHbfubAtgmFW00VRR+lHunzitE4MaakWGpjO3bloiVJb/wMJS65YqbWxGk46 uEuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=a6s4BTMT; spf=pass (google.com: domain of gcc-patches-return-464848-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464848-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 b18si5153594pge.711.2017.10.23.10.30.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 10:30:16 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-464848-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=a6s4BTMT; spf=pass (google.com: domain of gcc-patches-return-464848-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464848-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:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=LUoX6Enicv9zRYF5LszHAWnaKQwMk EVeAhGLccX5PjlwkX0rBACg2UFcgGB/QbHENO2vmG/6LUocsE/4tO8sHiHx98pbz qXt1MfJT5q6Wkasbnl8knNQH8uP7r91SuUkhipjfMLM108UUx4vzTgoiH3jpwGo0 k4OFJSTMm6Q06I= 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:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=j9rrE4aow8q7tH4Em+XrhF5wtiI=; b=a6s 4BTMTsotL1LaCRO8si+Xzxad/FoufT2o7wCQTYex7S0xLN/6t4DOUbtfUdx42mwX vrO8ePc0L3nAd4Kx58UAiYH18wCvPPvvJHl5y9QrZjqyHuYJGfTHOFVUk8POvTyH FSMu5G7aKFrtJ8ouq9MO+4XA5qPkkaGEnG+nw5EQ= Received: (qmail 84547 invoked by alias); 23 Oct 2017 17:29:41 -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 84409 invoked by uid 89); 23 Oct 2017 17:29:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-16.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f48.google.com Received: from mail-wm0-f48.google.com (HELO mail-wm0-f48.google.com) (74.125.82.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 17:29:38 +0000 Received: by mail-wm0-f48.google.com with SMTP id 78so8465260wmb.1 for ; Mon, 23 Oct 2017 10:29:38 -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:references:date :in-reply-to:message-id:user-agent:mime-version; bh=AabpaKJTWrk1oSVWuHO6MNE/yB+MJ3/X3YPXrkFj2y0=; b=pofsTlGYoN28i3LT4+57axIxkRTq3swOWVW9aNAZXqPnUKcwfPojxJjZm7EBemBdLZ 96Fo3HYIgoohBduvvXr1LvgvT8/RPt75KBqllvxRYcnkFrNju+kiEF5dqML9mbpSVadz 8DK8aJ0PPmQ5Dt5ZQ/T7fQCl7MzO61ntVjJRTdjKchzQtuv/RmnwIC4JBrHml+0J2VQ+ nRb3YpvSOmZiIp42TFN9RtbgTbz0j0cWSsfM5NfhBQlw1Y23Y+jF4UlaI9RoUTfA/xPe kz8Cqab0BzPF7Ru0Jme5rWmPYH99lQ/SwdCxUefvQPse1cIdmGqX1ngKJ6zJ+21HRqeN tD3A== X-Gm-Message-State: AMCzsaVzTx5SKXZgPEKtyn/bh0YJa5htrVQRZDyJ5iWSVOxqAwzV2axO p8fLwyzEaZ9mmMauwUO4vnpGP4MN6mc= X-Google-Smtp-Source: ABhQp+SzTekNGXQrSLcQgqvR7xHISMmSWE5K5QifaNsGr0OMTGcaAntAUbmggRs2eL8tsLCIHExnzQ== X-Received: by 10.28.127.206 with SMTP id a197mr5530172wmd.12.1508779776656; Mon, 23 Oct 2017 10:29:36 -0700 (PDT) Received: from localhost ([2.26.27.199]) by smtp.gmail.com with ESMTPSA id l130sm1432172wmd.47.2017.10.23.10.29.35 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2017 10:29:35 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [072/nnn] poly_int: vectorizable_live_operation References: <871sltvm7r.fsf@linaro.org> Date: Mon, 23 Oct 2017 18:29:35 +0100 In-Reply-To: <871sltvm7r.fsf@linaro.org> (Richard Sandiford's message of "Mon, 23 Oct 2017 17:54:32 +0100") Message-ID: <878tg1ixhc.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch makes vectorizable_live_operation cope with variable-length vectors. For now we just handle cases in which we can tell at compile time which vector contains the final result. 2017-10-23 Richard Sandiford Alan Hayward David Sherwood gcc/ * tree-vect-loop.c (vectorizable_live_operation): Treat the number of units as polynomial. Punt if we can't tell at compile time which vector contains the final result. Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c 2017-10-23 17:22:36.904793787 +0100 +++ gcc/tree-vect-loop.c 2017-10-23 17:22:37.879692661 +0100 @@ -7132,10 +7132,12 @@ vectorizable_live_operation (gimple *stm imm_use_iterator imm_iter; tree lhs, lhs_type, bitsize, vec_bitsize; tree vectype = STMT_VINFO_VECTYPE (stmt_info); - int nunits = TYPE_VECTOR_SUBPARTS (vectype); + poly_uint64 nunits = TYPE_VECTOR_SUBPARTS (vectype); int ncopies; gimple *use_stmt; auto_vec vec_oprnds; + int vec_entry = 0; + poly_uint64 vec_index = 0; gcc_assert (STMT_VINFO_LIVE_P (stmt_info)); @@ -7164,6 +7166,30 @@ vectorizable_live_operation (gimple *stm else ncopies = vect_get_num_copies (loop_vinfo, vectype); + if (slp_node) + { + gcc_assert (slp_index >= 0); + + int num_scalar = SLP_TREE_SCALAR_STMTS (slp_node).length (); + int num_vec = SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node); + + /* Get the last occurrence of the scalar index from the concatenation of + all the slp vectors. Calculate which slp vector it is and the index + within. */ + poly_uint64 pos = (num_vec * nunits) - num_scalar + slp_index; + + /* Calculate which vector contains the result, and which lane of + that vector we need. */ + if (!can_div_trunc_p (pos, nunits, &vec_entry, &vec_index)) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "Cannot determine which vector holds the" + " final result.\n"); + return false; + } + } + if (!vec_stmt) /* No transformation required. */ return true; @@ -7185,18 +7211,6 @@ vectorizable_live_operation (gimple *stm tree vec_lhs, bitstart; if (slp_node) { - gcc_assert (slp_index >= 0); - - int num_scalar = SLP_TREE_SCALAR_STMTS (slp_node).length (); - int num_vec = SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node); - - /* Get the last occurrence of the scalar index from the concatenation of - all the slp vectors. Calculate which slp vector it is and the index - within. */ - int pos = (num_vec * nunits) - num_scalar + slp_index; - int vec_entry = pos / nunits; - int vec_index = pos % nunits; - /* Get the correct slp vectorized stmt. */ vec_lhs = gimple_get_lhs (SLP_TREE_VEC_STMTS (slp_node)[vec_entry]);