This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
The Do_Overflow_Check flag was being set on division operators in many cases where it was not needed. Now the flag will be set only if there is a possibility of the (largest neg number) / (-1) case and this only if code is not being generated (-gnatc mode), since if code is generated, the check is explicitly generated. The test program: 1. procedure JunkDCheck 2. (Y : Positive; 3. X, Z : in out Integer) is 4. begin 5. Z := X / Z; 6. X := 10 / Y; 7. end; if compiled with -gnatc -gnatG generates: procedure junkdcheck (y : positive; x : in out integer; z : in out integer) is begin z := x {/} z; x := 10 / y; end junkdcheck; (previously the second assignment had {/} and if compiled with -gnatc -gnatG: procedure junkdcheck (y : positive; x : in out integer; z : in out integer) is begin [constraint_error when z = 0 "divide by zero"] [constraint_error when x = -16#8000_0000# and then z = -1 "overflow check failed"] z := x / z; x := 10 / y; return; end junkdcheck; Tested on x86_64-pc-linux-gnu, committed on trunk 2014-07-31 Robert Dewar <dewar@adacore.com> * checks.adb (Enable_Overflow_Check): More precise setting of Do_Overflow_Check flag for division.
Attachment:
difs
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |