ada: Do not unnecessarily use component-wise loop for slice assignment
commit65ea0024063eaa9623c8309edbe22e042325b7ea
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 26 Jun 2023 18:33:53 +0000 (26 20:33 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 4 Jul 2023 08:08:29 +0000 (4 10:08 +0200)
tree425f7f0b07517e2d4f52f377c9066bee8feec7ce
parent2e80be632bfd09987425cb0bdd271659673e1e43
ada: Do not unnecessarily use component-wise loop for slice assignment

This relaxes the condition under which Expand_Assign_Array leaves the
assignment to or from an array slice untouched.  The main prerequisite
for the code generator is that everything be aligned on byte boundaries
and Is_Possibly_Unaligned_Slice is too strong a predicate for this, so
it is replaced by the combination of Possible_Bit_Aligned_Component and
Is_Bit_Packed_Array, modulo a change to Possible_Bit_Aligned_Component
to take into account the specific case of slices.

gcc/ada/

* exp_ch5.adb (Expand_Assign_Array): Adjust comment above the
calls to Possible_Bit_Aligned_Component on the LHS and RHS. Do not
call Is_Possibly_Unaligned_Slice in the slice case.
* exp_util.ads (Component_May_Be_Bit_Aligned): Add For_Slice
boolean parameter.
(Possible_Bit_Aligned_Component): Likewise.
* exp_util.adb (Component_May_Be_Bit_Aligned): Do not return False
for the slice of a small record or bit-packed array component.
(Possible_Bit_Aligned_Component): Pass For_Slice in recursive
calls, except in the slice case where True is passed, as well as
in call to Component_May_Be_Bit_Aligned.
gcc/ada/exp_ch5.adb
gcc/ada/exp_util.adb
gcc/ada/exp_util.ads