From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1285) id 247813858C42; Sat, 3 Feb 2024 12:27:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 247813858C42 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706963251; bh=uGFUKxxDthR7sKJ5M8OPWC8t/OsG9friVs9pI62SVOY=; h=From:To:Subject:Date:From; b=ydr2tG9k0Xfip5U4R45qQDbLofOOtqKp2HwZ2s+S/YmTaMkipRzkZdst8JCeCqW4j fzYcWw6XONgHSsFU/e/H87/MMfavLuSyurszlQm0XZMeRbhkfythp87SUe4WE/JS1R 7v22mLMURNmwGS+Uuxh6+S4hceL6kumpx/lvCma8= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Eric Botcazou To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-8276] Revert use of accumulator type in expansion of 'Reduce attribute X-Act-Checkin: gcc X-Git-Author: Eric Botcazou X-Git-Refname: refs/heads/releases/gcc-13 X-Git-Oldrev: 58ffc0f066731786a11c4bee8217c71c4949262e X-Git-Newrev: 79d0dd71302daf51448a07e42ab77a397e2cf0a8 Message-Id: <20240203122731.247813858C42@sourceware.org> Date: Sat, 3 Feb 2024 12:27:31 +0000 (GMT) List-Id: https://gcc.gnu.org/g:79d0dd71302daf51448a07e42ab77a397e2cf0a8 commit r13-8276-g79d0dd71302daf51448a07e42ab77a397e2cf0a8 Author: Eric Botcazou Date: Sat Feb 3 13:26:03 2024 +0100 Revert use of accumulator type in expansion of 'Reduce attribute gcc/ada * exp_attr.adb (Expand_N_Attribute_Reference): Revert older change. Diff: --- gcc/ada/exp_attr.adb | 72 ++++++++-------------------------------------------- 1 file changed, 10 insertions(+), 62 deletions(-) diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index 7e71422eba3b..aababd516d54 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -5978,30 +5978,27 @@ package body Exp_Attr is when Attribute_Reduce => declare Loc : constant Source_Ptr := Sloc (N); - E1 : constant Node_Id := First (Expressions (N)); - E2 : constant Node_Id := Next (E1); - Bnn : constant Entity_Id := Make_Temporary (Loc, 'B', N); + E1 : constant Node_Id := First (Expressions (N)); + E2 : constant Node_Id := Next (E1); + Bnn : constant Entity_Id := Make_Temporary (Loc, 'B', N); + Typ : constant Entity_Id := Etype (N); - Accum_Typ : Entity_Id; - New_Loop : Node_Id; + New_Loop : Node_Id; + Stat : Node_Id; function Build_Stat (Comp : Node_Id) return Node_Id; -- The reducer can be a function, a procedure whose first -- parameter is in-out, or an attribute that is a function, -- which (for now) can only be Min/Max. This subprogram - -- builds the corresponding computation for the generated loop - -- and retrieves the accumulator type as per RM 4.5.10(19/5). + -- builds the corresponding computation for the generated loop. ---------------- -- Build_Stat -- ---------------- function Build_Stat (Comp : Node_Id) return Node_Id is - Stat : Node_Id; - begin if Nkind (E1) = N_Attribute_Reference then - Accum_Typ := Entity (Prefix (E1)); Stat := Make_Assignment_Statement (Loc, Name => New_Occurrence_Of (Bnn, Loc), Expression => Make_Attribute_Reference (Loc, @@ -6012,14 +6009,12 @@ package body Exp_Attr is Comp))); elsif Ekind (Entity (E1)) = E_Procedure then - Accum_Typ := Etype (First_Formal (Entity (E1))); Stat := Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (Entity (E1), Loc), Parameter_Associations => New_List ( New_Occurrence_Of (Bnn, Loc), Comp)); else - Accum_Typ := Etype (Entity (E1)); Stat := Make_Assignment_Statement (Loc, Name => New_Occurrence_Of (Bnn, Loc), Expression => Make_Function_Call (Loc, @@ -6079,13 +6074,6 @@ package body Exp_Attr is End_Label => Empty, Statements => New_List (Build_Stat (Relocate_Node (Expr)))); - - -- If the reducer subprogram is a universal operator, then - -- we still look at the context to find the type for now. - - if Is_Universal_Numeric_Type (Accum_Typ) then - Accum_Typ := Etype (N); - end if; end; else @@ -6094,9 +6082,8 @@ package body Exp_Attr is -- a container with the proper aspects. declare - Elem : constant Entity_Id := Make_Temporary (Loc, 'E', N); - Iter : Node_Id; + Elem : constant Entity_Id := Make_Temporary (Loc, 'E', N); begin Iter := @@ -6114,44 +6101,6 @@ package body Exp_Attr is End_Label => Empty, Statements => New_List ( Build_Stat (New_Occurrence_Of (Elem, Loc)))); - - -- If the reducer subprogram is a universal operator, then - -- we need to look at the prefix to find the type. This is - -- modeled on Analyze_Iterator_Specification in Sem_Ch5. - - if Is_Universal_Numeric_Type (Accum_Typ) then - declare - Ptyp : constant Entity_Id := - Base_Type (Etype (Prefix (N))); - - begin - if Is_Array_Type (Ptyp) then - Accum_Typ := Component_Type (Ptyp); - - elsif Has_Aspect (Ptyp, Aspect_Iterable) then - declare - Element : constant Entity_Id := - Get_Iterable_Type_Primitive - (Ptyp, Name_Element); - begin - if Present (Element) then - Accum_Typ := Etype (Element); - end if; - end; - - else - declare - Element : constant Node_Id := - Find_Value_Of_Aspect - (Ptyp, Aspect_Iterator_Element); - begin - if Present (Element) then - Accum_Typ := Entity (Element); - end if; - end; - end if; - end; - end if; end; end if; @@ -6161,11 +6110,10 @@ package body Exp_Attr is Make_Object_Declaration (Loc, Defining_Identifier => Bnn, Object_Definition => - New_Occurrence_Of (Accum_Typ, Loc), + New_Occurrence_Of (Typ, Loc), Expression => Relocate_Node (E2)), New_Loop), Expression => New_Occurrence_Of (Bnn, Loc))); - - Analyze_And_Resolve (N, Accum_Typ); + Analyze_And_Resolve (N, Typ); end; ----------