<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Missed optimization with struct only memcpy'ed"
   href="http://llvm.org/bugs/show_bug.cgi?id=16948">16948</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Missed optimization with struct only memcpy'ed
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>sharparrow1@yahoo.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>chandlerc@gmail.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>