[Bug tree-optimization/23346] New: [4.1 Regression] FRE before DCE makes a mess of loads or need to sink loads
pinskia at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Fri Aug 12 00:50:00 GMT 2005
Take the following code:
int a, b;
int f(int bool1)
{
int c;
int c1 = a/b;
if(bool1)
c = 0;
else
c = a/b;
return c;
}
On the mainline, we produce (at -O2 -fomit-frame-pointer):
f:
subl $8, %esp
xorl %ecx, %ecx
movl 12(%esp), %eax
movl %ebx, (%esp)
movl b, %edx
movl %esi, 4(%esp)
movl a, %ebx
testl %eax, %eax
jne .L4
movl %ebx, %eax
movl %edx, %esi
cltd
idivl %esi
movl %eax, %ecx
.L4:
movl (%esp), %ebx
movl %ecx, %eax
movl 4(%esp), %esi
addl $8, %esp
ret
Which is just a mess.
in 4.0.0, we produced:
f:
movl 4(%esp), %edx
xorl %eax, %eax
testl %edx, %edx
jne .L4
movl a, %eax
cltd
idivl b
.L4:
ret
There are two ways of fixing this, one way is to sink loads; the other simple way (most likely for 4.1) is
to call dce before fre. I think the reason why the testcase which Steven committed did not catch this is
because sink will sink the divide which is what is only in Steven's testcase.
--
Summary: [4.1 Regression] FRE before DCE makes a mess of loads or
need to sink loads
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P2
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pinskia at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23346
More information about the Gcc-bugs
mailing list