<html>
<head>
<base href="http://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 - Special-case memcpy() after conditional block"
href="http://bugs.llvm.org/show_bug.cgi?id=32070">32070</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Special-case memcpy() after conditional block
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</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>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>simonhosie77+llvm@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Given:
void f(void *d, void const* s, size_t l, int c) {
if (__builtin_expect(c != 0, 1)) {
l = 0;
}
__builtin_memcpy(d, s, l);
}
Compiling this I get a conditional set-register-to-zero and unconditional call
to memcpy().
Ideally we'd just skip over the call when c != 0. Changing the code to this
makes everything better, but it's not automatic, and in realistic code it's not
something I'd want to do manually:
void f(void *d, void const* s, size_t l, int c) {
if (__builtin_expect(c != 0, 1)) {
l = 0;
__builtin_memcpy(d, s, l);
} else {
__builtin_memcpy(d, s, l);
}
}
Generally, finishing a conditional block with additional optimisation
information might produce a candidate for special-case implementation of the
common code that follows it. For __builtin_memcpy() this would include l being
set to any small constant.</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>