-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Arm64] Don't generate hardware intrinsic method bodies #39753
Conversation
68c2af6
to
27a2165
Compare
src/coreclr/src/zap/zapinfo.cpp
Outdated
#if defined(TARGET_ARM64) | ||
if (!fIsPlatformHWIntrinsic && fIsHWIntrinsic) | ||
{ | ||
fTreatAsRegularMethodCall = (strcmp(className, "Vector64`1") != 0) && (strcmp(className, "Vector128`1") != 0); |
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.
Why don't we need something similar for Vector128<T>
and Vector256<T>
on x86?
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.
(I might just be missing where we cover it, if it exists somewhere)
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.
My understanding (that could be incorrect) is that on x86 in R2R code we want to treat all calls outside of System.Runtime.Intrinsics.X86 as regular calls since there is no guarantee what ISAs will be supported on target platform while on Arm64 - ArmBase and AdvSimd are baseline and always supported.
@davidwrighton Is it correct interpretation of discussion in #38060?
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.
Ah right. I remember this reasoning now. It always confuses me at first 😄
src/coreclr/src/zap/zapinfo.cpp
Outdated
#if defined(TARGET_ARM64) | ||
if (!fIsPlatformHWIntrinsic && fIsHWIntrinsic) | ||
{ | ||
fTreatAsRegularMethodCall = (strcmp(className, "Vector64`1") != 0) && (strcmp(className, "Vector128`1") != 0); |
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.
you are missing |=
. It should be fTreatAsRegularMethodCall |= (strcmp(className, "Vector64
1") != 0) && (strcmp(className, "Vector1281") != 0);
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.
No, I am not.
Consider this:
- If
fTreatAsRegularMethodCall=true
before line 2160, then it meansfIsPlatformHWIntrinsic=true
and the if-condition is false. - If
fTreatAsRegularMethodCall=false
before line 2160, thenfTreatAsRegularMethodCall = fTreatAsRegularMethodCall || (if-cond-expr)
is equvalent tofTreatAsRegularMethodCall = (if-cond-expr)
.
I could've written this as
fTreatAsRegularMethodCall = (fIsGetIsSupportedMethod && fIsPlatformHWIntrinsic) || (!fIsPlatformHWIntrinsic && fIsHWIntrinsic
#if defined(TARGET_ARM64)
&& ((strcmp(className, "Vector64`1") == 0) || (strcmp(className, "Vector128`1") == 0))
#endif
);
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.
I could've written this as
Yes either that or something like this:
fTreatAsRegularMethodCall = (fIsGetIsSupportedMethod && fIsPlatformHWIntrinsic);
if (!fIsPlatformHWIntrinsic && fIsHWIntrinsic)
{
#if defined(TARGET_ARM64)
// For ARM64, treat as method calls if HWIntrinsic is not the one supported.
fTreatAsRegularMethodCall |= (strcmp(className, "Vector64`1") != 0) && (strcmp(className, "Vector128`1") != 0);
#else
// For XArch, always treat HWIntrinsic as method calls.
fTreatAsRegularMethodCall |= true;
#endif
}
Currently, it just feels like we override the fTreatAsRegularMethodCall
without carefully inspecting the code the way you pointed.
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.
I pushed the simpler change. I think it's better to repeat (!fIsPlatformHWIntrinsic && fIsHWIntrinsic)
twice.
27a2165
to
1f5e97e
Compare
@@ -450,7 +450,7 @@ void ZapInfo::CompileMethod() | |||
} | |||
#endif | |||
|
|||
#if defined(TARGET_X86) || defined(TARGET_AMD64) | |||
#if defined(TARGET_X86) || defined(TARGET_AMD64) || defined(TARGET_ARM64) | |||
if (methodAttribs & CORINFO_FLG_JIT_INTRINSIC) |
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.
@AntonLapounov Can you please show me the place when I can disable pre-generation of the intrinsics bodies on Arm64 in CrossGen2?
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.
I think CorInfoImpl.ShouldSkipCompilation
controls that.
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.
It looks it already does this right
runtime/src/coreclr/src/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs
Lines 190 to 193 in 557c7af
if (HardwareIntrinsicHelpers.IsHardwareIntrinsic(methodNeedingCode)) | |
{ | |
return true; | |
} |
Thanks!
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.
LGTM
* Don't generate hardware intrinsic method bodies on Arm64 in zapinfo.cpp * Treat Vector64 and Vector128 methods as intrinsics on Arm64 in zapinfo.cpp
Fixes #39618