public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Optization of predicate checks
@ 2015-10-16 12:33 Arnaud Charlet
  0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2015-10-16 12:33 UTC (permalink / raw)
  To: gcc-patches; +Cc: Ed Schonberg

[-- 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-10-16 12:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-16 12:33 [Ada] Optization of predicate checks Arnaud Charlet

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).