This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

optimization/8776: loop invariants are not removed (most likely)


>Number:         8776
>Category:       optimization
>Synopsis:       loop invariants are not removed (most likely)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          pessimizes-code
>Submitter-Id:   net
>Arrival-Date:   Sun Dec 01 15:26:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     lomov1@yahoo.com
>Release:        gcc version 3.2 (Mandrake Linux 9.0 3.2-1mdk); also with gcc-3.1
>Organization:
>Environment:
Linux 2.4.19-16mdk i686 GNU/Linux
Mandrake 9.0
AMD Athlon(tm) Processor stepping 2 cpu MHz 908.111
>Description:
There is a following program:
------
struct str{
   int f[3];
};

int main (int argc, char *argv[])
{
   double d[1];
   double* pd=d;
   str s;
   int* pf=&s.f[0];
   s.f[0]=s.f[1]=s.f[2]=0;
   for (int i=0;i<1000000000;++i) {
#ifdef SLOW1
      pd[s.f[0]+s.f[1]*s.f[2]]=1;
#elif defined(SLOW2)
      d[pf[0]+pf[1]*pf[2]]=1;
#else
      pd[pf[0]+pf[1]*pf[2]]=1;
#endif
   }
}
------
after compilation with gcc-3.2 -O9 on Linux Mandrake 9.0 Athlon 900MHz,

time ./a.out of the SLOW[12] version gives >10s
time ./a.out of the "!defined(SLOW[12])" version gives 3.50s

Logically this is the same thing... 
>How-To-Repeat:
gcc -O9 test.cpp ; time ./a.out
gcc -O9 -DSLOW1 test.cpp ; time ./a.out
gcc -O9 -DSLOW2 test.cpp ; time ./a.out
>Fix:
gcc-2.96 doesn't have this problem. Sorry, but I don't have access to other official (besides 3.1 and 3.2) releases
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="test.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="test.cpp"

aW50IG1haW4gKGludCBhcmdjLCBjaGFyICphcmd2W10pCnsKICAgZG91YmxlIGRbMV07CiAgIGRv
dWJsZSogcGQ9ZDsKICAgc3RyIHM7CiAgIGludCogcGY9JnMuZlswXTsKICAgcy5mWzBdPXMuZlsx
XT1zLmZbMl09MDsKICAgZm9yIChpbnQgaT0wO2k8MTAwMDAwMDAwMDsrK2kpIHsKI2lmZGVmIFNM
T1cxCiAgICAgIHBkW3MuZlswXStzLmZbMV0qcy5mWzJdXT0xOwojZWxpZiBkZWZpbmVkKFNMT1cy
KQogICAgICBkW3BmWzBdK3BmWzFdKnBmWzJdXT0xOwojZWxzZQogICAgICBwZFtwZlswXStwZlsx
XSpwZlsyXV09MTsKI2VuZGlmCiAgIH0KfQoK


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]