This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c/859: sparc-specific pessimal code for simple loop
- To: gcc-bugs at gcc dot gnu dot org
- Subject: c/859: sparc-specific pessimal code for simple loop
- From: Joe Buck <jbuck at racerx dot synopsys dot com>
- Date: Tue, 21 Nov 2000 13:40:32 -0800 (PST)
See the GNATS case c/859 for details. I was trying to understand the
strange results for the Stepanov abstraction penalty on the Sparc, and
the problem is that we generate very bad code for some simple
fortran-style loops on the Sparc, but the ix86 back end doesn't have
this problem. I originally saw the problem in C++, but it's in C as well.
The problem code is below. We get a rather wasteful 8-instruction inner
loop.
--------------------------
void check(double);
void test0(double* first, double* last)
{
int n, pdiff = last - first;
double result = 0;
for (n = 0; n < pdiff; ++n) result += first[n];
check(result);
}