diff options
author | Bob Duff <duff@adacore.com> | 2019-09-17 07:59:11 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-09-17 07:59:11 +0000 |
commit | 38b06e7a19d4002697117965d0bfce7ee77e1d40 (patch) | |
tree | e2a5b8a7959e9641e03242174da27e7a81c1184b /gcc/ada/exp_ch5.adb | |
parent | 8ba9c127cdbc661a4f10fcf977c560e61edc5ca4 (diff) | |
download | gcc-38b06e7a19d4002697117965d0bfce7ee77e1d40.zip gcc-38b06e7a19d4002697117965d0bfce7ee77e1d40.tar.gz gcc-38b06e7a19d4002697117965d0bfce7ee77e1d40.tar.bz2 |
[Ada] Refine conditions for calling Copy_Bitfield
Avoid calling Copy_Bitfield if there are volatile or independent
components that might be read or written. The test is conservative.
2019-09-17 Bob Duff <duff@adacore.com>
gcc/ada/
* exp_ch5.adb (Expand_Assign_Array_Loop_Or_Bitfield): Add tests
for potential volatile or independent components.
* libgnat/s-bituti.adb (Copy_Small_Bitfield,
Copy_Large_Bitfield): Move declarations to more appropriate
place.
From-SVN: r275768
Diffstat (limited to 'gcc/ada/exp_ch5.adb')
-rw-r--r-- | gcc/ada/exp_ch5.adb | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb index ba0b793..6ef3fb2 100644 --- a/gcc/ada/exp_ch5.adb +++ b/gcc/ada/exp_ch5.adb @@ -1451,20 +1451,35 @@ package body Exp_Ch5 is begin -- Determine whether Copy_Bitfield is appropriate (will work, and will -- be more efficient than component-by-component copy). Copy_Bitfield - -- doesn't work for reversed storage orders. It is efficient only for - -- slices of bit-packed arrays. - - -- Note that Expand_Assign_Array_Bitfield is disabled for now - - if False -- ??? + -- doesn't work for reversed storage orders. It is efficient for slices + -- of bit-packed arrays. Copy_Bitfield can read and write bits that are + -- not part of the objects being copied, so we don't want to use it if + -- there are volatile or independent components. If the Prefix of the + -- slice is a selected component (etc, see below), then it might be a + -- component of an object with some other volatile or independent + -- components, so we disable the 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) and then Is_Bit_Packed_Array (L_Type) and then Is_Bit_Packed_Array (R_Type) - and then RTE_Available (RE_Copy_Bitfield) and then not Reverse_Storage_Order (L_Type) and then not Reverse_Storage_Order (R_Type) and then Ndim = 1 and then not Rev and then Slices + and then not Has_Volatile_Component (L_Type) + and then not Has_Volatile_Component (R_Type) + and then not Has_Independent_Components (L_Type) + and then not Has_Independent_Components (R_Type) + and then not Nkind_In (Prefix (Name (N)), + N_Selected_Component, + N_Indexed_Component, + N_Slice) then return Expand_Assign_Array_Bitfield (N, Larray, Rarray, L_Type, R_Type, Rev); |