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: Infinite number of iterations in loop [v850, mep]


> -----Original Message-----
> From: gcc-owner@gcc.gnu.org [mailto:gcc-owner@gcc.gnu.org] On Behalf Of Paulo
> Matos
> Sent: 13 November 2013 16:14
> To: Andrew Haley
> Cc: gcc@gcc.gnu.org
> Subject: RE: Infinite number of iterations in loop [v850, mep]
> 
> > -----Original Message-----
> > From: Andrew Haley [mailto:aph@redhat.com]
> > Sent: 13 November 2013 15:56
> > To: Paulo Matos
> > Cc: gcc@gcc.gnu.org
> > Subject: Re: Infinite number of iterations in loop [v850, mep]
> >
> > On 11/13/2013 03:48 PM, Paulo Matos wrote:
> >
> > Because GCC does not know that *c++ = 0; will not overwrite b .  I
> > suppose you could argue that it's not really infinite, because a will
> > eventually equal 0xffffffff, but I think that's what is going on.
> >
> > Andrew.
> >
> 
> 
> I will try to investigate further.
> 

After re-encountering this issue something is amiss. I think this is incorrect.
In the example:
extern int *c;

void fn1 (unsigned int b)
{
  unsigned int a;
  for (a = 0; a < b; a++)
    *c++ = 0;
}

It doesn't make sense to assume *c++ will overwrite b. b is an argument to the function.
The same situation occurs with a coremark function:
void matrix_add_const(ee_u32 N, MATDAT *A, MATDAT val) {
 ee_u32 i,j;
 for (i=0; i<N; i++) {
  for (j=0; j<N; j++) {
   A[i*N+j] += val;
  }
 }
}

It also says the inner loop might be infinite but it can't N is given as argument. j starts as 0, N is unsigned like N. This will loop N times. GCC cannot possibly assume array A will overwrite the value of N in the loop. This seems like something is wrong in alias analysis.

> --
> PMatos

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