When dealing with an array with known values, pre will evaluate the first iteration of a loop over the elements. The code generator with then jump into the loop. This is at best increasing the size of the code. It also creates inferior code when the hardware supports zero overhead loops. The attached code demonstrates the difference between an unknown array and a known array. The loop size has been picked large enough for cunrolli to not fully unroll the loop. The problem did not exist in gcc 4.8.


extern int B[27];
int foo()
{
        int i;
        int t=0;
        for(i=0;i<27;i++)
                t+=B[i];
        return t;
}
int boo()
{
        int i;
        int t=0;
        static int A[] = 
{1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9};
        for(i=0;i<27;i++)
                t+=A[i];
        return t;
}

Reply via email to