[Ada] Simplify detection of others choice with just one value

Message ID 20200716092051.GA146458@adacore.com
State New
Headers show
Series
  • [Ada] Simplify detection of others choice with just one value
Related show

Commit Message

Pierre-Marie de Rodat July 16, 2020, 9:20 a.m.
Trivial cleanup with equality between universal integers, which should
be much faster than subtraction. Semantics is unaffected.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* sem_case.adb (Build_Choice): Simplify.

Patch

diff --git a/gcc/ada/sem_case.adb b/gcc/ada/sem_case.adb
--- a/gcc/ada/sem_case.adb
+++ b/gcc/ada/sem_case.adb
@@ -1012,7 +1012,7 @@  package body Sem_Case is
          --  If there is only one choice value missing between Value1 and
          --  Value2, build an integer or enumeration literal to represent it.
 
-         if (Value2 - Value1) = 0 then
+         if Value1 = Value2 then
             if Is_Integer_Type (Choice_Type) then
                Lit_Node := Make_Integer_Literal (Loc, Value1);
                Set_Etype (Lit_Node, Choice_Type);