Commit 0af16535 by Bob Duff Committed by Pierre-Marie de Rodat

[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  <duff@adacore.com>

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
parent a6d677c6
2019-09-18 Bob Duff <duff@adacore.com>
* 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 <fofanov@adacore.com> 2019-09-18 Vasiliy Fofanov <fofanov@adacore.com>
* doc/gnat_rm/implementation_defined_pragmas.rst: Fix minor * doc/gnat_rm/implementation_defined_pragmas.rst: Fix minor
......
...@@ -1411,12 +1411,21 @@ package body Exp_Ch5 is ...@@ -1411,12 +1411,21 @@ package body Exp_Ch5 is
-- Compute the Size of the bitfield -- Compute the Size of the bitfield
-- Note that the length check has already been done, so we can use the -- 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 := Size : constant Node_Id :=
Make_Attribute_Reference (Loc, Make_Op_Multiply (Loc,
Prefix => Duplicate_Subexpr (Name (N), True), Make_Attribute_Reference (Loc,
Attribute_Name => Name_Size); 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 begin
return Make_Procedure_Call_Statement (Loc, return Make_Procedure_Call_Statement (Loc,
...@@ -1466,10 +1475,7 @@ package body Exp_Ch5 is ...@@ -1466,10 +1475,7 @@ package body Exp_Ch5 is
-- optimization in that case as well. We could complicate this code by -- optimization in that case as well. We could complicate this code by
-- actually looking for such volatile and independent components. -- actually looking for such volatile and independent components.
-- Note that Expand_Assign_Array_Bitfield is disabled for now. if RTE_Available (RE_Copy_Bitfield)
if False and then -- ???
RTE_Available (RE_Copy_Bitfield)
and then Is_Bit_Packed_Array (L_Type) and then Is_Bit_Packed_Array (L_Type)
and then Is_Bit_Packed_Array (R_Type) and then Is_Bit_Packed_Array (R_Type)
and then not Reverse_Storage_Order (L_Type) and then not Reverse_Storage_Order (L_Type)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment