Incorrect JIT asm w/ intrinsics (eg. Sse2, Avx2)
See original GitHub issueHello, I’ve noticed that sharplab.io
seems to struggle quite a bit when showing the JIT asm for code using intrinsics (eg. Vector256<T>
, Vector128<T>
and the various Sse2
, Avx2
, etc. classes), which results in the asm code beind displayed incorrectly, often including invalid
tokens and a bunch of incorrect instructions. I’ve prepared a repro here that shows the issue both with a standalone method, and when the method is inlined into another method, in case it makes a difference.
In particular, you can see that this line:
Vector128<int> vadd1 = Sse2.Add(vector.GetLower(), vector.GetUpper());
Is displayed as follows:
L000b: invalid
L000f: rol byte [rcx], 0xc5
L0012: invalid
L0014: or ebp, eax
L0016: int1
L0017: inc al
In particular it would seem that one of the APIs that causes this issue in sharplab
is the Vector256.GetUpper()
extension, which should translate to _mm256_extracti128_si256
in this case.
This makes it particularly difficult to inspect/optimize code when these APIs are involved. I’m not sure if this is an issue with the sharplab
backend in particular or something help, hope this helps!
Keep up the amazing work! 😊
P.S. not seeing a donation link anywhere, if you ever get one just ping me, I use sharplab
all the time and the least I can do for a fellow developer is to offer you a beer! 🍻
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
Hmm – I didn’t add the disclaimer this time, but your sample is targeted at Roslyn
master
. Roslyn branches lag a bit behind main deployment (sometimes by months tbh). Fortunately I just fixed the branch build, but themaster
branch still has SharpDisasm – hopefully only until tomorrow.If you try the same sample in Default you’ll see no
invalid
: https://sharplab.io/#v2:C4LghgzgtgPgAgBgARwIwDoBKBXAdsASygFN0BJfAJwNwgIGMIBuAWAChEUMd8jSLg1WgwjoAGgA4AbKzbs4AZi5SUAJiQARAhEhRMxAA6UA9uwDe7JFZRK0K7DWBIAogA9BYesExhcAc2IACgd8JAA3MAAbbGIAGiQAIwBPYGIkCGAwSmB45NSkSOJ/YAALAEpLaws2a1qUAHYkACEoAgwmgmAAMQJiSIATNw8vQIjouPTM7PjC4vLZWoBfdkqrRWUkEKcAZWJvXwDgx3ComNyUtIysnMSLgqK/UvitpAAzSLA/CAqaqtW6rb/OrWEoEPwlDrACBIAC8SECqGwSAAPMj7nMykgALRIRGxIHAgrGMD9ACykAA1rCkKDwZDoajJtd8b9CdYMsZKMRyRAqXDAu9PtCAGQ0sEQzrfFFoq7ZWQEtaNFptdAAQVw/QAcsZgIFIsSyZT4mMYpiYJNOdzKQtrMtWUh/us7EhjgAVYgZABqxC8nNUAFYpIFvb7KAGpMjHAA+cI+4Ccn61apskPxyioVQSSP4GMRfr9VDU7YQYiqNX50ZxznoADiewAMsYAO7ESiBMrGquUWt7ACqBgMrfbZXl9tqcEaeYL6Fdxm29CiWXbNqsdsWQA==Thanks for reporting and good feedback! I have some ASM improvements planned, but didn’t get to them just yet.