[llvm-bugs] [Bug 51340] Wrong code generated for x86 inline assembly
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Nov 3 13:37:34 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=51340
Paul Gofman <pgofman at codeweavers.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|FIXED |---
--- Comment #2 from Paul Gofman <pgofman at codeweavers.com> ---
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211103/450f83bf/attachment.html>
More information about the llvm-bugs
mailing list