This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: Infinite number of iterations in loop [v850, mep]
- From: Paulo Matos <pmatos at broadcom dot com>
- To: Andrew Haley <aph at redhat dot com>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Tue, 7 Jan 2014 15:47:05 +0000
- Subject: RE: Infinite number of iterations in loop [v850, mep]
- Authentication-results: sourceware.org; auth=none
- References: <19EB96622A777C4AB91610E763265F463A757B at SJEXCHMB14 dot corp dot ad dot broadcom dot com> <5283A108 dot 1020108 at redhat dot com> <19EB96622A777C4AB91610E763265F463A761A at SJEXCHMB14 dot corp dot ad dot broadcom dot com>
> -----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