From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5941 invoked by alias); 26 Oct 2015 10:11:21 -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 5921 invoked by uid 89); 26 Oct 2015 10:11:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yk0-f175.google.com Received: from mail-yk0-f175.google.com (HELO mail-yk0-f175.google.com) (209.85.160.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 26 Oct 2015 10:11:18 +0000 Received: by ykba4 with SMTP id a4so172135757ykb.3 for ; Mon, 26 Oct 2015 03:11:16 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.129.125.194 with SMTP id y185mr24629314ywc.5.1445854276763; Mon, 26 Oct 2015 03:11:16 -0700 (PDT) Received: by 10.37.117.136 with HTTP; Mon, 26 Oct 2015 03:11:16 -0700 (PDT) In-Reply-To: <87si4yvuey.fsf@e105548-lin.cambridge.arm.com> References: <87si4yvuey.fsf@e105548-lin.cambridge.arm.com> Date: Mon, 26 Oct 2015 10:14:00 -0000 Message-ID: Subject: Re: Allow more complex call replacements in gimple-fold.c From: Richard Biener To: GCC Patches , richard.sandiford@arm.com Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-10/txt/msg02672.txt.bz2 On Mon, Oct 26, 2015 at 10:41 AM, Richard Sandiford wrote: > An upcoming patch adds a match.pd rule that folds pow(pow(x,y),z) > to pow(x,y*z). This fold can reuse the existing pow gimple statement > and simply replace the operands with x and y*z. However, the y*z > itself requires a separate gimple statement and the code wasn't > prepared to handle that. > > Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi. > OK to install? Hmm, I put the assert there because of the !inplace case but I see the is_tree_code case alredy behaves the same. I think the intent of fold_stmt_inplace (and thus the 'inplace' case) was that no additional stmts are inserted (and obviously the stmt itself being not replaced, so gsi_stmt () is the same before and after). So I think both the is_gimple_assign && is_tree_code and the case you are amending need a if (inplace && !gimple_seq_empty_p (*seq)) return false; Thanks, Richard. > Thanks, > Richard > > > gcc/ > * gimple-fold.c (replace_stmt_with_simplification): Allow calls > to have nonempty sequences. > > diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c > index 1869c09..4b9b782 100644 > --- a/gcc/gimple-fold.c > +++ b/gcc/gimple-fold.c > @@ -3365,7 +3365,14 @@ replace_stmt_with_simplification (gimple_stmt_iterator *gsi, > } > if (i < 3) > gcc_assert (ops[i] == NULL_TREE); > - gcc_assert (gimple_seq_empty_p (*seq)); > + if (dump_file && (dump_flags & TDF_DETAILS)) > + { > + fprintf (dump_file, "gimple_simplified to "); > + if (!gimple_seq_empty_p (*seq)) > + print_gimple_seq (dump_file, *seq, 0, TDF_SLIM); > + print_gimple_stmt (dump_file, gsi_stmt (*gsi), 0, TDF_SLIM); > + } > + gsi_insert_seq_before (gsi, *seq, GSI_SAME_STMT); > return true; > } > else if (!inplace) >