<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 - Clang-cl inefficient assembly, 'inc' not generated"
href="https://bugs.llvm.org/show_bug.cgi?id=37912">37912</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang-cl inefficient assembly, 'inc' not generated
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>6.0
</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>enhancement
</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>jvapen@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Unfortunately, I am unable to share all details for this.
However in investigating why the generated executable by clang-cl is 10% slower
than the one of MSVC, I did notice the following already when comparing the
generated assembly:
MSVC uses specialized inc/dec instructions while clang uses add instructions:
MSVC: incq 0x20(%rbx)
Clang: addq $0x1,(%rcx)
MSVC: inc %rcx
Clang: add $0x1,%rdx
MSVC: dec %eax
Clang: add $0xffffffff,%edi
File was compiled with:
clang-cl.exe -fms-compatibility-version=19.11 /DBOOST_USE_WINDOWS_H
-Weverything -Wno-unused-command-line-argument /nologo /c /W4 /Wall /wd4710
/wd4711 /GR /EHsc /favor:INTEL64 /fp:precise /FS /std:c++17 /Ox /Z7 /MD
/bigobj t.cpp
Note that /favor:INTEL64 ain't recognized by clang, which might be the reason
the inc instruction doesn't get selected.
At the same time, it is remarkable that for most functions, more non-volotile
registers get pushed/popped by clang than by MSVC. In the hot path, I've
noticed 8 pop instructions for clang and 3 for MSVC.</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>