diff mbox series

[Ada] Small tweak to Narrow_Large_Operation procedure

Message ID 20200708145733.GA27407@adacore.com
State New
Headers show
Series [Ada] Small tweak to Narrow_Large_Operation procedure | expand

Commit Message

Pierre-Marie de Rodat July 8, 2020, 2:57 p.m. UTC
This recently introduced procedure is responsible for narrowing the
type of operations done originally in Universal_Integer, rewriting
them into operations done in Integer or Long_Long_Integer.

This changes the procedure to use the base type instead of the first
subtype for these two integer types, which avoids the need for useless
conversions between the base type and the first subtype.

No functional changes.

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

gcc/ada/

	* exp_ch4.adb (Narrow_Large_Operation): Use the base type instead
	of the first subtype of standard integer types as narrower type.
diff mbox series

Patch

diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -14067,13 +14067,15 @@  package body Exp_Ch4 is
          return;
       end if;
 
-      --  Now pick the narrower type according to the size
+      --  Now pick the narrower type according to the size. We use the base
+      --  type instead of the first subtype because operations are done in
+      --  the base type, so this avoids the need for useless conversions.
 
       if Nsiz <= RM_Size (Standard_Integer) then
-         Ntyp := Standard_Integer;
+         Ntyp := Etype (Standard_Integer);
 
       elsif Nsiz <= RM_Size (Standard_Long_Long_Integer) then
-         Ntyp := Standard_Long_Long_Integer;
+         Ntyp := Etype (Standard_Long_Long_Integer);
 
       else
          return;