<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 should not remove branches if not profitable"
href="https://bugs.llvm.org/show_bug.cgi?id=43897">43897</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>LLVM should not remove branches if not profitable
</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>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>david.bolvansky@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>void foo(char **d, char **s, int n, int m) {
for (int i = 0; i < n; ++i) {
if (m == 128) // m is usually 128, hot path
__builtin_memcpy(d[i], s[i], m);
else
__builtin_memcpy(d[i], s[i], m);
}
}
LLVM (Simplify CFG?) removes branch and leaves '__builtin_memcpy(d[i], s[i],
m);'. But here, LLVM was too smart and ignored what I wanted to do - "inlined"
version of memcpy.
If I use:
if (m == 128)
__builtin_memcpy(d[i], s[i], 128);
else
__builtin_memcpy(d[i], s[i], m);
Everything is OK. Simplify CFG should not merge branches if it can propagate
constant from condition to one branch.
<a href="https://godbolt.org/z/GFfPrb">https://godbolt.org/z/GFfPrb</a></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>