From patchwork Sat Oct 14 16:48:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 825838 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-464220-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="BRKOwBqZ"; dkim-atps=neutral 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 3yDrC00ZMdz9t3Z for ; Sun, 15 Oct 2017 03:48:59 +1100 (AEDT) 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=MKg2w7WvPsomFgz+MdI0EIofhIy88Yf+Gc6XpC1i71d4H0FS7H 0OdHyjEAwLwv7O/yOn0DO75a9lLWiEzaVVDl3Dk3XntJDpeaLjmLqP3nx9adGIBo oXEdD7W5GL1UgJagR3Ejh3VtGhut5FvS2rKk2hZ9ZGwGrcsMe8P2CU760= 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=kJ3nF4Lm3nfEIYkKl8BGWwDGK90=; b=BRKOwBqZ1TkD+zO3i8Xy DTPunAnbHPQwJHectEulztgKC+Y0FuTtaewhLHN53Q/jlDX3XDIQ0zdpWqVsKLfi k4NbqEywPFt+AtQzpV4J3QvQWIIAOI/TUmDKUkyN/nOiHRMO9YUM+PlLx5eSKTbk hOXklTQghT3K4s9P78nKKoM= Received: (qmail 3804 invoked by alias); 14 Oct 2017 16:48:48 -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 2798 invoked by uid 89); 14 Oct 2017 16:48:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=3039, H*Ad:U*ebotcazou, Ent, sk:ebotcaz 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 ESMTP; Sat, 14 Oct 2017 16:48:37 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id DA0A156213; Sat, 14 Oct 2017 12:48:35 -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 w9QHiJE61jXh; Sat, 14 Oct 2017 12:48:35 -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 C7B8A56079; Sat, 14 Oct 2017 12:48:35 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id C6B4A319; Sat, 14 Oct 2017 12:48:35 -0400 (EDT) Date: Sat, 14 Oct 2017 12:48:35 -0400 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [Ada] Fix performance regression of Ada.Numerics on 32-bit Windows Message-ID: <20171014164835.GA103233@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes This fixes a run-time performance regression recently introduced on 32-bit Windows for Ada.Numerics by an unrelated change that exposed an old defect of the compiler on 32-bit Windows, namely that the Long_Long_Float type has got a wrong alignment of 8 instead of the expected 4. The following package: package P is LLF : Long_Long_Float; end P; must yield the following output when compiled with -gnatR2 on 32-bit Windows: Representation information for unit P (spec) -------------------------------------------- for Llf'Size use 96; for Llf'Alignment use 4; Tested on x86_64-pc-linux-gnu, committed on trunk 2017-10-14 Eric Botcazou * cstand.adb (Build_Float_Type): Move down Siz parameter, add Align parameter and set the alignment of the type to Align. (Copy_Float_Type): Adjust call to Build_Float_Type. (Register_Float_Type): Add pragma Unreferenced for Precision. Adjust call to Build_Float_Type and do not set RM_Size and Alignment. Index: cstand.adb =================================================================== --- cstand.adb (revision 253753) +++ cstand.adb (working copy) @@ -62,15 +62,22 @@ ----------------------- procedure Build_Float_Type - (E : Entity_Id; - Siz : Int; - Rep : Float_Rep_Kind; - Digs : Int); + (E : Entity_Id; + Digs : Int; + Rep : Float_Rep_Kind; + Siz : Int; + Align : Int); -- Procedure to build standard predefined float base type. The first - -- parameter is the entity for the type, and the second parameter is the - -- size in bits. The third parameter indicates the kind of representation - -- to be used. The fourth parameter is the digits value. Each type + -- parameter is the entity for the type. The second parameter is the + -- digits value. The third parameter indicates the representation to + -- be used for the type. The fourth parameter is the size in bits. + -- The fifth parameter is the alignment in storage units. Each type -- is added to the list of predefined floating point types. + -- + -- Note that both RM_Size and Esize are set to the specified size, i.e. + -- we do not set the RM_Size to the precision passed by the back end. + -- This is consistent with the semantics of 'Size specified in the RM + -- because we cannot pack components of the type tighter than this size. procedure Build_Signed_Integer_Type (E : Entity_Id; Siz : Nat); -- Procedure to build standard predefined signed integer subtype. The @@ -189,10 +196,11 @@ ---------------------- procedure Build_Float_Type - (E : Entity_Id; - Siz : Int; - Rep : Float_Rep_Kind; - Digs : Int) + (E : Entity_Id; + Digs : Int; + Rep : Float_Rep_Kind; + Siz : Int; + Align : Int) is begin Set_Type_Definition (Parent (E), @@ -201,10 +209,10 @@ Set_Ekind (E, E_Floating_Point_Type); Set_Etype (E, E); - Set_Float_Rep (E, Rep); + Init_Digits_Value (E, Digs); + Set_Float_Rep (E, Rep); Init_Size (E, Siz); - Set_Elem_Alignment (E); - Init_Digits_Value (E, Digs); + Set_Alignment (E, UI_From_Int (Align)); Set_Float_Bounds (E); Set_Is_Frozen (E); Set_Is_Public (E); @@ -295,8 +303,9 @@ procedure Copy_Float_Type (To : Entity_Id; From : Entity_Id) is begin - Build_Float_Type (To, UI_To_Int (Esize (From)), Float_Rep (From), - UI_To_Int (Digits_Value (From))); + Build_Float_Type + (To, UI_To_Int (Digits_Value (From)), Float_Rep (From), + UI_To_Int (Esize (From)), UI_To_Int (Alignment (From))); end Copy_Float_Type; ---------------------- @@ -2065,15 +2074,17 @@ Size : Positive; Alignment : Natural) is + pragma Unreferenced (Precision); + -- See Build_Float_Type for the rationale + Ent : constant Entity_Id := New_Standard_Entity; begin Set_Defining_Identifier (New_Node (N_Full_Type_Declaration, Stloc), Ent); Make_Name (Ent, Name); Set_Scope (Ent, Standard_Standard); - Build_Float_Type (Ent, Int (Size), Float_Rep, Pos (Digs)); - Set_RM_Size (Ent, UI_From_Int (Int (Precision))); - Set_Alignment (Ent, UI_From_Int (Int (Alignment / 8))); + Build_Float_Type + (Ent, Pos (Digs), Float_Rep, Int (Size), Int (Alignment / 8)); if No (Back_End_Float_Types) then Back_End_Float_Types := New_Elmt_List;