From patchwork Tue Jul 24 09:52:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 948285 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-482112-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="AHfNpDQY"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZYZV1vdDz9s3N for ; Tue, 24 Jul 2018 19:53:06 +1000 (AEST) 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=JLF598KQO3FmJjBhI0tJJGstOKLXa SMpfd3zcU7San56kHm84K7j9P7APAcTr7eZJUqg2iAQMX7xV1JRGMVgSfsxem+ia WOFtgutWEBipDpLqGK4zbsZ5N5/184fhu6iOjlFEYJZeG/10jb9nnOABGxhUq+1K eY8845GEFmUwk4= 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=DtR+pgcD36WRXJbqNugwDK/D9+I=; b=AHf NpDQY9RlpXh3/0ItOmSLqbp54sI473xcnPErncG/huug/2t+i3EYFe37E9a5q2m7 T1eJ5m1jxim7rzbi/LpgsX2M8GALkrRNiWG+e5BBDqrT4+foeGbSqLvhUWhbtWWa mNu26r9JpY3L718bXbtpVdSYzanjLP19VhJx/3PE= Received: (qmail 115067 invoked by alias); 24 Jul 2018 09:52:59 -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 115057 invoked by uid 89); 24 Jul 2018 09:52:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: foss.arm.com Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 24 Jul 2018 09:52:57 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 19D2D7A9 for ; Tue, 24 Jul 2018 02:52:56 -0700 (PDT) Received: from localhost (unknown [10.32.99.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 96D123F237 for ; Tue, 24 Jul 2018 02:52:55 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [01/46] Move special cases out of get_initial_def_for_reduction References: <87wotlrmen.fsf@arm.com> Date: Tue, 24 Jul 2018 10:52:54 +0100 In-Reply-To: <87wotlrmen.fsf@arm.com> (Richard Sandiford's message of "Tue, 24 Jul 2018 10:52:16 +0100") Message-ID: <87sh49rmdl.fsf@arm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 This minor clean-up avoids repeating the test for double reductions and also moves the vect_get_vec_def_for_operand call to the same function as the corresponding vect_get_vec_def_for_stmt_copy. 2018-07-24 Richard Sandiford gcc/ * tree-vect-loop.c (get_initial_def_for_reduction): Move special cases for nested loops from here to ... (vect_create_epilog_for_reduction): ...here. Only call vect_is_simple_use for inner-loop reductions. Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c 2018-07-13 10:11:14.429843575 +0100 +++ gcc/tree-vect-loop.c 2018-07-24 10:22:02.965552667 +0100 @@ -4113,10 +4113,8 @@ get_initial_def_for_reduction (gimple *s enum tree_code code = gimple_assign_rhs_code (stmt); tree def_for_init; tree init_def; - bool nested_in_vect_loop = false; REAL_VALUE_TYPE real_init_val = dconst0; int int_init_val = 0; - gimple *def_stmt = NULL; gimple_seq stmts = NULL; gcc_assert (vectype); @@ -4124,39 +4122,12 @@ get_initial_def_for_reduction (gimple *s gcc_assert (POINTER_TYPE_P (scalar_type) || INTEGRAL_TYPE_P (scalar_type) || SCALAR_FLOAT_TYPE_P (scalar_type)); - if (nested_in_vect_loop_p (loop, stmt)) - nested_in_vect_loop = true; - else - gcc_assert (loop == (gimple_bb (stmt))->loop_father); - - /* In case of double reduction we only create a vector variable to be put - in the reduction phi node. The actual statement creation is done in - vect_create_epilog_for_reduction. */ - if (adjustment_def && nested_in_vect_loop - && TREE_CODE (init_val) == SSA_NAME - && (def_stmt = SSA_NAME_DEF_STMT (init_val)) - && gimple_code (def_stmt) == GIMPLE_PHI - && flow_bb_inside_loop_p (loop, gimple_bb (def_stmt)) - && vinfo_for_stmt (def_stmt) - && STMT_VINFO_DEF_TYPE (vinfo_for_stmt (def_stmt)) - == vect_double_reduction_def) - { - *adjustment_def = NULL; - return vect_create_destination_var (init_val, vectype); - } + gcc_assert (nested_in_vect_loop_p (loop, stmt) + || loop == (gimple_bb (stmt))->loop_father); vect_reduction_type reduction_type = STMT_VINFO_VEC_REDUCTION_TYPE (stmt_vinfo); - /* In case of a nested reduction do not use an adjustment def as - that case is not supported by the epilogue generation correctly - if ncopies is not one. */ - if (adjustment_def && nested_in_vect_loop) - { - *adjustment_def = NULL; - return vect_get_vec_def_for_operand (init_val, stmt); - } - switch (code) { case WIDEN_SUM_EXPR: @@ -4586,9 +4557,22 @@ vect_create_epilog_for_reduction (vec