public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Reduce compilation time at -O0 (2/n)
@ 2011-08-02 10:08 Arnaud Charlet
  0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2011-08-02 10:08 UTC (permalink / raw)
  To: gcc-patches; +Cc: Eric Botcazou

[-- Attachment #1: Type: text/plain, Size: 338 bytes --]

This patch slightly reduces compilation time at -O0 in typical conditions by
tuning the implementation of Base_Type to make it more easily optimizable.

No functional changes.

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-08-02  Eric Botcazou  <ebotcazou@adacore.com>

	* einfo.adb (Base_Type): Tune implementation for speed.


[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 1153 bytes --]

Index: einfo.adb
===================================================================
--- einfo.adb	(revision 177110)
+++ einfo.adb	(working copy)
@@ -5608,7 +5608,13 @@
    ---------------
 
    function Base_Type (Id : E) return E is
+      Is_Base_Type : Boolean;
    begin
+      --  Implementation note: this function shows up high in the profile.
+      --  We use a fully static case construct so as to make it easier for
+      --  the compiler to build a static table out of it, instead of using
+      --  a less efficient jump table.
+
       case Ekind (Id) is
          when E_Enumeration_Subtype          |
               E_Incomplete_Type              |
@@ -5628,11 +5634,17 @@
               E_Task_Subtype                 |
               E_String_Literal_Subtype       |
               E_Class_Wide_Subtype           =>
-            return Etype (Id);
+            Is_Base_Type := False;
 
          when others =>
-            return Id;
+            Is_Base_Type := True;
       end case;
+
+      if Is_Base_Type then
+         return Id;
+      end if;
+
+      return Etype (Id);
    end Base_Type;
 
    -------------------------

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

only message in thread, other threads:[~2011-08-02 10:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-02 10:08 [Ada] Reduce compilation time at -O0 (2/n) 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).