<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - llvm does not narrow overly-wide memcpys with !tbaa.struct metadata"
   href="https://bugs.llvm.org/show_bug.cgi?id=37023">37023</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>llvm does not narrow overly-wide memcpys with !tbaa.struct metadata
          </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>Linux
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Common Code Generator Code
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>richard-llvm@metafoo.co.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Testcase:

struct alignas(256) X { int n; };
X f(X x) { return x; }

Clang generates:

%struct.X = type { i32, [252 x i8] }

define dso_local void @_Z1f1X(%struct.X* noalias nocapture sret %agg.result,
%struct.X* byval nocapture readonly align 256 %x) local_unnamed_addr #0 {
entry:
  %0 = bitcast %struct.X* %agg.result to i8*
  %1 = bitcast %struct.X* %x to i8*
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 256 %0, i8* nonnull align 256
%1, i64 256, i1 false), !tbaa.struct !2
  ret void
}

declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture
readonly, i64, i1) #1

attributes #0 = { nounwind uwtable
"correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false"
"less-precise-fpmad"="false" "no-frame-pointer-elim"="false"
"no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false"
"no-signed-zeros-fp-math"="false" "no-trapping-math"="false"
"stack-protector-buffer-size"="8" "target-cpu"="x86-64"
"target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false"
"use-soft-float"="false" }
attributes #1 = { argmemonly nounwind }

and (eg) the x86 backend then produces a 256-byte memcpy. This cannot be the
fastest way of copying 4 bytes with 252 bytes of padding :)</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>