This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
no Loop Invariant Motion?
- From: prashant rawat <prashant dot rawat86 at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Sun, 3 Jan 2010 11:24:21 +0530
- Subject: no Loop Invariant Motion?
- References: <9654bc4f1001020202w142c02e2qef871115ac8d35db@mail.gmail.com>
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
Can anyone explain what went wrong?
--
With Regards,
Prashant SIngh Rawat
MTech, CSE, IIT Bombay