[Ada] Optimize length checks generated for slice assignments
2020-06-17 Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* exp_attr.adb (Expand_N_Attribute_Reference) <Attribute_First>:
Replace it with a direct reference to an entity which is not a
discriminant for constrained array types. Add same condition
for scalar types.
<Attribute_Last>: Merge with above implementation.
* exp_ch4.adb (Optimize_Length_Comparison): Be prepared for a
second entity whose length is compared. Rename Prepare_64 to
Convert_To_Long_Long_Integer. If the second entity is present,
compute the difference of the 'First attributes and compare the
sum of 'Last of the second entity with this difference against
'Last of the first entity. Add a special case when the 'First
attributes are equal. Suppress overflow checks in all cases.