diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2017-01-21 11:10:00 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2017-01-21 11:10:00 +0000 |
commit | 22564ca91644d357ff2f08e1238abf142c45a807 (patch) | |
tree | e7cfdc9eb13bfe8b6dcd07c62aa6303563ed703d /gcc | |
parent | 51f03c6b11a46d756ae05c67e34cca2ccb4fafaa (diff) | |
download | gcc-22564ca91644d357ff2f08e1238abf142c45a807.zip gcc-22564ca91644d357ff2f08e1238abf142c45a807.tar.gz gcc-22564ca91644d357ff2f08e1238abf142c45a807.tar.bz2 |
sem_eval.adb (Compile_Time_Compare): Reinstate the expr+literal (etc) optimizations when...
* sem_eval.adb (Compile_Time_Compare): Reinstate the expr+literal (etc)
optimizations when the type is modular and the offsets are equal.
From-SVN: r244745
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/ada/sem_eval.adb | 41 |
2 files changed, 27 insertions, 19 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index d2647b1..71927a6 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2017-01-21 Eric Botcazou <ebotcazou@adacore.com> + + * sem_eval.adb (Compile_Time_Compare): Reinstate the expr+literal (etc) + optimizations when the type is modular and the offsets are equal. + 2017-01-20 Thomas Quinot <quinot@adacore.com> * sem_warn.adb (Warn_On_Useless_Assignment): Adjust wording of warning diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb index b421926..0d135cf 100644 --- a/gcc/ada/sem_eval.adb +++ b/gcc/ada/sem_eval.adb @@ -1329,26 +1329,29 @@ package body Sem_Eval is -- J .. J + 1. This code can conclude LT with a difference of 1, -- even if the range of J is not known. - -- This would be wrong for modular types (e.g. X < X + 1 is False if - -- X is the largest number). + declare + Lnode : Node_Id; + Loffs : Uint; + Rnode : Node_Id; + Roffs : Uint; - if not Is_Modular_Integer_Type (Ltyp) - and then not Is_Modular_Integer_Type (Rtyp) - then - declare - Lnode : Node_Id; - Loffs : Uint; - Rnode : Node_Id; - Roffs : Uint; + begin + Compare_Decompose (L, Lnode, Loffs); + Compare_Decompose (R, Rnode, Roffs); - begin - Compare_Decompose (L, Lnode, Loffs); - Compare_Decompose (R, Rnode, Roffs); + if Is_Same_Value (Lnode, Rnode) then + if Loffs = Roffs then + return EQ; + end if; - if Is_Same_Value (Lnode, Rnode) then - if Loffs = Roffs then - return EQ; - elsif Loffs < Roffs then + -- When the offsets are not equal, we can go farther only if + -- the types are not modular (e.g. X < X + 1 is False if X is + -- the largest number). + + if not Is_Modular_Integer_Type (Ltyp) + and then not Is_Modular_Integer_Type (Rtyp) + then + if Loffs < Roffs then Diff.all := Roffs - Loffs; return LT; else @@ -1356,8 +1359,8 @@ package body Sem_Eval is return GT; end if; end if; - end; - end if; + end if; + end; -- Next, try range analysis and see if operand ranges are disjoint |