From: Arnaud Charlet <charlet@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Ed Schonberg <schonberg@adacore.com>
Subject: [Ada] Optization of predicate checks
Date: Fri, 16 Oct 2015 12:33:00 -0000 [thread overview]
Message-ID: <20151016123320.GA24069@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 552 bytes --]
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 <schonberg@adacore.com>
* 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.
[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 802 bytes --]
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
reply other threads:[~2015-10-16 12:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151016123320.GA24069@adacore.com \
--to=charlet@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=schonberg@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).