[Bug c/54743] New: Large loop runs endingless
slbyan at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sat Sep 29 05:44:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54743
Bug #: 54743
Summary: Large loop runs endingless
Classification: Unclassified
Product: gcc
Version: 4.6.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: slbyan@gmail.com
When the loops is 1000000000, the -O3 or -O2 -funroll-loops make the code runs
fast enough(~17sec, on Intel(R) Core(TM)2 Duo CPU E7400 @ 2.80GHz), and when
double the loops (2000000000), the time doubles as expected. However, when
loops is 3000000000, the code runs hours without ending.
The code is:
#include <stdio.h>
static long double vec_a[16] ={
1.0,2.0,3.0,4.0,
11.0,22.0,33.0,44.0,
111.0,222.0,333.0,444.0,
1111.0,2222.0,3333.0,4444.0};
static long double vec_b[16] ={
1.0,2.0,3.0,4.0,
11.0,22.0,33.0,44.0,
111.0,222.0,333.0,444.0,
1111.0,2222.0,3333.0,4444.0};
static long MAX = 3000000000L;
int main(int argc, char** argv) {
long double c = 0.0f;
for (int i=0; i < MAX; ++i)
for (int j=0; j<16;++j)
c += vec_a[j]* vec_a[j];
printf("%llf\n",c);
return 0;
}
More information about the Gcc-bugs
mailing list