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]

Strange regression in egcs-current/x86


Hello,

There is something strange in the x86 code generated by egcs-current. 

% g++ -v
Reading specs from /pkg/egcs-300698/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.45/specs
gcc version egcs-2.91.45 19980630 (gcc2 ss-980609 experimental)

Given this simple function:

f(int i)
{
	float b[i + 1];

	for (int c = 0; c <= i; c++) { 
		b[c] = sin(c - 1); /* nonsense */ 
	} 
}

g++ -O2 -fomit-frame-pointer -fstrict-aliasingt generates this code:

	[...]
f__Fi:
.LFB1:
        pushl %ebp
.LCFI0:
        movl %esp,%ebp
.LCFI1:
        subl $4,%esp
.LCFI2:
        xorl %edx,%edx
        pushl %ebx
.LCFI3:
        movl 8(%ebp),%ecx
        leal 1(%ecx),%eax        <-------
        sall $5,%eax             <------- shift to the left
	shrl $3,%eax             <------- shift back
        subl %eax,%esp
[...]

g++ 2.7.2 did it with:

[..]
        movl %esp,-8(%ebp)
        leal 4(,%esi,4),%eax
        subl %eax,%esp

I know that often more primitive operations are faster on later x86 CPUs,
but I doubt that first shifting to the left, and the backshifting to the 
right is the fastest way to do it. It seems some patterns got lost or the
combiner has some problems. 

-Andi





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