From 0af16535246ef8a9a814da6a3ae7a5bcae89dc30 Mon Sep 17 00:00:00 2001 From: Bob Duff Date: Wed, 18 Sep 2019 08:32:51 +0000 Subject: [PATCH] [Ada] Improve efficiency of copying bit-packed slices This patch substantially improves the efficiency of copying large slices of bit-packed arrays, by copying 32 bits at a time instead of 1 at a time. 2019-09-18 Bob Duff gcc/ada/ * exp_ch5.adb (Expand_Assign_Array_Loop_Or_Bitfield): The call to Copy_Bitfield is now enabled. (Expand_Assign_Array_Bitfield): Multiply 'Length times 'Component_Size "by hand" instead of using 'Size. From-SVN: r275855 --- gcc/ada/ChangeLog | 7 +++++++ gcc/ada/exp_ch5.adb | 22 ++++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 752a9fd8f24..561f6a845f2 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2019-09-18 Bob Duff + + * exp_ch5.adb (Expand_Assign_Array_Loop_Or_Bitfield): The call + to Copy_Bitfield is now enabled. + (Expand_Assign_Array_Bitfield): Multiply 'Length times + 'Component_Size "by hand" instead of using 'Size. + 2019-09-18 Vasiliy Fofanov * doc/gnat_rm/implementation_defined_pragmas.rst: Fix minor diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb index 76e97fc9e18..f5c1f211cb5 100644 --- a/gcc/ada/exp_ch5.adb +++ b/gcc/ada/exp_ch5.adb @@ -1411,12 +1411,21 @@ package body Exp_Ch5 is -- Compute the Size of the bitfield -- Note that the length check has already been done, so we can use the - -- size of either L or R. + -- size of either L or R; they are equal. We can't use 'Size here, + -- because sometimes bit fields get copied into a temp, and the 'Size + -- ends up being the size of the temp (e.g. an 8-bit temp containing + -- a 4-bit bit field). Size : constant Node_Id := - Make_Attribute_Reference (Loc, - Prefix => Duplicate_Subexpr (Name (N), True), - Attribute_Name => Name_Size); + Make_Op_Multiply (Loc, + Make_Attribute_Reference (Loc, + Prefix => + Duplicate_Subexpr (Name (N), True), + Attribute_Name => Name_Length), + Make_Attribute_Reference (Loc, + Prefix => + Duplicate_Subexpr (Name (N), True), + Attribute_Name => Name_Component_Size)); begin return Make_Procedure_Call_Statement (Loc, @@ -1466,10 +1475,7 @@ package body Exp_Ch5 is -- optimization in that case as well. We could complicate this code by -- actually looking for such volatile and independent components. - -- Note that Expand_Assign_Array_Bitfield is disabled for now. - - if False and then -- ??? - RTE_Available (RE_Copy_Bitfield) + if RTE_Available (RE_Copy_Bitfield) and then Is_Bit_Packed_Array (L_Type) and then Is_Bit_Packed_Array (R_Type) and then not Reverse_Storage_Order (L_Type) -- 2.30.2