aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2019-09-18 08:32:51 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-09-18 08:32:51 +0000
commit0af16535246ef8a9a814da6a3ae7a5bcae89dc30 (patch)
tree6ac47113e2f600748107d7998842aa37d6447279 /gcc/ada
parenta6d677c65b999fd44446592cde9282b65772095a (diff)
downloadgcc-0af16535246ef8a9a814da6a3ae7a5bcae89dc30.zip
gcc-0af16535246ef8a9a814da6a3ae7a5bcae89dc30.tar.gz
gcc-0af16535246ef8a9a814da6a3ae7a5bcae89dc30.tar.bz2
[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
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog7
-rw-r--r--gcc/ada/exp_ch5.adb22
2 files changed, 21 insertions, 8 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 752a9fd..561f6a8 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,10 @@
+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>
* doc/gnat_rm/implementation_defined_pragmas.rst: Fix minor
diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb
index 76e97fc..f5c1f21 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)