You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Vector128<double>.ToScalar() produces expected code (vmovsd) -- no issue there.
Same CQ issue for int, and for Vector256<T>.
Didn't check other types, than noted here.
Activity
gfoidl commentedon May 22, 2019
/cc: @tannergooding please have a look here
fiigii commentedon May 22, 2019
I remember that
ToScalaron integer types are not intrinsic now. You can useSse2.X64.ConvertToInt64forVector128<long>.gfoidl commentedon May 22, 2019
Thanks.
Is better, but still not ideal:
It is documented as
__int64 _mm_cvtsi128_si64 (__m128i a) MOVQ reg/m64, xmm, but JIT didn't emit themovq.mikedn commentedon May 22, 2019
Is that output from the JIT's own disassembler? It's probably
movqbut displayed asmovd.gfoidl commentedon May 22, 2019
Looked at the JIT-dump and in VS-dissambly view (both in release with optimization on, tiering disabled).
SharpLab with CoreCLR shows the same.
fiigii commentedon May 22, 2019
Right,
vmovd rax, xmm0is actuallyvmovq rax, xmm0.movdis an alias ofmovqon r64.fiigii commentedon May 22, 2019
BTW, in this link,
vzeroupperis generated for Vector128 code. That should not be there, I will take a look.gfoidl commentedon May 22, 2019
👍
So codegen could be
or
There is the extra
vmovupd(see https://github.com/dotnet/coreclr/issues/24710#issuecomment-494720476)Thanks.
My code to show this
dasm for that code
gfoidl commentedon May 22, 2019
Isn't this needed for VEX? No matter if Vector128 or Vector256.
fiigii commentedon May 22, 2019
It is a bit complex, please see https://github.com/dotnet/coreclr/issues/21062.
But I am sure that codegen has something wrong.
AndyAyersMS commentedon May 22, 2019
Marking as future; if there's something surgical we can fix, or there's a bug, we can move to 3.0.
omariom commentedon May 24, 2019
It might be related.
xmm0is spilled to the stack.gfoidl commentedon Mar 11, 2020
@omariom for reference: this is tracked by #11413 (thx @EgorBo for the remainder).
hypeartist commentedon Apr 20, 2020
@omariom What about this?
Asm output:
https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AXEBDAzgWwB8ABAJgEYBYAKGIAYACY8gOgCUBXAOwwEt8YLAMIR8AB14AbGFADKMgG68wMXAG4aNbrmwAzGE1IMhDGgG8aDKwzFReC7BgPMkDSRC4BzBgEFcAGQ9PAApeLgYAEwgOYGlI2IBKS2sLamt0pgB2BgAqYPcvHISAVS4dfRY/AAUIMKcoYNhdBlLywT82GF1giMSEjTTrAF9TaiGgA
gfoidl commentedon Apr 20, 2020
@hypeartist this uses also the stack
[rcx]and doesn't operate with registers solely.AndyAyersMS commentedon Jun 13, 2026
Note
This comment was generated with Copilot CLI assistance.
This now produces optimal codegen on current main. Closing as fixed.
Repro:
Current codegen (x64, AVX):
(The implicit-byref ABI passes a pointer to the vector, so the JIT now folds straight to a scalar load — no spill round-trip.)