[Bug tree-optimization/32964] New: union cause ineffient code inside loops
pinskia at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Wed Aug 1 23:11:00 GMT 2007
Testcase:
union A
{
float a;
};
float t(float a)
{
union A a1, a2, a3;
a1.a = a;
for(int i =0;i<100;i++)
{
a2 = a1;
a2.a += a;
a1 = a2;
}
a3 = a1;
return a3.a;
}
--------------
We currently get on powerpc-linux-gnu in the inner loop:
.L2:
stw 0,8(1)
lfs 0,8(1)
fadds 0,1,0
stfs 0,8(1)
lwz 0,8(1)
bdnz .L2
Notice how we are storing and loading from the same address twice in the loop.
That is bad news for the Cell.
This also happens on x86:
.L2:
flds -4(%ebp) <--- load a1.a
addl $1, %eax
fadd %st(1), %st
cmpl $100, %eax
fstps -8(%ebp) <--- store a2.a
movl -8(%ebp), %edx <--- load a2.a
movl %edx, -4(%ebp) <--- store a1.a
jne .L2
--
Summary: union cause ineffient code inside loops
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pinskia at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32964
More information about the Gcc-bugs
mailing list