This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/46236] New: Local aggregate not eliminated
- From: "davidxl at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 30 Oct 2010 00:37:44 +0000
- Subject: [Bug tree-optimization/46236] New: Local aggregate not eliminated
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46236
Summary: Local aggregate not eliminated
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: davidxl@gcc.gnu.org
CC: xinliangli@gmail.com
Simple Test case:
struct A {
int a[100];
};
const struct A aa = {1,1,1};
int foo(int i)
{
int s = 0;
struct A a;
a = aa;
s = a.a[i];
if (i > 5)
s+=a.a[i];
return s;
}
// Trunk gcc generates: (O2)
foo:
.LFB0:
.cfi_startproc
subq $280, %rsp
.cfi_def_cfa_offset 288
movl %edi, %edx
xorl %eax, %eax
leaq -120(%rsp), %rdi
cmpl $6, %edx
movl $50, %ecx
rep stosq
movl $1, -120(%rsp)
movl $1, -116(%rsp)
movl $1, -112(%rsp)
movslq %edx, %rax
movl -120(%rsp,%rax,4), %eax
leal (%rax,%rax), %ecx
cmovge %ecx, %eax
addq $280, %rsp
.cfi_def_cfa_offset 8
ret
// Trunk LLVM generates: (O2)
foo:
.Leh_func_begin0:
movslq %edi, %rcx
movl aa(,%rcx,4), %eax
cmpl $6, %ecx
jl .LBB0_2
addl %eax, %eax
.LBB0_2:
ret