[llvm-bugs] [Bug 37023] New: llvm does not narrow overly-wide memcpys with !tbaa.struct metadata

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Apr 5 14:37:36 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37023

            Bug ID: 37023
           Summary: llvm does not narrow overly-wide memcpys with
                    !tbaa.struct metadata
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: richard-llvm at metafoo.co.uk
                CC: llvm-bugs at lists.llvm.org

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 :)

-- 
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/20180405/83c296e0/attachment.html>


More information about the llvm-bugs mailing list