<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 - clang fails to recognize popcount corresponding as best as possible to detectPopcountIdiom example"
href="https://bugs.llvm.org/show_bug.cgi?id=45480">45480</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang fails to recognize popcount corresponding as best as possible to detectPopcountIdiom example
</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>gabravier@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=23335" name="attach_23335" title="Contains relevant .{S,bc} files from both gcc and clang along with C source code">attachment 23335</a> <a href="attachment.cgi?id=23335&action=edit" title="Contains relevant .{S,bc} files from both gcc and clang along with C source code">[details]</a></span>
Contains relevant .{S,bc} files from both gcc and clang along with C source
code
I found the code at
<a href="https://github.com/llvm-mirror/llvm/blob/2c4ca6832fa6b306ee6a7010bfb80a3f2596f824/lib/Transforms/Scalar/LoopIdiomRecognize.cpp#L1260-L1283">https://github.com/llvm-mirror/llvm/blob/2c4ca6832fa6b306ee6a7010bfb80a3f2596f824/lib/Transforms/Scalar/LoopIdiomRecognize.cpp#L1260-L1283</a>
interesting and wanted to reproduce an example of what LLVM reproduces at the
most very basic level. LLVM, however, fails to optimize such a reproduction to
an `llvm.ctpop` call.
GCC, however, manages to optimize it properly to a `__builtin_popcount` call
internally.
See <a href="https://godbolt.org/z/Sge8tQ">https://godbolt.org/z/Sge8tQ</a> for a direct comparison, I have also added an
attachment archive with relevant source/assembly/bytecode files.</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>