From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13913 invoked by alias); 31 Jul 2018 12:03:22 -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 13096 invoked by uid 89); 31 Jul 2018 12:03:21 -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= X-HELO: mail-lf1-f67.google.com Received: from mail-lf1-f67.google.com (HELO mail-lf1-f67.google.com) (209.85.167.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 31 Jul 2018 12:03:16 +0000 Received: by mail-lf1-f67.google.com with SMTP id a134-v6so10532792lfe.6 for ; Tue, 31 Jul 2018 05:03:15 -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=j4rLxk1/1aFdM4485nkHGsXmW4/l4mITSDSR+cMMn5Y=; b=RW3eQR1vbWr+2euWs2xJYBsZMZ9KHgXMPdW2T9PR1RluyfuRdJTSv7yLwi3TZ+J1Qg S6Zi5SSSWm8KyIQ+UnpZvQufWf3o8DdT0evnP3RwWQisTnztIjOrZu+pnyJMHXCHdUrx EvqDqfi2zPzFTiphJLD9PLQyQBTufqOUUGVPG7MCQg4s51wDzjSFbKs9u0cR+RPeZ0gO gGoNGpLyBWVOmwCD69SwOXQMYf/adh3xyA2gmDQ005K5h4La/ToDWjVqIyzLrpBRvFxE HWMlJaInwEHgahI3u+oaE6Hk03fu93xf8GE9cC8Qf5U6IAw5JtfarByFjNYD7tGjp+He 4vew== MIME-Version: 1.0 References: <87wotlrmen.fsf@arm.com> <87va95kkrb.fsf@arm.com> In-Reply-To: <87va95kkrb.fsf@arm.com> From: Richard Biener Date: Tue, 31 Jul 2018 12:03:00 -0000 Message-ID: Subject: Re: [42/46] Add vec_info::replace_stmt To: GCC Patches , richard.sandiford@arm.com Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-07/txt/msg01923.txt.bz2 On Tue, Jul 24, 2018 at 12:09 PM Richard Sandiford wrote: > > This patch adds a helper for replacing a stmt_vec_info's statement with > a new statement. OK. > > 2018-07-24 Richard Sandiford > > gcc/ > * tree-vectorizer.h (vec_info::replace_stmt): Declare. > * tree-vectorizer.c (vec_info::replace_stmt): New function. > * tree-vect-slp.c (vect_remove_slp_scalar_calls): Use it. > * tree-vect-stmts.c (vectorizable_call): Likewise. > (vectorizable_simd_clone_call): Likewise. > > Index: gcc/tree-vectorizer.h > =================================================================== > --- gcc/tree-vectorizer.h 2018-07-24 10:24:19.544339803 +0100 > +++ gcc/tree-vectorizer.h 2018-07-24 10:24:22.684311906 +0100 > @@ -242,6 +242,7 @@ struct vec_info { > stmt_vec_info lookup_single_use (tree); > stmt_vec_info lookup_dr (data_reference *); > void remove_stmt (stmt_vec_info); > + void replace_stmt (gimple_stmt_iterator *, stmt_vec_info, gimple *); > > /* The type of vectorization. */ > vec_kind kind; > Index: gcc/tree-vectorizer.c > =================================================================== > --- gcc/tree-vectorizer.c 2018-07-24 10:24:19.544339803 +0100 > +++ gcc/tree-vectorizer.c 2018-07-24 10:24:22.684311906 +0100 > @@ -591,6 +591,22 @@ vec_info::remove_stmt (stmt_vec_info stm > free_stmt_vec_info (stmt_info); > } > > +/* Replace the statement at GSI by NEW_STMT, both the vectorization > + information and the function itself. STMT_INFO describes the statement > + at GSI. */ > + > +void > +vec_info::replace_stmt (gimple_stmt_iterator *gsi, stmt_vec_info stmt_info, > + gimple *new_stmt) > +{ > + gimple *old_stmt = stmt_info->stmt; > + gcc_assert (!stmt_info->pattern_stmt_p && old_stmt == gsi_stmt (*gsi)); > + set_vinfo_for_stmt (old_stmt, NULL); > + set_vinfo_for_stmt (new_stmt, stmt_info); > + stmt_info->stmt = new_stmt; > + gsi_replace (gsi, new_stmt, true); > +} > + > /* A helper function to free scev and LOOP niter information, as well as > clear loop constraint LOOP_C_FINITE. */ > > Index: gcc/tree-vect-slp.c > =================================================================== > --- gcc/tree-vect-slp.c 2018-07-24 10:24:19.540339838 +0100 > +++ gcc/tree-vect-slp.c 2018-07-24 10:24:22.680311942 +0100 > @@ -4048,11 +4048,8 @@ vect_remove_slp_scalar_calls (slp_tree n > continue; > lhs = gimple_call_lhs (stmt); > new_stmt = gimple_build_assign (lhs, build_zero_cst (TREE_TYPE (lhs))); > - set_vinfo_for_stmt (new_stmt, stmt_info); > - set_vinfo_for_stmt (stmt, NULL); > - STMT_VINFO_STMT (stmt_info) = new_stmt; > gsi = gsi_for_stmt (stmt); > - gsi_replace (&gsi, new_stmt, false); > + stmt_info->vinfo->replace_stmt (&gsi, stmt_info, new_stmt); > SSA_NAME_DEF_STMT (gimple_assign_lhs (new_stmt)) = new_stmt; > } > } > Index: gcc/tree-vect-stmts.c > =================================================================== > --- gcc/tree-vect-stmts.c 2018-07-24 10:24:19.544339803 +0100 > +++ gcc/tree-vect-stmts.c 2018-07-24 10:24:22.684311906 +0100 > @@ -3629,10 +3629,7 @@ vectorizable_call (stmt_vec_info stmt_in > > gassign *new_stmt > = gimple_build_assign (lhs, build_zero_cst (TREE_TYPE (lhs))); > - set_vinfo_for_stmt (new_stmt, stmt_info); > - set_vinfo_for_stmt (stmt_info->stmt, NULL); > - STMT_VINFO_STMT (stmt_info) = new_stmt; > - gsi_replace (gsi, new_stmt, false); > + vinfo->replace_stmt (gsi, stmt_info, new_stmt); > > return true; > } > @@ -4370,10 +4367,7 @@ vectorizable_simd_clone_call (stmt_vec_i > } > else > new_stmt = gimple_build_nop (); > - set_vinfo_for_stmt (new_stmt, stmt_info); > - set_vinfo_for_stmt (stmt, NULL); > - STMT_VINFO_STMT (stmt_info) = new_stmt; > - gsi_replace (gsi, new_stmt, true); > + vinfo->replace_stmt (gsi, stmt_info, new_stmt); > unlink_stmt_vdef (stmt); > > return true;