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
{{ message }}
Repository navigation
Struct copy using movs rather than SSE on x64 #7469
So movs is used when the struct contains reference fields, it complements CORINFO_HELP_ASSIGN_BYREF which uses rsi and rdi just like movs does.
The use of movs may be worth investigation, it doesn't have a good reputation performance wise. For example, on Skylake movs requires 5 uops instead of 1 or 2 needed by movdqu. That said, its association with helper calls and memory accesses might mean that the overhead is too small to matter.
Some quick testing seems to indicate that when vmovdqu is used the code is ~1.5x faster. It would seem that movs is indeed very slow, especially considering that the test code includes 2 calls.
Activity
mikedn commentedon Feb 19, 2017
To be clear the entire copy code looks like this:
If there's no reference field then the generated code is:
If there's no reference field and another
intfield is added so the struct has 16 bytes then we get this:If instead of a reference field we use a
longfield then we get this:So
movsis used when the struct contains reference fields, it complementsCORINFO_HELP_ASSIGN_BYREFwhich usesrsiandrdijust likemovsdoes.The use of
movsmay be worth investigation, it doesn't have a good reputation performance wise. For example, on Skylakemovsrequires 5 uops instead of 1 or 2 needed bymovdqu. That said, its association with helper calls and memory accesses might mean that the overhead is too small to matter.mikedn commentedon Feb 20, 2017
Some quick testing seems to indicate that when
vmovdquis used the code is ~1.5x faster. It would seem thatmovsis indeed very slow, especially considering that the test code includes 2 calls.huoyaoyuan commentedon May 6, 2024
I believe this can be closed now. Struct copying now uses SSE/AVX when appropriate:
https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AXEBDAzgWwB8ABAJgEYBYAKBuIGYACXDKAVzA0YFkZ9oAnjQDeNRuMaxsAEwgA7ADYDGASzlcA+hADucmFADcYiVNmLlazSulHqEyTBnylq9Yw1rpMBLfunnFm4aCjByAOYYABa+EpaM2DHiccCJrlxgqXE2NAC+NHRMZIwAwoyidhK8/FDK+KnG4sQoPAAUVYKMAG7YCmwwAJSMALwAfIz4w109fbY5QA
Struct with GC reference may use
rep movsxthough.EgorBo commentedon May 28, 2026
Presumably fixed by #128542