[llvm-bugs] [Bug 24590] New: clang-cl generates wrong addressing mode for table lookup.

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 26 11:50:29 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=24590

            Bug ID: 24590
           Summary: clang-cl generates wrong addressing mode for table
                    lookup.
           Product: tools
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: llvmc
          Assignee: unassignedbugs at nondot.org
          Reporter: fbarchard at google.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 14781
  --> https://llvm.org/bugs/attachment.cgi?id=14781&action=edit
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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150826/80c98c58/attachment-0001.html>


More information about the llvm-bugs mailing list