From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,103803355c3db607 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.224.138.146 with SMTP id a18mr156758qau.6.1343262293803; Wed, 25 Jul 2012 17:24:53 -0700 (PDT) Received: by 10.66.72.165 with SMTP id e5mr1275853pav.4.1343262185541; Wed, 25 Jul 2012 17:23:05 -0700 (PDT) Path: a15ni95130680qag.0!nntp.google.com!q21no16455496qas.0!news-out.google.com!p10ni59864680pbh.1!nntp.google.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!ctu-peer!ctu-gate!news.nctu.edu.tw!usenet.stanford.edu!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Keean Schupke Newsgroups: comp.lang.ada Subject: Re: GNAT (GCC) Profile Guided Compilation Date: Wed, 18 Jul 2012 10:36:00 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <982d531a-3972-4971-b802-c7e7778b8649@googlegroups.com> <520bdc39-6004-4142-a227-facf14ebb0e8@googlegroups.com> <4ff08cb2$0$6575$9b4e6d93@newsspool3.arcor-online.net> <4ff1d731$0$6582$9b4e6d93@newsspool3.arcor-online.net> <4ff41d38$0$6577$9b4e6d93@newsspool3.arcor-online.net> <26b778c4-5abc-4fbf-94b0-888c2ce71831@googlegroups.com> <4ff43956$0$6576$9b4e6d93@newsspool3.arcor-online.net> <2dba1140-4f28-4fb8-ace4-2c10f3a02313@googlegroups.com> <505460ad-495d-41b4-a88f-e95eb99a6be3@googlegroups.com> <50068967$0$9507$9b4e6d93@newsspool1.arcor-online.net> NNTP-Posting-Host: 82.44.19.199 Mime-Version: 1.0 X-Trace: posting.google.com 1342632961 31207 127.0.0.1 (18 Jul 2012 17:36:01 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 18 Jul 2012 17:36:01 +0000 (UTC) In-Reply-To: <50068967$0$9507$9b4e6d93@newsspool1.arcor-online.net> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=82.44.19.199; posting-account=T5Z2vAoAAAB8ExE3yV3f56dVATtEMNcM User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-07-18T10:36:00-07:00 List-Id: On Wednesday, 18 July 2012 11:01:11 UTC+1, Georg Bauhaus wrote: > On 15.07.12 10:27, Keean Schupke wrote: > > function F(N : Node, V : Value) return Boolean is begin ( > > return (N.Enum = Const) or else ((N.Enum = V) = (N.Number = 0)); > > ) > > > > B : constant Boolean = F(N1, V) > > and then F(N2, V) > > and then F(N3, V) > > and then F(N4, V); > > > > FWIW, I have two observations after playing with the above function: > > Using different ways of supplying the variables to F and to functions > like it, two things seemed to have noticeable influence: > > 1) making the Node record limited (good) > 2) supplying the values, not the record, to F (possibly good) > > The results have varied a lot with everything (CPU, compiler, switches, ...), > and I haven't checked the indirections for correctness; in any case, > plain F (record components) did well. > > with System; > package News_23.Choice is > > function F (N : Node; V : Value) return Boolean; > function FA (N : Node; V : Value) return Boolean; > function FP1 (p : System.Address; V : Value) return Boolean; > function FP2 (p : System.Address; V : Value) return Boolean; > function FP3 (p : System.Address; V : Value) return Boolean; > function F_3_Args (Enum : Value; > Number : Numeric; > V : Value) return Boolean; > private > Const : constant Value := Two; > end News_23.choice; > > with System.Address_To_Access_Conversions, System.Storage_Elements; > with Ada.Unchecked_Conversion; > package body News_23.Choice is > > use System.Storage_Elements; > Enum_Offset : constant := 4 * Storage_Element'Size; > Number_Offset : constant := 8 * Storage_Element'Size; > > function F(N : Node; V : Value) return Boolean is begin > return (N.Enum = Const) or else ((N.Enum = V) = (N.Number = 0)); > end; > > package Value_P is new System.Address_To_Access_Conversions > (Object => Value); > package Numeric_P is new System.Address_To_Access_Conversions > (Object => Numeric); > > function FA(N : Node; V : Value) return Boolean is > begin > declare > -- Enm : Value_P.Object_Pointer renames Value_P.To_Pointer (N'Address + > N.Enum'Position); > -- Num : Numeric_P.Object_Pointer renames Numeric_P.To_Pointer (N'Address + > N.Number'Position); > Enm : Value_P.Object_Pointer renames Value_P.To_Pointer (N'Address + > Enum_Offset); > Num : Numeric_P.Object_Pointer renames Numeric_P.To_Pointer (N'Address + > Number_Offset); > begin > return (Enm.all = Const) or else ((Enm.all = V) = (Num.all = 0)); > end; > end FA; > > function FP1 (P : System.Address; V : Value) return Boolean is > Enm : Value; > pragma Import (Ada, Enm); > for Enm'Address use P + Enum_Offset; > Num : Numeric; > pragma Import (Ada, Num); > for Num'Address use P + Number_Offset; > begin > pragma Inspection_Point (P); > return (Enm = Const) or else ((Enm = V) = (Num = 0)); > end FP1; > > function FP2 (P : System.Address; V : Value) return Boolean is > Enm : Value; > pragma Import (Ada, Enm); > for Enm'Address use To_Address (To_Integer (P) + Enum_Offset); > Num : Numeric; > pragma Import (Ada, Num); > for Num'Address use To_Address (To_Integer (P) + Number_Offset); > begin > pragma Inspection_Point (P); > return (Enm = Const) or else ((Enm = V) = (Num = 0)); > end FP2; > > type Adr is mod 2**Standard'Address_Size; > function To_N is new Ada.Unchecked_Conversion (System.Address, Adr); > function To_Adr is new Ada.Unchecked_Conversion (Adr, System.Address); > > function FP3 (P : System.Address; V : Value) return Boolean is > Enm : Value; > pragma Import (Ada, Enm); > for Enm'Address use To_Adr (To_N (P) + Enum_Offset); > Num : Numeric; > pragma Import (Ada, Num); > for Num'Address use To_Adr (To_N (P) + Number_Offset); > begin > pragma Inspection_Point (P); > return (Enm = Const) or else ((Enm = V) = (Num = 0)); > end FP3; > > function F_3_Args(Enum : Value; Number : Numeric ; V : Value) return > Boolean is begin > return (Enum = Const) or else ((Enum = V) = (Number = 0)); > end F_3_Args; > > end News_23.Choice; I think if you use -O3 -gnatn (and pragma Inline(X)) the function will be inlined. Does it still make a difference then? Cheers, Keean.