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: Serious performance regression -- some tree optimizer questions


Hello,

> On Wed, Dec 29, 2004 at 09:34:27PM +0100, Toon Moene wrote:
> > [ Serious performance regression in SPEC2000's mgrid*.f* ]
> > 
> > >It is not always constant.
> > >Consider say unsigned int i; on LP64 target and
> > >char A[(long) UINT_MAX + 1];
> > >&A[i+1] - &A[i] is (ptrdiff_t) 1 unless i == UINT_MAX, for which
> > >it is - (ptrdiff_t) UINT_MAX.
> > 
> > Oh, sure, but we are talking Fortran here - you can't apply the 
> > limitations of C to a discussion about optimizing Fortran code.  Fortran 
> > knows of no UINT_MAX, or the intrincacies of C's ptrdiff_t.
> 
> I thought we were talking about middle-end and there is just one middle-end
> used by both Fortran and C.
> My point was just that extra care needs to be taken when handling
> &A[i+1] - &A[i] folding in fold-const.  You can optimize most of these
> even for C, but not all.

we should be able to determine that &A[i+1] - &A[i] == sizeof (A[0]) on
architectures where sizeof (int) == sizeof (void *).  On other
architectures this indeed might be incorrect in general.  Inside loop
optimizer we quite often have enough information to prove correctness of
such a transformation (see can_count_iv_in_wider_type which solves
basically the same problem), but it is kind of hard to find a place for
the simplification that would use it (putting it inside fold does not
seem to be appropriate).

Zdenek


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