From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30556 invoked by alias); 2 Jun 2017 10:23:48 -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 30543 invoked by uid 89); 2 Jun 2017 10:23:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy= 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; Fri, 02 Jun 2017 10:23:46 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id EAFF7AC29 for ; Fri, 2 Jun 2017 10:23:48 +0000 (UTC) Date: Fri, 02 Jun 2017 10:23:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH][2/n] Avoid vectorizing IV update when not necessary Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SW-Source: 2017-06/txt/msg00105.txt.bz2 When doing SLP reduction a needlessy marked IV update causes hybrid SLP and thus pointless unrolling to happen. The following avoids vectorizing the IV update when not otherwise necessary. Currently we're creating a dead vector stmt for all inductions that are vectorized. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2017-06-02 Richard Biener * tree-vect-loop.c (vect_analyze_loop_operations): Not relevant PHIs are ok. * tree-vect-stmts.c (process_use): Do not mark backedge defs for inductions as relevant. Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c (revision 248788) +++ gcc/tree-vect-loop.c (working copy) @@ -1708,8 +1708,7 @@ vect_analyze_loop_operations (loop_vec_i are not used in the outerloop (unless it is double reduction, i.e., this phi is vect_reduction_def), cause this case requires to actually do something here. */ - if ((!STMT_VINFO_RELEVANT_P (stmt_info) - || STMT_VINFO_LIVE_P (stmt_info)) + if (STMT_VINFO_LIVE_P (stmt_info) && STMT_VINFO_DEF_TYPE (stmt_info) != vect_double_reduction_def) { Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c (revision 248788) +++ gcc/tree-vect-stmts.c (working copy) @@ -579,6 +579,20 @@ process_use (gimple *stmt, tree use, loo gcc_unreachable (); } } + /* We are also not interested in uses on loop PHI backedges that are + inductions. Otherwise we'll needlessly vectorize the IV increment + and cause hybrid SLP for SLP inductions. */ + else if (gimple_code (stmt) == GIMPLE_PHI + && STMT_VINFO_DEF_TYPE (stmt_vinfo) == vect_induction_def + && (PHI_ARG_DEF_FROM_EDGE (stmt, loop_latch_edge (bb->loop_father)) + == use)) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_NOTE, vect_location, + "induction value on backedge.\n"); + return true; + } + vect_mark_relevant (worklist, def_stmt, relevant, false); return true;