[llvm-bugs] [Bug 39944] New: missed optimizations in memcpy like code
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Dec 10 15:35:50 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=39944
Bug ID: 39944
Summary: missed optimizations in memcpy like code
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Common Code Generator Code
Assignee: unassignedbugs at nondot.org
Reporter: trass3r at gmail.com
CC: llvm-bugs at lists.llvm.org
https://godbolt.org/z/g7OHz3
void foo(char* __restrict dst, const char* __restrict buf) {
for (int i=0; i<8; ++i)
*dst++ = *buf++;
}
$ clang -Os -march=haswell
define dso_local void @_Z3fooPcPKc(i8* noalias nocapture, i8* noalias nocapture
readonly) local_unnamed_addr #0 {
br label %3
%4 = phi i64 [ 0, %2 ], [ %10, %3 ]
%5 = getelementptr i8, i8* %1, i64 %4
%6 = getelementptr i8, i8* %0, i64 %4
%7 = bitcast i8* %5 to i64*
%8 = load i64, i64* %7, align 1, !tbaa !2
%9 = bitcast i8* %6 to i64*
store i64 %8, i64* %9, align 1, !tbaa !2
%10 = add i64 %4, 8
%11 = icmp eq i64 %4, 0
br i1 %11, label %12, label %3, !llvm.loop !5
foo(char*, char const*): # @foo(char*, char const*)
xor eax, eax
mov ecx, 8
.LBB0_1:
mov rdx, qword ptr [rsi + rax]
mov qword ptr [rdi + rax], rdx
add rax, 8
cmp rax, rcx
jne .LBB0_1
And with -O2 or -O3 this is unrolled into byte-sized reads!
--
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/20181210/277c5565/attachment.html>
More information about the llvm-bugs
mailing list