From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 75340 invoked by alias); 25 Jul 2018 09:13:16 -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 75033 invoked by uid 89); 25 Jul 2018 09:13:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=participating X-HELO: mail-lf1-f65.google.com Received: from mail-lf1-f65.google.com (HELO mail-lf1-f65.google.com) (209.85.167.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 25 Jul 2018 09:13:14 +0000 Received: by mail-lf1-f65.google.com with SMTP id u202-v6so4914570lff.9 for ; Wed, 25 Jul 2018 02:13:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=S+GoD2I8BPtCKzZiB1MVf09Ty/3INLGirtFHB/Xmvfk=; b=JjCM5NnB8MRrf6SZFvsoUKoTwK89CwZ4pcbQXVjZAt6cDBqFY+Kt7ize1uywBFc/l1 oo/sdwvFxaXenkMm7xf90U1yRURl1M15riaPqq74yJUIH0iKEuTT/+/ITXEdHCf6/x7A i/Os1zMg80J9dP2ofddG8pGQPeTd76XaF8aXwUnVzf3k0LC01KwRwfv3C5juutCkAByU xJP1ypzGhygvdbpxnJqdgmzjBuF4kpMCfmzYqKC2lmcjTuMEW90vcuT7fTAgxLI1bgFu PvQ+GZ5/c5/sBYBUBLQF4BJe7H5I3U11m9Aw8woyJ8EM5UiHLeNSeaSChHPsfKWVlIE/ hNVA== MIME-Version: 1.0 References: <87wotlrmen.fsf@arm.com> <87tvopq7ni.fsf@arm.com> In-Reply-To: <87tvopq7ni.fsf@arm.com> From: Richard Biener Date: Wed, 25 Jul 2018 09:13:00 -0000 Message-ID: Subject: Re: [09/46] Add vec_info::lookup_single_use To: GCC Patches , richard.sandiford@arm.com Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-07/txt/msg01471.txt.bz2 On Tue, Jul 24, 2018 at 11:56 AM Richard Sandiford wrote: > > This patch adds a helper function for seeing whether there is a single > user of an SSA name, and whether that user has a stmt_vec_info. OK. > > 2018-07-24 Richard Sandiford > > gcc/ > * tree-vectorizer.h (vec_info::lookup_single_use): Declare. > * tree-vectorizer.c (vec_info::lookup_single_use): New function. > * tree-vect-loop.c (vectorizable_reduction): Use it instead of > a single_imm_use-based sequence. > * tree-vect-stmts.c (supportable_widening_operation): Likewise. > > Index: gcc/tree-vectorizer.h > =================================================================== > --- gcc/tree-vectorizer.h 2018-07-24 10:22:27.285336715 +0100 > +++ gcc/tree-vectorizer.h 2018-07-24 10:22:30.401309046 +0100 > @@ -220,6 +220,7 @@ struct vec_info { > stmt_vec_info add_stmt (gimple *); > stmt_vec_info lookup_stmt (gimple *); > stmt_vec_info lookup_def (tree); > + stmt_vec_info lookup_single_use (tree); > > /* The type of vectorization. */ > vec_kind kind; > Index: gcc/tree-vectorizer.c > =================================================================== > --- gcc/tree-vectorizer.c 2018-07-24 10:22:27.285336715 +0100 > +++ gcc/tree-vectorizer.c 2018-07-24 10:22:30.401309046 +0100 > @@ -548,6 +548,20 @@ vec_info::lookup_def (tree name) > return NULL; > } > > +/* See whether there is a single non-debug statement that uses LHS and > + whether that statement has an associated stmt_vec_info. Return the > + stmt_vec_info if so, otherwise return null. */ > + > +stmt_vec_info > +vec_info::lookup_single_use (tree lhs) > +{ > + use_operand_p dummy; > + gimple *use_stmt; > + if (single_imm_use (lhs, &dummy, &use_stmt)) > + return lookup_stmt (use_stmt); > + return NULL; > +} > + > /* A helper function to free scev and LOOP niter information, as well as > clear loop constraint LOOP_C_FINITE. */ > > Index: gcc/tree-vect-loop.c > =================================================================== > --- gcc/tree-vect-loop.c 2018-07-24 10:22:27.277336786 +0100 > +++ gcc/tree-vect-loop.c 2018-07-24 10:22:30.401309046 +0100 > @@ -6138,6 +6138,7 @@ vectorizable_reduction (gimple *stmt, gi > > if (gimple_code (stmt) == GIMPLE_PHI) > { > + tree phi_result = gimple_phi_result (stmt); > /* Analysis is fully done on the reduction stmt invocation. */ > if (! vec_stmt) > { > @@ -6158,7 +6159,8 @@ vectorizable_reduction (gimple *stmt, gi > if (STMT_VINFO_IN_PATTERN_P (vinfo_for_stmt (reduc_stmt))) > reduc_stmt = STMT_VINFO_RELATED_STMT (vinfo_for_stmt (reduc_stmt)); > > - if (STMT_VINFO_VEC_REDUCTION_TYPE (vinfo_for_stmt (reduc_stmt)) > + stmt_vec_info reduc_stmt_info = vinfo_for_stmt (reduc_stmt); > + if (STMT_VINFO_VEC_REDUCTION_TYPE (reduc_stmt_info) > == EXTRACT_LAST_REDUCTION) > /* Leave the scalar phi in place. */ > return true; > @@ -6185,15 +6187,12 @@ vectorizable_reduction (gimple *stmt, gi > else > ncopies = vect_get_num_copies (loop_vinfo, vectype_in); > > - use_operand_p use_p; > - gimple *use_stmt; > + stmt_vec_info use_stmt_info; > if (ncopies > 1 > - && (STMT_VINFO_RELEVANT (vinfo_for_stmt (reduc_stmt)) > - <= vect_used_only_live) > - && single_imm_use (gimple_phi_result (stmt), &use_p, &use_stmt) > - && (use_stmt == reduc_stmt > - || (STMT_VINFO_RELATED_STMT (vinfo_for_stmt (use_stmt)) > - == reduc_stmt))) > + && STMT_VINFO_RELEVANT (reduc_stmt_info) <= vect_used_only_live > + && (use_stmt_info = loop_vinfo->lookup_single_use (phi_result)) > + && (use_stmt_info == reduc_stmt_info > + || STMT_VINFO_RELATED_STMT (use_stmt_info) == reduc_stmt)) > single_defuse_cycle = true; > > /* Create the destination vector */ > @@ -6955,13 +6954,13 @@ vectorizable_reduction (gimple *stmt, gi > This only works when we see both the reduction PHI and its only consumer > in vectorizable_reduction and there are no intermediate stmts > participating. */ > - use_operand_p use_p; > - gimple *use_stmt; > + stmt_vec_info use_stmt_info; > + tree reduc_phi_result = gimple_phi_result (reduc_def_stmt); > if (ncopies > 1 > && (STMT_VINFO_RELEVANT (stmt_info) <= vect_used_only_live) > - && single_imm_use (gimple_phi_result (reduc_def_stmt), &use_p, &use_stmt) > - && (use_stmt == stmt > - || STMT_VINFO_RELATED_STMT (vinfo_for_stmt (use_stmt)) == stmt)) > + && (use_stmt_info = loop_vinfo->lookup_single_use (reduc_phi_result)) > + && (use_stmt_info == stmt_info > + || STMT_VINFO_RELATED_STMT (use_stmt_info) == stmt)) > { > single_defuse_cycle = true; > epilog_copies = 1; > Index: gcc/tree-vect-stmts.c > =================================================================== > --- gcc/tree-vect-stmts.c 2018-07-24 10:22:27.281336751 +0100 > +++ gcc/tree-vect-stmts.c 2018-07-24 10:22:30.401309046 +0100 > @@ -10310,14 +10310,11 @@ supportable_widening_operation (enum tre > same operation. One such an example is s += a * b, where elements > in a and b cannot be reordered. Here we check if the vector defined > by STMT is only directly used in the reduction statement. */ > - tree lhs = gimple_assign_lhs (stmt); > - use_operand_p dummy; > - gimple *use_stmt; > - stmt_vec_info use_stmt_info = NULL; > - if (single_imm_use (lhs, &dummy, &use_stmt) > - && (use_stmt_info = vinfo_for_stmt (use_stmt)) > - && STMT_VINFO_DEF_TYPE (use_stmt_info) == vect_reduction_def) > - return true; > + tree lhs = gimple_assign_lhs (stmt); > + stmt_vec_info use_stmt_info = loop_info->lookup_single_use (lhs); > + if (use_stmt_info > + && STMT_VINFO_DEF_TYPE (use_stmt_info) == vect_reduction_def) > + return true; > } > c1 = VEC_WIDEN_MULT_LO_EXPR; > c2 = VEC_WIDEN_MULT_HI_EXPR;