<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><span class="vcard"><a class="email" href="mailto:pgofman@codeweavers.com" title="Paul Gofman <pgofman@codeweavers.com>"> <span class="fn">Paul Gofman</span></a>
</span> changed
<a class="bz_bug_link
bz_status_REOPENED "
title="REOPENED - Wrong code generated for x86 inline assembly"
href="https://bugs.llvm.org/show_bug.cgi?id=51340">bug 51340</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">Status</td>
<td>RESOLVED
</td>
<td>REOPENED
</td>
</tr>
<tr>
<td style="text-align:right;">Resolution</td>
<td>FIXED
</td>
<td>---
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_REOPENED "
title="REOPENED - Wrong code generated for x86 inline assembly"
href="https://bugs.llvm.org/show_bug.cgi?id=51340#c2">Comment # 2</a>
on <a class="bz_bug_link
bz_status_REOPENED "
title="REOPENED - Wrong code generated for x86 inline assembly"
href="https://bugs.llvm.org/show_bug.cgi?id=51340">bug 51340</a>
from <span class="vcard"><a class="email" href="mailto:pgofman@codeweavers.com" title="Paul Gofman <pgofman@codeweavers.com>"> <span class="fn">Paul Gofman</span></a>
</span></b>
<pre>I tried with clang 13.0 and while the situation is greatly improved in terms
that it detects registers clobbering now an issue seems to be still there in a
different form.
I modified the round_func() from my sample in the following way so the asm part
is using more registers:
int round_func(float x)
{
FI fi;
static const float negHalf = -0.5f;
__asm
{
push esi
push edi
xor esi,esi
xor edi,edi
xor ecx,ecx
xor edx,edx
movss xmm0,x; // load given value to xmm0
cvtss2si eax,xmm0; // convert it to integer (rounding mode doesn't
matter)
cvtsi2ss xmm1,ecx; // convert back to float
subss xmm1,xmm0; // xmm1 = (rounded - given)
movss xmm0,negHalf; // load -0.5f
cmpless xmm1,xmm0; // get all-ones if (rounded - given) < -0.5f
movss fi.f,xmm1; // get comparison result as integer
sub eax,fi.i; // correct the result of rounding
pop edi
pop esi
}
}
Now it fails to compile with the message:
"error: inline assembly requires more registers than available"
Which is clearly not the case, it is the compiler uses more registers than
available. The fact it preloads the variable address to registers (twice the
same address btw) for asm block looks questionable to me.
Interestingly, the issue is not there if compiling the same with -O1 or -O2.</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>