<html>
<head>
<base href="https://llvm.org/bugs/" />
</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-cl generates wrong addressing mode for table lookup."
href="https://llvm.org/bugs/show_bug.cgi?id=24590">24590</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang-cl generates wrong addressing mode for table lookup.
</td>
</tr>
<tr>
<th>Product</th>
<td>tools
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>llvmc
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>fbarchard@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=14781" name="attach_14781" title="source for test to reproduce table index bug">attachment 14781</a> <a href="attachment.cgi?id=14781&action=edit" title="source for test to reproduce table index bug">[details]</a></span>
source for test to reproduce table index bug
This code generates the wrong code for clang-cl. The indexing is lost.
const int fixed_invtbl8[256] = { 0, };
void f() {
char file[] = "";
__asm movd xmm0, dword ptr [fixed_invtbl8 + eax * 4]
}
Visual C:
cl /c test.c
dumpbin -disasm test.obj
0000000C: 66 0F 6E 04 85 00 movd xmm0,dword ptr _fixed_invtbl8[eax*4]
00 00 00
objdump -d test.obj
c: 66 0f 6e 04 85 00 00 movd 0x0(,%eax,4),%xmm0
13: 00 00
clang-cl /c test.c
dumpbin -disasm test.obj
00000034: 66 0F 6E 05 00 00 movd xmm0,dword ptr [_fixed_invtbl8]
00 00
34: 66 0f 6e 05 00 00 00 movd 0x0,%xmm0
3b: 00
The code will build and run, but produces the wrong result - it uses the first
int from the table.
A work around is to put the table into a register:
const int fixed_invtbl8[256] = { 0, };
void f() {
char file[] = "";
__asm lea ebx, fixed_invtbl8
__asm movd xmm0, dword ptr [ebx + eax * 4]
}
35: 8D 1D 00 00 00 00 lea ebx,[_fixed_invtbl8]
3B: 66 0F 6E 04 83 movd xmm0,dword ptr [ebx+eax*4]
Using clang-cl provided by chromium
third_party\llvm-build\Release+Asserts\bin\clang-cl.exe</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>