From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 48345 invoked by alias); 26 Feb 2016 14:29:08 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 48335 invoked by uid 89); 26 Feb 2016 14:29:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=BAYES_00,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SPF_PASS autolearn=no version=3.3.2 spammy=***************, UD:tree-vect-loop.c X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Fri, 26 Feb 2016 14:29:06 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 95893AB4B for ; Fri, 26 Feb 2016 14:29:02 +0000 (UTC) Date: Fri, 26 Feb 2016 14:29:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR69720 Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2016-02/txt/msg01795.txt.bz2 The following fixes PR69720 where with nested reductions that require unrolling the inner loop (and thus having multiple PHIs) we fail to properly build the reduction epilogue. Existing testcases in the testsuite are also affected but for them it doesn't matter as adding zero can be omitted safely ... Bootstrapped on x86_64-unknown-linux-gnu, testing still in progress. We might be able to remove the adjustment_def case completely now, but that's not appropriate at this stage so I removed only the case we were handling not correctly. Richard. 2016-02-26 Richard Biener PR tree-optimization/69720 * tree-vect-loop.c (get_initial_def_for_reduction): Avoid the adjustment_def path for possibly vectorized defs. (vect_create_epilog_for_reduction): Handle vectorized initial defs properly. * gcc.dg/vect/vect-outer-pr69720.c: New testcase. Index: gcc/tree-vect-loop.c =================================================================== *** gcc/tree-vect-loop.c (revision 233734) --- gcc/tree-vect-loop.c (working copy) *************** get_initial_def_for_reduction (gimple *s *** 4110,4115 **** --- 4119,4133 ---- return vect_create_destination_var (init_val, vectype); } + /* 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: *************** get_initial_def_for_reduction (gimple *s *** 4124,4135 **** /* ADJUSMENT_DEF is NULL when called from vect_create_epilog_for_reduction to vectorize double reduction. */ if (adjustment_def) ! { ! if (nested_in_vect_loop) ! *adjustment_def = vect_get_vec_def_for_operand (init_val, stmt); ! else ! *adjustment_def = init_val; ! } if (code == MULT_EXPR) { --- 4142,4148 ---- /* ADJUSMENT_DEF is NULL when called from vect_create_epilog_for_reduction to vectorize double reduction. */ if (adjustment_def) ! *adjustment_def = init_val; if (code == MULT_EXPR) { *************** vect_create_epilog_for_reduction (vec