[PATCH] ada: Simplify code while building boolean expression

Samuel Tardieu sam@rfc1149.net
Thu Aug 7 13:47:00 GMT 2008


Simplify code by building

  if Boolean (B'First) and Boolean (B'Last) then

instead of

  if B'First = BT (True) and B'Last = BT (True) then

in Silly_Boolean_Array_Xor_Test.

Tested on i686-pc-linux-gnu. Ok for trunk?

    gcc/ada/
	* exp_util.adb (Silly_Boolean_Array_Xor_Test): Simplify code.
---
 gcc/ada/exp_util.adb |   28 ++++++++--------------------
 1 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 09850f6..4381ad9 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -5147,7 +5147,6 @@ package body Exp_Util is
    procedure Silly_Boolean_Array_Xor_Test (N : Node_Id; T : Entity_Id) is
       Loc : constant Source_Ptr := Sloc (N);
       CT  : constant Entity_Id  := Component_Type (T);
-      BT  : constant Entity_Id  := Base_Type (CT);
 
    begin
       Insert_Action (N,
@@ -5155,26 +5154,15 @@ package body Exp_Util is
           Condition =>
             Make_Op_And (Loc,
               Left_Opnd =>
-                Make_Op_Eq (Loc,
-                  Left_Opnd =>
-                    Make_Attribute_Reference (Loc,
-                      Prefix         => New_Occurrence_Of (CT, Loc),
-                      Attribute_Name => Name_First),
-
-                  Right_Opnd =>
-                    Convert_To (BT,
-                      New_Occurrence_Of (Standard_True, Loc))),
-
+                Convert_To (Standard_Boolean,
+                  Make_Attribute_Reference (Loc,
+                    Prefix         => New_Occurrence_Of (CT, Loc),
+                    Attribute_Name => Name_First)),
               Right_Opnd =>
-                Make_Op_Eq (Loc,
-                  Left_Opnd =>
-                    Make_Attribute_Reference (Loc,
-                      Prefix         => New_Occurrence_Of (CT, Loc),
-                      Attribute_Name => Name_Last),
-
-                  Right_Opnd =>
-                    Convert_To (BT,
-                      New_Occurrence_Of (Standard_True, Loc)))),
+                Convert_To (Standard_Boolean,
+                  Make_Attribute_Reference (Loc,
+                    Prefix         => New_Occurrence_Of (CT, Loc),
+                    Attribute_Name => Name_Last))),
           Reason => CE_Range_Check_Failed));
    end Silly_Boolean_Array_Xor_Test;
 
-- 
1.6.0.rc0.182.gb96c7



More information about the Gcc-patches mailing list