From patchwork Mon Oct 26 09:41:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 535779 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1C14B140E31 for ; Mon, 26 Oct 2015 20:41:41 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=mDD30aqz; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=CwZLOLXEGFYbrnLm 5sUArNPaI47R0fmUQC73DM2oYdB0Z9o6nrpUX0Me3i478UhDuhX9jbMPecNjJi7q gqobh9n6yMv4yf6dfkdGUKroqt5mzd35jEtN60DY1WxIu35Pes1BJbMPch7+0TZ9 lzgiEt6zrsEqBIV66hcrZSykBEw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=EKXtDB6OBaJL844QqlrpPH Q/VMw=; b=mDD30aqzfjB5jZFTaStYWOqS8sxVv3xrp4PVwYOVa/el7r+cX96aBW h1YZtDItwUUypgwm1hZz8Q7PfRQoiFP7g75KRT79SUTdtvs8anja+zYcqI2SZVCK pizxrCPU9pilWbMVuM9Yj76dqficG+XQd77LN49fBf/2ojjn/JwQ8= Received: (qmail 103883 invoked by alias); 26 Oct 2015 09:41:33 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 103867 invoked by uid 89); 26 Oct 2015 09:41:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=BAYES_00, FREEMAIL_FROM, SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (146.101.78.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 26 Oct 2015 09:41:31 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-7-Aowb8gw9RAWaopAhff3tFg-1; Mon, 26 Oct 2015 09:41:25 +0000 Received: from localhost ([10.1.2.79]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 26 Oct 2015 09:41:25 +0000 From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: Allow more complex call replacements in gimple-fold.c Date: Mon, 26 Oct 2015 09:41:25 +0000 Message-ID: <87si4yvuey.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-MC-Unique: Aowb8gw9RAWaopAhff3tFg-1 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? 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)