<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 - Wrong register in result asm when using inline asm with movups"
href="https://bugs.llvm.org/show_bug.cgi?id=33785">33785</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Wrong register in result asm when using inline asm with movups
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>enhancement
</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>ilia.taraban@intel.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>==================== copy-asm.c =================
#include <stdio.h>
#define N 2
float __declspec(align(64)) farray[4 * N];
float __declspec(align(64)) fdest[4 * N];
void copy_from_arr_to_dest()
{
long long int i;
for (i = 0; i < sizeof(farray); i += 4) {
__asm {
mov rax, i
movups xmm1, [farray+rax]
movups [fdest+rax], xmm1
}
}
}
int
main()
{
int i;
for (i = 0; i < 4 * N; ++i) {
farray[i] = (float)i;
}
copy_from_arr_to_dest();
//check second pack of floats
if (fdest[4] != farray[4]) {
printf("FAILED\n");
return 1;
}
printf("PASSED!\n");
return 0;
}
====================================================
<span class="quote">>>> clang -v</span >
clang version 5.0.0 (cfe/trunk 307600)
...
<span class="quote">>>> clang -o copy-asm.exe copy-asm.c -fms-extensions
>>> ./copy-asm.exe</span >
FAILED
=============== generated-assembler =================
...
movq -8(%rbp), %rax # mov rax, i
movups farray(%rip), %xmm1 # movups xmm1, [farray+rax]
movups %xmm1, fdest(%rip) # movups [fdest+rax], xmm1
...
=====================================================
Now, if we change rip to rax(which we use in inline asm block):
=============== new-assembler =================
...
movq -8(%rbp), %rax # mov rax, i
movups farray(%rax), %xmm1 # movups xmm1, [farray+rax]
movups %xmm1, fdest(%rax) # movups [fdest+rax], xmm1
...
=====================================================
<span class="quote">>>> clang -o fixed-copy-asm.exe fixed-copy-asm.s
>>> ./fixed-copy-asm.exe</span >
PASSED!
Same problem with movaps, movdqa32, movdqu32
------------------------
Intel Software Engineer
Ilia Taraban</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>