<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 - missed optimizations in memcpy like code"
href="https://bugs.llvm.org/show_bug.cgi?id=39944">39944</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>missed optimizations in memcpy like code
</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>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>trass3r@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre><a href="https://godbolt.org/z/g7OHz3">https://godbolt.org/z/g7OHz3</a>
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!</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>