<html>
<head>
<base href="http://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 --- - Inline assembly MMX register bugs"
href="http://llvm.org/bugs/show_bug.cgi?id=22022">22022</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Inline assembly MMX register bugs
</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>Linux
</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>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>adam@consulting.net.nz
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Thanks for a great compiler that is steadily improving!
Inline assembly with MMX registers is fragile. It's unusual to use MMX
registers so I'm likely exercising previously untested code paths.
Here are a couple of examples that fail:
//Example 1
#include <stdint.h>
#include <stdio.h>
typedef uint8_t mmx_t __attribute__ ((vector_size (8)));
int main(void) {
register mmx_t mmx asm ("mm0");
asm volatile ("" : "+y" (mmx));
printf("%d\n", mmx[0]);
return 0;
}
$ clang-3.6 --version
Debian clang version 3.6.0-svn224681-1~exp1 (trunk) (based on LLVM 3.6.0)
Target: x86_64-pc-linux-gnu
Thread model: posix
(approx. 20 December 2014 snapshot)
$ clang-3.6 -O3 clang-u8x8-mmx-bug.c
clang-u8x8-mmx-bug.c:8:17: error: non-trivial scalar-to-vector conversion,
possible invalid constraint for vector type
asm volatile ("" : "+y" (mmx));
^
1 error generated.
Note: y is the machine constraint for any MMX register:
<<a href="https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html">https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html</a>>
//Example 2 (MMX register is now defined as one 64 bit value)
#include <stdint.h>
#include <stdio.h>
typedef uint64_t mmx_t __attribute__ ((vector_size (8)));
int main(void) {
register mmx_t mmx asm ("mm0");
asm volatile ("" : "+y" (mmx));
printf("%ld\n", mmx[0]);
return 0;
}
$ clang-3.6 -O3 clang-u64-mmx-bug.c
fatal error: error in backend: Cannot select: 0x2138870: i64 = truncate
0x2138760 [ORD=2] [ID=27]
0x2138760: x86mmx,ch,glue = CopyFromReg 0x2138650, 0x2137ee0, 0x2138650:1
[ORD=2] [ID=25]
0x2137ee0: x86mmx = Register %MM0 [ID=5]
0x2138650: ch,glue = inlineasm 0x2138210, 0x2137aa0, 0x2137bb0, 0x2137cc0,
0x2137dd0, 0x2137ee0, 0x2138320, 0x2138100, 0x2138430, 0x2138540, 0x2138210:1
[ORD=2] [ID=24]
0x2137aa0: i64 = TargetExternalSymbol'' [ID=1]
0x2137cc0: i64 = TargetConstant<1> [ID=3]
0x2137dd0: i32 = TargetConstant<10> [ID=4]
0x2137ee0: x86mmx = Register %MM0 [ID=5]
0x2138320: i32 = TargetConstant<-2147483639> [ID=8]
0x2138100: x86mmx = Register %vreg0 [ID=7]
0x2138430: i32 = TargetConstant<12> [ID=9]
0x2138540: i32 = Register %EFLAGS [ID=10]
0x2138210: ch,glue = CopyToReg 0x20ee730, 0x2138100, 0x2137ff0 [ORD=2]
[ID=22]
0x2138100: x86mmx = Register %vreg0 [ID=7]
0x2137ff0: x86mmx = undef [ID=6]
In function: main
clang: error: clang frontend command failed with exit code 70 (use -v to see
invocation)
Debian clang version 3.6.0-svn224681-1~exp1 (trunk) (based on LLVM 3.6.0)
Target: x86_64-pc-linux-gnu
Thread model: posix</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>