[Ada] Optimize generation of checks for fixed-point types
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 2 Nov 2020 21:54:01 +0000 (22:54 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Fri, 27 Nov 2020 09:15:47 +0000 (04:15 -0500)
commit84c54629c2fb6dae0e7d97a2c57e894899f2b944
treedde824100727d455c32afe4c3f0770b46f2b02ab
parent2d1504186ee9d83fbc93f4b6880d55dcdd8daaff
[Ada] Optimize generation of checks for fixed-point types

gcc/ada/

* checks.ads (Determine_Range_To_Discrete): New procedure.
* checks.adb (Apply_Scalar_Range_Check): Call it to determine
a range for the expression when the target type is discrete.
And also apply the tests for discrete types to fixed-point
types when they are treated as integers.
(Apply_Type_Conversion_Checks): Apply checks to conversions
involving fixed-point types when they are treated as integers.
(Determine_Range) <N_Type_Conversion>: Factor out code into...
(Determine_Range_To_Discrete): ...this new procedure and add
support for fixed-point types when they are treated as integers.
* einfo.ads (Type_High_Bound): Remove obsolete sentence.
(Type_Low_Bound): Likewise.
* exp_ch4.adb (Discrete_Range_Check): Remove obsolete code.
(Real_Range_Check): Likewise.
(Expand_N_Type_Conversion): In case of a no-op conversion, clear
the Do_Range_Check flag on the operand before substituting it.
Remove calls to Real_Range_Check and Discrete_Range_Check that
are not guarded by the Do_Range_Check flag, and an assertion.
* sem_res.adb (Resolve_Type_Conversion): Always apply range
checks in GNATprove mode; in normal mode, use the updated type
of the operand in the test against Universal_Fixed.  Remove
obsolete code setting the Do_Range_Check flag at the end.
gcc/ada/checks.adb
gcc/ada/checks.ads
gcc/ada/einfo.ads
gcc/ada/exp_ch4.adb
gcc/ada/sem_res.adb