[LLVMbugs] [Bug 16948] New: Missed optimization with struct only memcpy'ed
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Aug 20 18:56:38 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=16948
Bug ID: 16948
Summary: Missed optimization with struct only memcpy'ed
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: sharparrow1 at yahoo.com
CC: chandlerc at gmail.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
Given the following (simplified) C++ code:
#include <new>
struct X { void* a; long b; void* c; X() : a(0), b(0) {} };
void f(struct X *a) { X x; new (a) X(x); }
It currently compiles to the following IR:
define void @_Z1fP1X(%struct.X* %a) #0 {
entry:
%x = alloca %struct.X, align 8
%x.0.cast = bitcast %struct.X* %x to i8*
call void @llvm.memset.p0i8.i64(i8* %x.0.cast, i8 0, i64 16, i32 8, i1 false)
%new.isnull = icmp eq %struct.X* %a, null
br i1 %new.isnull, label %new.cont, label %new.notnull
new.notnull: ; preds = %entry
%0 = bitcast %struct.X* %a to i8*
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* %x.0.cast, i64 24, i32 8, i1
false), !tbaa.struct !0
br label %new.cont
new.cont: ; preds = %new.notnull,
%entry
ret void
}
I think SROA should be able to eliminate the alloca and the memcpy; I'm not
sure why it doesn't.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130821/27641fed/attachment.html>
More information about the llvm-bugs
mailing list