Go to file
Eric Botcazou 4e896dad49 [Ada] Eliminate redundant range checks on conversions
This gets rid of redundant range checks generated in 5 out of the 9
cases of scalar conversions, i.e. (integer, fixed-point, floating-point)
converted to (integer, fixed-point, floating-point).

The problem is that the Real_Range_Check routine rewrites the conversion
node into a conversion to the base type so, when its parent node is
analyzed, a new conversion to the subtype may be introduced, depending
on the context, giving rise to a second range check against the subtype
bounds.

This change makes Real_Range_Check rewrite the expression of the
conversion node instead of the node, so that the type of the node is
preserved and no new conversion is introduced.  As a matter of fact,
this is exactly what happens in the float-to-float case which goes to
the Generate_Range_Check circuit instead and does not suffer from the
duplication of range checks.

For the following procedure, the compiler must now generate exactly one
range check per nested function:

procedure P is

  type I1 is new Integer range -100 .. 100;

  type I2 is new Integer range -200 .. 200;

  type D1 is delta 0.5 range -100.0 .. 100.0;

  type D2 is delta 0.5 range -200.0 .. 200.0;

  type F1 is new Long_Float range -100.0 .. 100.0;

  type F2 is new Long_Float range -200.0 .. 200.0;

  function Conv (A : I2) return I1 is
  begin
    return I1 (A);
  end;

  function Conv (A : D2) return I1 is
  begin
    return I1 (A);
  end;

  function Conv (A : F2) return I1 is
  begin
    return I1 (A);
  end;

  function Conv (A : I2) return D1 is
  begin
    return D1 (A);
  end;

  function Conv (A : D2) return D1 is
  begin
    return D1 (A);
  end;

  function Conv (A : F2) return D1 is
  begin
    return D1 (A);
  end;

  function Conv (A : I2) return F1 is
  begin
    return F1 (A);
  end;

  function Conv (A : D2) return F1 is
  begin
    return F1 (A);
  end;

  function Conv (A : F2) return F1 is
  begin
    return F1 (A);
  end;

begin
  null;
end;

2019-08-12  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

	* exp_ch4.adb (Real_Range_Check): Do not rewrite the conversion
	node but its expression instead, after having fetched its
	current value.  Clear the Do_Range_Check flag on entry.  Return
	early for a rewritten float-to-float conversion.  Remove
	redundant local variable.  Suppress all checks when inserting
	the temporary and do not reanalyze the node.

From-SVN: r274287
2019-08-12 08:59:28 +00:00
config
contrib
fixincludes
gcc [Ada] Eliminate redundant range checks on conversions 2019-08-12 08:59:28 +00:00
gnattools
gotools
include Fix file descriptor existence of MinGW. 2019-08-08 07:50:28 +00:00
INSTALL
intl
libada
libatomic
libbacktrace
libcc1 [C++ PATCH] Using decls 2019-05-21 14:33:24 +00:00
libcpp * zh_TW.po: Update. 2019-08-09 23:02:08 +01:00
libdecnumber
libffi
libgcc config.gcc (hppa*-*-netbsd*): New target. 2019-07-31 14:11:16 +00:00
libgfortran PR 53796 Make inquire(file=, recl=) conform to F2018 2019-08-07 10:34:10 +03:00
libgo runtime: expose the g variable 2019-07-15 21:17:16 +00:00
libgomp gimplify.c (omp_add_variable): Use GOVD_PRIVATE | GOVD_EXPLICIT for VLA helper variables on target data even if... 2019-08-08 08:39:02 +02:00
libhsail-rt
libiberty Move is_valid_fd to filedescriptor.c file. 2019-08-12 07:36:48 +00:00
libitm
libobjc
liboffloadmic
libphobos
libquadmath quadmath.h (M_Eq, [...]): Use two more decimal places. 2019-08-02 09:59:19 +02:00
libsanitizer
libssp
libstdc++-v3 skip Cholesky decomposition in is>>n_mv_dist 2019-08-09 09:20:58 +00:00
libvtv
lto-plugin
maintainer-scripts update_web_docs_svn: Proceed even if the invocation of sphinx fails. 2019-08-04 22:31:54 +00:00
zlib
.dir-locals.el
.gitattributes add basic .gitattributes files to notice whitespace issues 2016-04-23 02:37:43 +00:00
.gitignore
ABOUT-NLS
ar-lib
ChangeLog
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in
config.guess
config.rpath
config.sub
configure
configure.ac
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.RUNTIME
depcomp
install-sh
libtool-ldflags
libtool.m4
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS
Makefile.def
Makefile.in
Makefile.tpl
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
symlink-tree
test-driver
ylwrap

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.