<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 uses adcx rather then adc when "arch=skylake""
href="https://bugs.llvm.org/show_bug.cgi?id=38852">38852</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang uses adcx rather then adc when "arch=skylake"
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</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>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>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ilya.lesokhin@gmail.com
</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=20847" name="attach_20847" title="source file">attachment 20847</a> <a href="attachment.cgi?id=20847&action=edit" title="source file">[details]</a></span>
source file
clang uses adcx rather then adc when "arch=skylake"
This seems to be a bad idea for two reasons.
1. adcx is bigger then adc.
2. adcx doesn't update the sign flag which might result in worst code.
Just using -mbmi2, to enable adcx support, doesn't trigger the issue.
See for example:
<a href="https://godbolt.org/z/Yt32d9">https://godbolt.org/z/Yt32d9</a>
Source:
#include <stdint.h>
__int128 good(__int128 a, __int128 b) {
b = a + b;
return b < 0 ? a : b;
}
__int128 __attribute__ ((__target__ ("arch=skylake"))) bad(__int128 a, __int128
b) {
b = a + b;
return b < 0 ? a : b;
}
Output:
good(__int128, __int128): # @good(__int128, __int128)
add rdx, rdi
adc rcx, rsi
cmovs rdx, rdi
cmovs rcx, rsi
mov rax, rdx
mov rdx, rcx
ret
bad(__int128, __int128): # @bad(__int128, __int128)
add rdx, rdi
adcx rcx, rsi
test rcx, rcx
cmovs rdx, rdi
cmovs rcx, rsi
mov rax, rdx
mov rdx, rcx
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>