<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 - x86 code generator uses shld/shrd incorrectly"
href="https://bugs.llvm.org/show_bug.cgi?id=49365">49365</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>x86 code generator uses shld/shrd incorrectly
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>8.0
</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>C
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>appro@cryptogams.org
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=24576" name="attach_24576" title="minimal reproducer code snippet">attachment 24576</a> <a href="attachment.cgi?id=24576&action=edit" title="minimal reproducer code snippet">[details]</a></span>
minimal reproducer code snippet
Hi,
Even though I've clicked on version 8.0 as problematic, the problem was
observed even with clang versions 9, 10, and 11... On a potentially related
note, when the attached snippet is compiled separately, it doesn't matter if I
ask for 32- or 64-bit code. While in real-life application, when the subroutine
is declared static and can be inlined, only the 32-bit build appears to be
affected by the bug. (Well, with exception for clang 11, which did manage to
compile even 32-bit application correctly.)
While the attached reproducer snippet compiles to 'shld' instruction, in the
course of distilling the problem I could observe a similar behaviour even with
'shrd'. Moreover, at some point I even observed the compiler generating correct
code if I removed the last '&(BITS-1)' operation. (Yes, thus subjecting it to
undefined behaviour.)
The underlying problem appears to be that it's assumed that 'shld'/'shrd' would
handle %cl==64 by performing an actual 64-bit shift. I'm not claiming that the
assumption is actually made, only that it appears that way judging from
generated machine code:-)
The rest of the details is in the commentary section of the attached snippet.
Cheers.</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>