-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ILLink substitution for wasm intrinsics #93407
Conversation
Tagging subscribers to this area: @dotnet/area-system-runtime-intrinsics Issue DetailsNoticed those were missing while looking at #93399
|
@tannergooding looks like your recent PR broke the build :) |
I wonder - do these do anything, or are we just cargo culting them since they were introduced in #37615? The way we build CoreLib source code ensures that Line 14 in 851c274
In the WASM CoreLib "supported" version of the file is supposed to recursively calls itself like these do for all the other platforms but it also returns false (I think this is a bug): runtime/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Wasm/PackedSimd.cs Line 17 in 851c274
ILLink should be able to inline the false value even without these substitutions (@vitek-karas @sbomer to double check me on this). The reason why we do these as a recursive call on platforms where IsSupported could be true at runtime are twofold:
Sample of a correct IsSupported implementation here: runtime/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/AdvSimd.cs Line 18 in 851c274
Hardcoded to false on platforms that are not ARM: Line 22 in 851c274
|
86bbc5d
to
1efeee4
Compare
I agree, I pushed a fix for that, let's see if it breaks anything 😄
I don't see it doing that in practice though, if I remove the substitution then it doesn't inline the false value from the property. |
@@ -14,7 +14,7 @@ namespace System.Runtime.Intrinsics.Wasm | |||
[CLSCompliant(false)] | |||
public abstract class PackedSimd | |||
{ | |||
public static bool IsSupported { [Intrinsic] get { return false; } } | |||
public static bool IsSupported { [Intrinsic] get { return IsSupported; } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a comment why it's done this way?
I was looking at this yesterday and it made no sense... :-)
Would be nice to have comments in the other places as well, at least eventually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are quite a lot of intrinsics, I'll do that in a follow-up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Intrinsic]
means that the code you see may not be what is actually executed. The self-recursive implementation is used a lot with [Intrinsic]
methods.
Yes - it should be able to do that. But it's definitely worth a test or validation (it depends on the callsite, if the condition around it is too complex we might give up on it). |
Noticed those were missing while looking at dotnet#93399
1af8432
to
6650a8c
Compare
Looking at the source code, looks like ILLinker aborts this if there's IntrinsicAttribute on the method :( |
Is there a reason why we'd have |
Yeah, that would probably help. I don't think it serves a purpose. |
This was introduced in dotnet/coreclr#23751. It does serve purpose. It allows RyuJIT to get rid of the unreachable code sooner. If you delete |
What Jan said, but noting that it also provides a minor TP increase as the JIT doesn't have to process the IL, method body, etc. We can at import skip all the normal steps and just directly generate a node that returns constant |
Looking at this in more detail - trimmer should really not assume a value of an Intrinsic method - since it can't know what the runtime will do. So I think the fact that it doesn't do constant propagation in this case is by design. Which means we will need the substitution XML to tell it to do it anyway in these cases. |
Ok sounds like we're in agreement then that this is the way to go :) Merging. |
I don't see RyuJIT recognizing |
RyuJIT is recognizing all Compile
|
Noticed those were missing while looking at #93399
Also deleted an empty file that was checked in by mistake.
Fixed an issue where we weren't recursively calling IsSupported for PackedSimd which is the pattern we've been using (the JIT/AOT compiler is supposed to use the intrinsic instead)