From: Geert Bosch <geert@gonzo.sun3.iaf.nl>
Subject: Re: array conversion - how to do?
Date: 1997/07/04
Date: 1997-07-04T00:00:00+00:00 [thread overview]
Message-ID: <5pjkpi$mvk$1@gonzo.sun3.iaf.nl> (raw)
In-Reply-To: dewar.867957369@merv
Geert says
``Now I think about it, it is possible to rather closely model
typecasting for arrays by implementing array conversion as showed
below. It is a pity that this generates lots of code with GNAT
although all code could be eliminated. Are there any compilers
that correctly compile this into a null function?''
Robert Dewar <dewar@merv.cs.nyu.edu> replies:
``If the body of Error is not available, this is not a valid
optimization, and indeed is typical of the kind of invalid
optimizations that optimizing compilers are sometimes known
to do.''
I think you placed my remark about optimization in the wrong context.
Your reply seems to target the loop approach which makes a copy that
cannot trivially be eliminated.
The code for Array_Conversion that I showed uses Unchecked_Conversion
from one constrained array to another. All checks can be eliminated,
so Unchecked_Conversion can just provide a different view of the
array which is the goal I want to achieve. I'll quote some references
to support my claim that the code can be optimized to null.
Regards,
Geert
RM95 13.9 /Implementation permissions/
(12) An implementation may return the result of an unchecked
conversion by reference, if the Source type is not
a by-copy type. In this case, the result of the unchecked
conversion represents simply a different (read-only) view
of the operand of the conversion.
RM95 13.9 /Implementation Advice/
(14) The Size of an array object should not include its bounds;
hence, the bounds should not be part of the converted data.
(15) The implementation should not generate unnecessary run-time
checks to ensure that the representation of S is a
representation of the target type. It should take advantage
of the permission to return by reference when possible.
Restrictions on unchecked conversions should be avoided
unless required by the target environment.
next prev parent reply other threads:[~1997-07-04 0:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-06-24 0:00 array conversion - how to do? Geert Bosch
1997-06-27 0:00 ` Wes Groleau
1997-06-27 0:00 ` Robert Dewar
1997-06-28 0:00 ` Geert Bosch
1997-07-03 0:00 ` Robert Dewar
1997-07-04 0:00 ` Geert Bosch
1997-07-04 0:00 ` Geert Bosch [this message]
1997-07-04 0:00 ` Robert Dewar
1997-06-28 0:00 ` Robert I. Eachus
1997-06-28 0:00 ` Geert Bosch
1997-06-30 0:00 ` Robert I. Eachus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox