question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect JIT asm w/ intrinsics (eg. Sse2, Avx2)

See original GitHub issue

Hello, 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:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
ashmindcommented, May 13, 2020

Thanks for reporting and good feedback! I have some ASM improvements planned, but didn’t get to them just yet.

Read more comments on GitHub >

github_iconTop Results From Across the Web

proposal: add package for using SIMD instructions #53171
Example A is a conversion of the assembly version. The idea was that with the native types it would be possible to hook...
Read more >
What are the errors in these avx2 intrinsics, and how to use ...
The Intel reference manual is fairly opaque on the details of how instructions are used. There are no examples on each instruction page....
Read more >
Performance Improvements in .NET 7
Now as intrinsics, when they're passed a constant value (e.g. 0 for the 0th rank), the JIT can substitute the necessary assembly ......
Read more >
Changelog | Burst | 1.8.7 - Unity User Manual 2021.3 (LTS)
Fixed an issue when targeting multiple cpu architectures (e.g. SSE2 & AVX2) that under some circumstances would lead to code attempting to ...
Read more >
Improving performance with SIMD intrinsics in three use ...
Source code that contains sufficient amounts of vector intrinsics or embeds their assembly equivalents is called manually vectorized code.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found