[Ada] Optimize generation of checks for fixed-point types
Pierre-Marie de Rodat
Fri Nov 27 09:18:00 GMT 2020
This set of changes aimed at optimizing the generation of range and
overflow checks for fixed-point types contains two parts:
1. a cleanup to the generation of range checks for type conversions
involving fixed-point types, which is now more clearly deferred
entirely to after the expansion of the conversions by Exp_Fixd.
2. a generic improvement to the range computation engine so as to
take into account the underlying integer ranges of fixed point.
The main effect is to get rid of useless overflow checks in some large
integer types generated for multiplication operations by Exp_Fixd.
Tested on x86_64-pc-linux-gnu, committed on trunk
* 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.
* exp_ch4.adb (Discrete_Range_Check): Remove obsolete code.
(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.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 17670 bytes
Desc: not available
More information about the Gcc-patches