This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Ada subtypes and base types


On Fri, 2006-03-17 at 12:51 -0700, Jeffrey A Law wrote:
> I'm not suggesting the FEs deduce more types and track ranges;
> that would be rather absurd.  What I'm saying is that exposing
> these types outside the FE is most likely costing you both on
> the compile-time side and on the run-time side.

About optimization, in most languages with array bounds and
range checks, the FE will build a structure with bounds
and code like the following for a typical array loop (sorry
for poor C):

struct {
   int low,high; /* no alias */
   double *data;
} X;

int first_i=X.low+2; 
int last_i=X.high-3;
int i;

if (first_i<=last_i) {
   for(i=first_i;i<=last_i;i++) {
      if (i<X.low||i>X.high) raise_bound_error(); /* CHECK */
      do_something(array_with_bounds[i]);
   }
}

The interesting thing performance wise would be to be able to remove the
CHECK in the BE. 

Is there some optimization pass able to do that?

And when "+2" and "-3" are replaced by "+x" and "-y" and we
know through typing that x>=0 and y>=0?

Laurent


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]