This is the mail archive of the gcc-patches@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: [patch] Lno branch merge part 7 -- tree level invariant motion


On Thu, Jul 08, 2004 at 05:54:10PM +0200, Zdenek Dvorak wrote:
> > This doesn't handle ARRAY_RANGE_REF or VIEW_CONVERT_EXPR.
> 
> because I don't know they exist (they never showed up when I used to
> have default: abort (); clause in the switch).

They're an Ada invention; you wouldn't have yet.

> > or varible stride?
> 
> What's that?

  address = base + (index - min_index) * stride.

Normally stride is constant (e.g. sizeof(int)), or invariant
(e.g. the outer index of a doubly variable sized array[n][n]).

But according to Paul Brook, Fortran needs to use strides that
may be completely variable.  I assume that in practice they'll
tend to be invariant to the inner loop, but not necessarily to
outer loops.

> Sure; I think we just need to fix handling of array_refs in
> tree_could_trap_p and it should be possible to use it, then.

Sure.  I think we'll want to honor TREE_THIS_NOTRAP there as
well.  It'll also give you a place to record non-trapping when
variable indicies are validated against derived loop trip count.

> Anyway, here is the (not fully tested yet) patch reflecting those of the
> changes you suggest I was able to do without further discussion.

> !     case ARRAY_REF:
> !     case ARRAY_RANGE_REF:
> !       base = TREE_OPERAND (expr, 0);
> !       idx = TREE_OPERAND (expr, 1);
> !       if (tree_could_trap_p (base))
> ! 	return true;

Not correct for ARRAY_RANGE_REF.  This is a strange little
operator that renumbers array indicies.

> !       return !in_array_bounds_p (base, idx);

And, really, this formation of in_array_bounds_p isn't going
to be the best idea.  You ought to pass in the entire expression,
because you need to pull the min-index from op2 of the ARRAY_REF.

We can iterate on this later.  The rest of it looks ok.


r~


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