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