Re: no Loop Invariant Motion?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



prashant rawat wrote:
I have a simple C code :

#include<stdio.h>
int *c;
int main ()
{
        int a=0, b;
        while (a < 100)
        {
                        b = 10;
                        a = a + 1;
        }
        c = &b;
        printf ("%d\n", *c);
        return 0;
}

I would basically expect the b = 10 statement to be moved out of the
while loop, as it is an invariant.
However, it does not seem to happen in the *.lim dump file.
I am using gcc 4.4.2 to compile, and the cmd line options are
install/bin/gcc -fdump-tree-all -O3 filename.c

With gcc 4.5, the b assignment is moved out of the loop at -O, and the loop is removed entirely at -O3 or -Os.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux