From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1914) id 94CCC385800E; Tue, 9 Nov 2021 09:46:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 94CCC385800E MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Pierre-Marie de Rodat To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-5026] [Ada] Simplify expansion of array equality X-Act-Checkin: gcc X-Git-Author: Piotr Trojanek X-Git-Refname: refs/heads/master X-Git-Oldrev: f4665dc4fb511a40a104f1986488861fee8b24f7 X-Git-Newrev: 02ca2184cdabf79c8c8353b7d464f15d26d1f24f Message-Id: <20211109094620.94CCC385800E@sourceware.org> Date: Tue, 9 Nov 2021 09:46:20 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Nov 2021 09:46:20 -0000 https://gcc.gnu.org/g:02ca2184cdabf79c8c8353b7d464f15d26d1f24f commit r12-5026-g02ca2184cdabf79c8c8353b7d464f15d26d1f24f Author: Piotr Trojanek Date: Tue Oct 26 18:05:43 2021 +0200 [Ada] Simplify expansion of array equality gcc/ada/ * exp_ch4.adb (Test_Empty_Arrays): Simplify with Evolve_Or_Else; remove unnecessary call to Relocate_Node. (Test_Lengths_Correspond): Likewise. Diff: --- gcc/ada/exp_ch4.adb | 50 +++++++++----------------------------------------- 1 file changed, 9 insertions(+), 41 deletions(-) diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 93dffb66011..26996444735 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -1902,41 +1902,20 @@ package body Exp_Ch4 is ----------------------- function Test_Empty_Arrays return Node_Id is - Alist : Node_Id; - Blist : Node_Id; - - Atest : Node_Id; - Btest : Node_Id; + Alist : Node_Id := Empty; + Blist : Node_Id := Empty; begin - Alist := Empty; - Blist := Empty; for J in 1 .. Number_Dimensions (Ltyp) loop - Atest := + Evolve_Or_Else (Alist, Make_Op_Eq (Loc, Left_Opnd => Arr_Attr (A, Name_Length, J), - Right_Opnd => Make_Integer_Literal (Loc, 0)); + Right_Opnd => Make_Integer_Literal (Loc, Uint_0))); - Btest := + Evolve_Or_Else (Blist, Make_Op_Eq (Loc, Left_Opnd => Arr_Attr (B, Name_Length, J), - Right_Opnd => Make_Integer_Literal (Loc, 0)); - - if No (Alist) then - Alist := Atest; - Blist := Btest; - - else - Alist := - Make_Or_Else (Loc, - Left_Opnd => Relocate_Node (Alist), - Right_Opnd => Atest); - - Blist := - Make_Or_Else (Loc, - Left_Opnd => Relocate_Node (Blist), - Right_Opnd => Btest); - end if; + Right_Opnd => Make_Integer_Literal (Loc, Uint_0))); end loop; return @@ -1950,25 +1929,14 @@ package body Exp_Ch4 is ----------------------------- function Test_Lengths_Correspond return Node_Id is - Result : Node_Id; - Rtest : Node_Id; + Result : Node_Id := Empty; begin - Result := Empty; for J in 1 .. Number_Dimensions (Ltyp) loop - Rtest := + Evolve_Or_Else (Result, Make_Op_Ne (Loc, Left_Opnd => Arr_Attr (A, Name_Length, J), - Right_Opnd => Arr_Attr (B, Name_Length, J)); - - if No (Result) then - Result := Rtest; - else - Result := - Make_Or_Else (Loc, - Left_Opnd => Relocate_Node (Result), - Right_Opnd => Rtest); - end if; + Right_Opnd => Arr_Attr (B, Name_Length, J))); end loop; return Result;