This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Infinite number of iterations in loop [v850, mep]
- From: "Paulo Matos" <pmatos at broadcom dot com>
- To: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Wed, 13 Nov 2013 15:48:09 +0000
- Subject: Infinite number of iterations in loop [v850, mep]
- Authentication-results: sourceware.org; auth=none
Hi,
I am seeing a strange phenomenon on GCC 4.8 which I can't understand. I tested this with v850 and mep, obtaining the same results (compiling with -O2).
With loop-1.c:
extern int *c;
void fn1 (unsigned int b)
{
unsigned int a;
for (a = 0; a < b; a++)
*c++ = 0;
}
both v850 (requires -mloop and -mv850e3v5) and mep generate a doloop_end pattern.
For loop-2.c:
extern int *c;
extern unsigned int b;
void fn1 (void)
{
unsigned int a;
for (a = 0; a < b; a++)
*c++ = 0;
}
None of v850 nor mep generate doloop_end pattern. doloop complains loop is not simple and may have infinite iterations:
Loop 1 is not simple.
Doloop: Possible infinite iteration case.
Doloop: The loop is not suitable.
I cannot understand GCC's reasoning that the second loop is not simple. The only source code difference is that unsigned int b is extern. However, it will always be higher than 'a' (unsigned int) and the loop can't possibly be infinite.
Does anybody know why GCC is behaving this way?
Paulo Matos