From patchwork Wed Nov 6 12:56:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1190385 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-512601-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="wksjqfi1"; 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 477RNs454rz9sR0 for ; Wed, 6 Nov 2019 23:56:11 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=Tzva2xSMptX58i7wykEfzylqFWApOHZKysChe85yctE3ECF/OsZhQ zXEcMf81KVgi1komOOFwtOI8LaGdOFcWkbd122LoeeAHMmhR+R3hwdIbJ+ELGDbv v8/iWQOjkis7UkFUvQBi4knYRAQtqvUP98un4TvF6zm1XHPo3LdcYY= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=nGXi4gfcYC/3MIxvn0C23RPFzEE=; b=wksjqfi1TohXNcmBRKF7 GB8zgMeoXB0eutMG91cd2ulmNaiYQ9lstSXQmra/hP6Hohu7gkv1fn/IqqwwD7Fw Kzd7IZFmOzYA686JzYocUEgovIY/8UIraA653qvpR/8CIXDmgVFmg2eEvgT08Wqr FtnmtIlp2BU5R2Y08K/OqvA= Received: (qmail 62672 invoked by alias); 6 Nov 2019 12:56:03 -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 62663 invoked by uid 89); 6 Nov 2019 12:56:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-13.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:3140, use_stmt X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 06 Nov 2019 12:56:02 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 2AF22B352 for ; Wed, 6 Nov 2019 12:56:00 +0000 (UTC) Date: Wed, 6 Nov 2019 13:56:00 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Some vectorizable_reduction TLC Message-ID: User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2019-11-06 Richard Biener * tree-vect-loop.c (vectorizable_reduction): Remember reduction PHI. Use STMT_VINFO_REDUC_IDX to skip the reduction operand. Simplify single_defuse_cycle condition. Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c (revision 277874) +++ gcc/tree-vect-loop.c (working copy) @@ -5725,6 +5725,7 @@ vectorizable_reduction (stmt_vec_info st } stmt_vec_info orig_stmt_of_analysis = stmt_info; + stmt_vec_info phi_info = stmt_info; if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_reduction_def || STMT_VINFO_DEF_TYPE (stmt_info) == vect_double_reduction_def) { @@ -5749,8 +5750,8 @@ vectorizable_reduction (stmt_vec_info st bool res = single_imm_use (gimple_phi_result (stmt_info->stmt), &use_p, &use_stmt); gcc_assert (res); - stmt_info = loop_vinfo->lookup_stmt (use_stmt); - stmt_info = vect_stmt_to_vectorize (STMT_VINFO_REDUC_DEF (stmt_info)); + phi_info = loop_vinfo->lookup_stmt (use_stmt); + stmt_info = vect_stmt_to_vectorize (STMT_VINFO_REDUC_DEF (phi_info)); } /* STMT_VINFO_REDUC_DEF doesn't point to the first but the last element. */ @@ -5760,6 +5761,8 @@ vectorizable_reduction (stmt_vec_info st stmt_info = REDUC_GROUP_FIRST_ELEMENT (stmt_info); } } + /* PHIs should not participate in patterns. */ + gcc_assert (!STMT_VINFO_RELATED_STMT (phi_info)); if (nested_in_vect_loop_p (loop, stmt_info)) { @@ -5822,9 +5825,6 @@ vectorizable_reduction (stmt_vec_info st The last use is the reduction variable. In case of nested cycle this assumption is not true: we use reduc_index to record the index of the reduction variable. */ - stmt_vec_info phi_info = STMT_VINFO_REDUC_DEF (vect_orig_stmt (stmt_info)); - /* PHIs should not participate in patterns. */ - gcc_assert (!STMT_VINFO_RELATED_STMT (phi_info)); gphi *reduc_def_phi = as_a (phi_info->stmt); /* Verify following REDUC_IDX from the latch def leads us back to the PHI @@ -5873,11 +5873,8 @@ vectorizable_reduction (stmt_vec_info st "use not simple.\n"); return false; } - if ((dt == vect_reduction_def || dt == vect_nested_cycle) - && op == reduc_def) - { - continue; - } + if (i == STMT_VINFO_REDUC_IDX (stmt_info)) + continue; /* There should be only one cycle def in the stmt, the one leading to reduc_def. */ @@ -6338,14 +6335,9 @@ vectorizable_reduction (stmt_vec_info st This only works when we see both the reduction PHI and its only consumer in vectorizable_reduction and there are no intermediate stmts participating. */ - stmt_vec_info use_stmt_info; - tree reduc_phi_result = gimple_phi_result (reduc_def_phi); if (ncopies > 1 && (STMT_VINFO_RELEVANT (stmt_info) <= vect_used_only_live) - && (use_stmt_info = loop_vinfo->lookup_single_use (reduc_phi_result)) - && (!STMT_VINFO_IN_PATTERN_P (use_stmt_info) - || !STMT_VINFO_PATTERN_DEF_SEQ (use_stmt_info)) - && vect_stmt_to_vectorize (use_stmt_info) == stmt_info) + && reduc_chain_length == 1) single_defuse_cycle = true; if (single_defuse_cycle || lane_reduc_code_p)