<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 /arch:IA32 generates CMOV instructions not supported by selected arch" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23993&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=jed4aJ0zCgkXPhehayEsoeu7rI-VbiIMA9rzxt46LUU&s=Q6akgn19QY7NMwg4kzSQbmoEglr26pyno9oJOrMl6ks&e=">23993</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang-cl /arch:IA32 generates CMOV instructions not supported by selected arch
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.6
</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>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>amadvance@gmail.com
</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>Using clang-cl /arch:IA32 should not generate CMOV instructions that are not
supported by a generic i686.
Visual Studio documentation is clear about that. CMOV instructions should be
generated only with /arch:SSE2.
See: <a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__msdn.microsoft.com_en-2Dus_library_7t5yh4fd.aspx&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=jed4aJ0zCgkXPhehayEsoeu7rI-VbiIMA9rzxt46LUU&s=Q9rI0qSw8_CT0asmAOjP16QcTAA9JmcFBNKVvmhxIZc&e=">https://msdn.microsoft.com/en-us/library/7t5yh4fd.aspx</a>
"In addition to using the SSE and SSE2 instructions, the compiler also uses
other instructions that are present on the processor revisions that support SSE
and SSE2. An example is the CMOV instruction that first appeared on the Pentium
Pro revision of the Intel processors."
The problem seems to be the "-target-cpu pentium4" selection. A "i686" would
work.
A workaround is to add in the command line: -Xclang -target-cpu -Xclang i686
Here an example with clang 3.6.0:
...> type test.c
extern int i;
extern int j;
int f(int g) {
i++;
if (g)
return j;
else
return 1;
}
...> clang-cl -O2 /arch:IA32 -v -c test.c -o test.obj
clang version 3.6.0 (tags/RELEASE_360/final)
Target: i686-pc-windows-msvc
Thread model: posix
"D:\\compiler\\clang-3.6\\bin\\clang-cl.exe" -cc1 -triple i686-pc-windows-msvc
-emit-obj -disable-free -main-file-name
test.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim
-relaxed-aliasing -fmath-errno -masm-verbose -mc
onstructor-aliases -target-cpu pentium4 -D_MT --dependent-lib=libcmt
--dependent-lib=oldnames -fdiagnostics-format msvc
-v -dwarf-column-info -coverage-file
"C:\\Users\\am\\Desktop\\clangtest\\test.c" -resource-dir
"D:\\compiler\\clang-3.6\
\bin\\..\\lib\\clang\\3.6.0" -internal-isystem
"D:\\compiler\\clang-3.6\\bin\\..\\lib\\clang\\3.6.0\\include" -internal-
isystem "d:\\compiler\\msvc71\\vc7\\include" -internal-isystem
"d:\\compiler\\msvc71\\vc7\\atlmfc\\include" -internal-is
ystem "d:\\compiler\\msvc71\\vc7\\PlatformSDK\\include" -O2
-fdebug-compilation-dir "C:\\Users\\am\\Desktop\\clangtest"
-ferror-limit 19 -fmessage-length 120 -mstackrealign -fms-extensions
-fms-compatibility -fms-compatibility-version=17.00
-fdelayed-template-parsing -fobjc-runtime=gcc -fdiagnostics-show-option
-fcolor-diagnostics -vectorize-loops -vectorize
-slp -o test.obj -x c test.c
clang -cc1 version 3.6.0 based upon LLVM 3.6.0 default target
i686-pc-windows-gnu
#include "..." search starts here:
#include <...> search starts here:
D:\compiler\clang-3.6\bin\..\lib\clang\3.6.0\include
d:\compiler\msvc71\vc7\include
d:\compiler\msvc71\vc7\atlmfc\include
d:\compiler\msvc71\vc7\PlatformSDK\include
End of search list.
...> dumpbin /DISASM test.obj
Dump of file test.obj
File Type: COFF OBJECT
_f:
00000000: 55 push ebp
00000001: 89 E5 mov ebp,esp
00000003: FF 05 00 00 00 00 inc dword ptr [_i]
00000009: 83 7D 08 00 cmp dword ptr [ebp+8],0
0000000D: B8 01 00 00 00 mov eax,1
00000012: 0F 45 05 00 00 00 cmovne eax,dword ptr [_j]
00
00000019: 5D pop ebp
0000001A: C3 ret</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>