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]

[Bug c/49148] New: Certain expressions take an extremely long time for no apparent reason


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49148

           Summary: Certain expressions take an extremely long time for no
                    apparent reason
           Product: gcc
           Version: 4.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jchthys@yahoo.com


Created attachment 24349
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24349
This is a minimal test case of an expression that takes 100 times longer to
evaluate than it should. See comments for explanations.

I have been doing work on 1-D Jacobi stencils. Basically, this involves a lot
of repeated operations. For some reason, however, I have been getting extremely
long run times for certain expressions. What is weird is that if I TAKE OUT a
multiply operation, the function takes about 100 times longer to run than if I
left it in.

The line that causes the problems is marked in the source code. It reads:

     new[i] = (A[i-1] + A[i] + A[i+1]) / 4.0;

If I change this to the following, there is no problem:

     new[i] = (A[i-1] + 2*A[i] + A[i+1]) / 4.0;

As another example, the following line runs slowly:

     new[i] = (A[i-1] + A[i] + A[i+1]) * 0.3;

while this line runs quickly:

     new[i] = (A[i-1] + 2*A[i] + A[i+1]) * 0.333;

The reason I think this is a bug is that it does not happen with older versions
of GCC (for example, 4.1.2), nor with the Intel C Compiler.


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