This gets rid of overflow checks done using a 128-bit integer type on 64-bit platforms and that can be done in a narrower type, by reusing the machinery already implemented to narrow the type of operations. This runs afoul of the processing for Max_Size_In_Storage_Elements in Expand_N_Attribute_Reference, which attempts to second guess the expansion of checks done in universal integer contexts, so this code is simply removed, as it does not seem to serve any real purpose. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_attr.adb (Expand_N_Attribute_Reference) : Apply the checks for universal integer contexts only in the default case. * exp_ch4.adb (Get_Size_For_Range): Move to library level. (Expand_N_Type_Conversion): If the operand has Universal_Integer type and the conversion requires an overflow check, try to do an intermediate conversion to a narrower type.