From patchwork Mon Jan 22 17:53:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 125453 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp1285261ljf; Mon, 22 Jan 2018 09:53:39 -0800 (PST) X-Google-Smtp-Source: AH8x22707TNez0/Wj8dcCmi26ByLMWnkTyUiz3JlpnvzuDCMS+4ugbN7zu/VYUXqd8do4VJy5Xuu X-Received: by 10.107.164.134 with SMTP id d6mr9222579ioj.176.1516643619517; Mon, 22 Jan 2018 09:53:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516643619; cv=none; d=google.com; s=arc-20160816; b=lxAW+nPUb+PNVNNFsHZKne55InvdDIGMFS21tB9yyHN2m10lhLo91jcN6nk2Gnkilg pWKHD/dbPsSP+Y2guHmtBUNLN3IQnVUpZMhaCsKivJXDUbH74MI0V8pfWleX1Jj2B45E XFn9euzf+vGT3gAYY3mZzbaUD9Prz4hPy616N/03ke8F7ZjXrxe1Ozpebjqq6jcaXSQB Y77RkQWfDQpKv80Ew9xM8x2AIjzoOq6vUT7Qr94x/QQNH178lzUfK9xBiirwwCQRIZfb 3h6zv8GWTG0SGayjXu0pNiIwk+MC2HSXOrwql/dSCjE6Svz4LI9ZmexGVmyQaUq/SohD Dktw== 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=Q0UEGSiCVOrzSzXjNCOXhIxVlFbeSO6V9PbZ7Vpe5Nc=; b=xLfRAvpHnxok+vH6HYo7Y5N8hyBqJa1xj6attqG1ywFf2PRfstFt1se/9EQhlv1/LF JKHRkZ/OaogF9fWB90aByuRG5OgTUVVbQdb/vyieRME07Qv0hv7Uo8OEpZsQtawD53E8 NDkn2501q0LzcSGkBKkx70zxMZ5eLzft3UoGXssVAUVpvtkU0HYV/TONeztp9YJbq93Y Uu46Ab/ciK5ucwslQ7BuWYwV5nzUdrvcUJwcs/sgPa87fVIOvv+CAamR9CDu4FjEWTkm t/3Tx6KspvaIiuzTunGTPUc/Oo6vtrnlyaF6jSq4a9uf3XK7L7iAMSkCzCAi8s6tqSVt O+qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=dwDNlZ7/; spf=pass (google.com: domain of gcc-patches-return-471814-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-471814-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 o62si12820959iod.318.2018.01.22.09.53.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jan 2018 09:53:39 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-471814-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=dwDNlZ7/; spf=pass (google.com: domain of gcc-patches-return-471814-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-471814-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=vK65Y2oNNvbCflmIBxjRyes/TeklnuOKtbPtISnXYf1r0CziiNA4A 2h0SNb1s3j4zimrvMhQZ+pTXK38GasIuQGBMT23yEvfdaYmB4bGHlQ8sYlmfWyJ6 d9hdDHcaYZVs2Qx+196TQ/iAiQdShx0H5Kc2Mn94ndxhsTb9RchUl8= 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=2tCgJhiTLPQ8m2VSJFkpsR5opow=; b=dwDNlZ7/N/RrFoi29ux4 9f1hYIh5JpsthIH3ElKpC0lGaPiH+2ZLwKsWdho/S5j/GBOZhxWU4bWcMLBOr05V w6EIhs2itez8EG8OPTdW94TIrXix1XjfM4ixPUbg9epBKn03mQubvEE1Pb+C+A/r 0sNiOVZsOJx8+gOrJd9iiY0= Received: (qmail 30238 invoked by alias); 22 Jan 2018 17:53:28 -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 30221 invoked by uid 89); 22 Jan 2018 17:53:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=UD:tree-vect-patterns.c, recognised X-HELO: mail-wr0-f170.google.com Received: from mail-wr0-f170.google.com (HELO mail-wr0-f170.google.com) (209.85.128.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 22 Jan 2018 17:53:26 +0000 Received: by mail-wr0-f170.google.com with SMTP id 100so9623857wrb.7 for ; Mon, 22 Jan 2018 09:53:25 -0800 (PST) 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=Q0UEGSiCVOrzSzXjNCOXhIxVlFbeSO6V9PbZ7Vpe5Nc=; b=giuTSKP7ypSSnVhjW9Iq3eLpjbw5xqp3ZByzLdmI/4GDYSktYTHGqPkZ468pgKxPDJ 8ggI7fN01VqFWqtNyjsXe2nBwPPwsEDhuZQ0ESQwzUTZWeWpozmaChdvB7rVVaKdueLf zeUbK/HTglQ/KVGEiacbLErm0Z8d3TAKgnZKNzwMjsCghqFm+2EMl7WrIbIV6vNHiID+ /mXGwRZAUSQClXTC5mPlIwlJTt7Q0GXiizvZKNRP2Jnedw2t/D6/4o+q9QVnqja8AIqA EOhcG2s90oCANVTgt0mugS+epTmE8VuJnwrmZ9BlZomOCZF3n9XE33J+MtcxIiFhzjEI zi2w== X-Gm-Message-State: AKwxytePpLK1eHJ+Fh2mayZ6CLqf0YgHZbq/4OH1rGPbTBXhgyrV+JNe yUiyXZzpnJgauPbeW/OJByp3H0NxsSU= X-Received: by 10.223.130.194 with SMTP id 60mr7220720wrc.72.1516643603677; Mon, 22 Jan 2018 09:53:23 -0800 (PST) Received: from localhost (188.29.164.244.threembb.co.uk. [188.29.164.244]) by smtp.gmail.com with ESMTPSA id 81sm1601038wmi.26.2018.01.22.09.53.22 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jan 2018 09:53:22 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Disable some patterns for fold-left reductions (PR 83965) Date: Mon, 22 Jan 2018 17:53:21 +0000 Message-ID: <871sihpypa.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 In this PR we recognised a PLUS_EXPR as a fold-left reduction, then applied pattern matching to convert it to a WIDEN_SUM_EXPR. We need to keep the original code in this case since we implement the reduction using scalar rather than vector operations. Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu. OK to install? Richard 2018-01-22 Richard Sandiford gcc/ PR tree-optimization/83965 * tree-vect-patterns.c (vect_reassociating_reduction_p): New function. (vect_recog_dot_prod_pattern, vect_recog_sad_pattern): Use it instead of checking only for a reduction. (vect_recog_widen_sum_pattern): Likewise. gcc/testsuite/ PR tree-optimization/83965 * gcc.dg/vect/pr83965.c: New test. Index: gcc/tree-vect-patterns.c =================================================================== --- gcc/tree-vect-patterns.c 2018-01-13 18:01:51.240735098 +0000 +++ gcc/tree-vect-patterns.c 2018-01-22 17:51:06.751462689 +0000 @@ -217,6 +217,16 @@ vect_recog_temp_ssa_var (tree type, gimp return make_temp_ssa_name (type, stmt, "patt"); } +/* Return true if STMT_VINFO describes a reduction for which reassociation + is allowed. */ + +static bool +vect_reassociating_reduction_p (stmt_vec_info stmt_vinfo) +{ + return (STMT_VINFO_DEF_TYPE (stmt_vinfo) == vect_reduction_def + && STMT_VINFO_REDUC_TYPE (stmt_vinfo) != FOLD_LEFT_REDUCTION); +} + /* Function vect_recog_dot_prod_pattern Try to find the following pattern: @@ -336,7 +346,7 @@ vect_recog_dot_prod_pattern (vec *s { gimple *def_stmt; - if (STMT_VINFO_DEF_TYPE (stmt_vinfo) != vect_reduction_def + if (!vect_reassociating_reduction_p (stmt_vinfo) && ! STMT_VINFO_GROUP_FIRST_ELEMENT (stmt_vinfo)) return NULL; plus_oprnd0 = gimple_assign_rhs1 (last_stmt); @@ -1181,7 +1191,7 @@ vect_recog_widen_sum_pattern (vec