From patchwork Mon May 1 10:18:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 757028 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 3wGgPZ69vbz9sD9 for ; Mon, 1 May 2017 20:18:50 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Qtcy3qzy"; 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=CO97XcqDpHW7uEIp NwzBiewxhniQ38KzrkTjB/4UTJ6uSceldUegSuuYUNkccBNBJrxufsHunAAE9SZF zcHsC4uesW87WqszDVXhD1CYduLRWTp1HL3NQ59wbmxJFTadYCSkQpRVijzOj8Gk EcpNorVnhAQvxoElQPbUeMziM70= 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=ypqkdvcvs9b86Wdv7N3SFs gIYog=; b=Qtcy3qzy01Xqgq6E8x/PRQ74hksy2Jf/KzSaMA1k1YABfIzr9pPCbr yL2jBpqPQ4JGxJlp8NxSgXdquQphnUYKlDHQjAlazlKMBToppLXPEzQbPx01CA3B uIIWT3V6mmllz76NWaXi1f84aXuEVzbZKjG6yaspckqOJEC43OIvc= Received: (qmail 28392 invoked by alias); 1 May 2017 10:18:39 -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 28379 invoked by uid 89); 1 May 2017 10:18:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 01 May 2017 10:18:36 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 09E9781378 for ; Mon, 1 May 2017 12:18:35 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HTA1tavFTuGf for ; Mon, 1 May 2017 12:18:34 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id DA67681348 for ; Mon, 1 May 2017 12:18:34 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [patch] Inline size functions in more cases Date: Mon, 01 May 2017 12:18:33 +0200 Message-ID: <8075953.ygbierXBQ8@polaris> User-Agent: KMail/4.14.10 (Linux/3.16.7-53-desktop; KDE/4.14.9; x86_64; ; ) MIME-Version: 1.0 Because variable-sized types are first-class citizens in Ada, the compiler factors out size (and offset) computations into size functions in order to make these types less heavyweight to manipulate. The counterpart is that it needs to inline back these size functions into regular expressions in some cases, for example when it constrains an originally unconstrained type. This patch makes the compiler inline these functions in a little more cases. Tested on x86_64-suse-linux, applied on the mainline (it only affects Ada). 2017-05-01 Eric Botcazou * tree.c (substitute_in_expr) : Also inline a call if the replacement expression is another instance of one of its arguments. Index: tree.c =================================================================== --- tree.c (revision 247405) +++ tree.c (working copy) @@ -3886,15 +3886,29 @@ substitute_in_expr (tree exp, tree f, tr new_tree = NULL_TREE; - /* If we are trying to replace F with a constant, inline back + /* If we are trying to replace F with a constant or with another + instance of one of the arguments of the call, inline back functions which do nothing else than computing a value from the arguments they are passed. This makes it possible to fold partially or entirely the replacement expression. */ - if (CONSTANT_CLASS_P (r) && code == CALL_EXPR) + if (code == CALL_EXPR) { - tree t = maybe_inline_call_in_expr (exp); - if (t) - return SUBSTITUTE_IN_EXPR (t, f, r); + bool maybe_inline = false; + if (CONSTANT_CLASS_P (r)) + maybe_inline = true; + else + for (i = 3; i < TREE_OPERAND_LENGTH (exp); i++) + if (operand_equal_p (TREE_OPERAND (exp, i), r, 0)) + { + maybe_inline = true; + break; + } + if (maybe_inline) + { + tree t = maybe_inline_call_in_expr (exp); + if (t) + return SUBSTITUTE_IN_EXPR (t, f, r); + } } for (i = 1; i < TREE_OPERAND_LENGTH (exp); i++)