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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to