<html>
    <head>
      <base href="http://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 - Bad code generation with cmpxchg16b and __uint128_t"
   href="http://bugs.llvm.org/show_bug.cgi?id=32568">32568</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Bad code generation with cmpxchg16b and __uint128_t
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>4.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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>LLVM Codegen
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>royger@freebsd.org
          </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=18249" name="attach_18249" title="Preprocessed file (-E)">attachment 18249</a> <a href="attachment.cgi?id=18249&action=edit" title="Preprocessed file (-E)">[details]</a></span>
Preprocessed file (-E)

Hello,

clang 3.8 and 4.0 at least seem to generate bad code around a cmpxchg16b asm
instruction that uses __uint128_t. The code is as follows:

ret = cmpxchg16b(entry, &old_ire, new_ire);
ASSERT(ret == old_ire.val);

This leads to clang generating the following asm:

mov    %r15,%rdx
shr    $0x20,%rdx
mov    %r12,%rcx
mov    %r15d,%eax
lock cmpxchg16b (%r14)
xor    %eax,%eax
test   %al,%al

I'm attaching the pre-processed output that causes this. The function where
this happens is update_irte.

The rune used to compile the file is:

clang -m64 -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes
-Wdeclaration-after-statement -Wno-unused-local-typedefs   -O1 -nostdinc
-fno-builtin -fno-common -Werror -Wredundant-decls -Wno-pointer-arith -pipe -g
-D__XEN__ -include /root/xen/xen/include/xen/config.h
'-D__OBJECT_FILE__="intremap.o"' -fno-omit-frame-pointer -MMD -MF
./.intremap.o.d -I/root/xen/xen/include
-I/root/xen/xen/include/asm-x86/mach-generic
-I/root/xen/xen/include/asm-x86/mach-default -DXEN_IMG_OFFSET=0x200000
'-D__OBJECT_LABEL__=drivers$passthrough$vtd$intremap.o' -msoft-float
-fno-stack-protector -fno-exceptions -Wnested-externs -DHAVE_GAS_VMX
-DHAVE_GAS_SSE4_2 -DHAVE_GAS_EPT -DHAVE_GAS_RDRAND -DHAVE_GAS_RDSEED
-mno-red-zone -mno-sse -fpic -fno-asynchronous-unwind-tables
-DGCC_HAS_VISIBILITY_ATTRIBUTE -c intremap.c -o intremap.o

Thanks, Roger.</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>