From patchwork Fri Sep 27 08:23:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1168346 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-509691-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="qc8mLeT3"; 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 46flDn4N6Zz9sN1 for ; Fri, 27 Sep 2019 18:23:35 +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:date:message-id:mime-version:content-type; q=dns; s= default; b=cDVghq3mmgatekSSfdoP0FeRGcrexYnyCqtclZwZDLcaPzYEdJEF6 qcv9hJUrfdCFqft92h/szDBFe9y+D4+Nf5lHn3tYHaBrBzUbEXinNoqrqUSDFej3 H7qqgQIMBS4iR0d3dcjHVdRDYvI5+vf/zaSmx2yq2J/CekbVsM+mz0= 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=nL7tGv6lz2UMF4KGj0NNF8tv9oE=; b=qc8mLeT3S8UyAcmozDeU 6k1Io72po5eOc5mFkgChdWII6oZmusSn9wXVdTkiF7h+q3JXe8myDX4VSMu8sLHP +SSfHQOflCBiE5KgtBtqNW6MM7CcsVPiM9porx2NOcOpu6nMvfmmNoRVqgB0C/oV EWSsm7EyGa8s/h5YHoQ3MtI= Received: (qmail 95244 invoked by alias); 27 Sep 2019 08:23: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 95232 invoked by uid 89); 27 Sep 2019 08:23:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 27 Sep 2019 08:23:27 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A53BC337 for ; Fri, 27 Sep 2019 01:23:25 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.126]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4C61A3F739 for ; Fri, 27 Sep 2019 01:23:25 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: Fix reduc_index==1 handling for COND_REDUCTION (PR91909) Date: Fri, 27 Sep 2019 09:23:24 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes The then/else order of the VEC_COND_EXPRs created by vect_create_epilog_for_reduction meeds to line up with the main VEC_COND_EXPR. Tested on aarch64-linux-gnu, x86_64-linux-gnu and armeb-eabi. Approved by Richi in the PR, applied as r276175. Richard 2019-09-27 Richard Sandiford gcc/ PR tree-optimization/91909 * tree-vect-loop.c (vect_create_epilog_for_reduction): Take a reduc_index parameter. When handling COND_REDUCTION, make sure that the reduction phi operand is in the correct arm of the VEC_COND_EXPR. (vectorizable_reduction): Pass reduc_index to the above. Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c 2019-09-27 09:09:26.747845171 +0100 +++ gcc/tree-vect-loop.c 2019-09-27 09:20:30.946948486 +0100 @@ -4235,6 +4235,8 @@ get_initial_defs_for_reduction (slp_tree INDUC_CODE is the code for epilog reduction if INTEGER_INDUC_COND_REDUCTION. NEUTRAL_OP is the value given by neutral_op_for_slp_reduction; it is null if this is not an SLP reduction + REDUC_INDEX says which rhs operand of the STMT_INFO is the reduction phi + (counting from 0) This function: 1. Creates the reduction def-use cycles: sets the arguments for @@ -4285,7 +4287,7 @@ vect_create_epilog_for_reduction (vec= 1); + tree index_cond_expr; + if (reduc_index == 2) + index_cond_expr = build3 (VEC_COND_EXPR, cr_index_vector_type, + ccompare, indx_before_incr, new_phi_tree); + else + index_cond_expr = build3 (VEC_COND_EXPR, cr_index_vector_type, + ccompare, new_phi_tree, indx_before_incr); induction_index = make_ssa_name (cr_index_vector_type); gimple *index_condition = gimple_build_assign (induction_index, index_cond_expr); @@ -7159,7 +7167,7 @@ vectorizable_reduction (stmt_vec_info st vect_create_epilog_for_reduction (vect_defs, stmt_info, reduc_def_phi, orig_code, epilog_copies, reduc_fn, phis, double_reduc, slp_node, slp_node_instance, - neutral_op); + neutral_op, reduc_index); return true; }