From patchwork Fri Oct 16 12:33:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 531298 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 8F8631402B6 for ; Fri, 16 Oct 2015 23:33:47 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=EsMe48eu; 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:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=tWgTsgQg+S0av3JWLF4cw8dC3rPzaW9vbuGf7rdIZ/vsZJ94s/ xUXlBjxirPIpArkba4HZvhEr28ufF3mhqeDmHnHWPtUNbG1T4Feu8x7jJeLIOqCB yWAtgcptDGxPoj0O2XxSCou1f9Xz2acqWUv2pBgX0KFjzrTp+NfxVLQvc= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=hZt/B8Trb1WNCwQ5X6vmozBW79A=; b=EsMe48euwByA8w6QG9lY 9XCdPLJ2PaqUBXcjjsVLMM1F/Yop8QqwXO1hgwAuxTs/JKoARF0lqIZiU0MI5V5G 9ekmBnvkHpJTvESiQvNjEn1ckb/Q74c9iUHmSoIlP2iIM8pcWlcFOgYHGZOjybur OUvkJzIBxODEp9jS3l7qzCA= Received: (qmail 100191 invoked by alias); 16 Oct 2015 12:33:24 -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 100120 invoked by uid 89); 16 Oct 2015 12:33:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.2 required=5.0 tests=BAYES_05, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 16 Oct 2015 12:33:22 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 86AEB118239; Fri, 16 Oct 2015 08:33:20 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 5cx+Sg80byXh; Fri, 16 Oct 2015 08:33:20 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id 76D7B118234; Fri, 16 Oct 2015 08:33:20 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id 71A1536E; Fri, 16 Oct 2015 08:33:20 -0400 (EDT) Date: Fri, 16 Oct 2015 08:33:20 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Optization of predicate checks Message-ID: <20151016123320.GA24069@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) This patch marks the generated predicate functions as Pure, so that the back-end can optimize redundant calls to these functions when inlining and high level of optimization are requested. This is a performance enhancement, no change in behavior. Tested on x86_64-pc-linux-gnu, committed on trunk 2015-10-16 Ed Schonberg * sem_ch13.adb (Build_Predicate_Functions): If expression for predicate is side-effect free, indicate that the predicate function is pure, to allow for optimization of redundant predicate checks. Index: sem_ch13.adb =================================================================== --- sem_ch13.adb (revision 228874) +++ sem_ch13.adb (working copy) @@ -8702,6 +8702,16 @@ Insert_Before_And_Analyze (N, FDecl); Insert_After_And_Analyze (N, FBody); + + -- Static predicate functions are always side-effect free, and + -- in most cases dynamic predicate functions are as well. Mark + -- them as such whenever possible, so redundant predicate checks + -- can be optimized. + + if Expander_Active then + Set_Is_Pure (SId, Side_Effect_Free (Expr)); + Set_Is_Inlined (SId); + end if; end; -- Test for raise expressions present and if so build M version