-
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
JIT does not eliminate null check for "o ??= new()" #75987
Comments
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsDescriptionstatic void M1(object o) {
if ((o ??= new object()) is null) throw new Exception();
}
static void M2(object o) {
if ((o = new object()) is null) throw new Exception();
}
static void M3(int i) {
if (i < 0) i = 0;
if (i < 0) throw new Exception();
}
static void M4(object o) {
} While the JIT can optimize Found while discussing #75936. Configurationsharplab says "Core CLR 6.0.822.36306 on amd64". I also tried 7.0.100-rc.1.22431.12 on amd64. The codegen for Regression?Probably not.
|
Looks like Jump-Threading + PHI issue? BB03 is never true because V02 is either come form |
Likely |
No, you were right, this is the PHI case: #48115 (comment)
|
Description
https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AXEBDAzgWwB8ABAJgEYBYAKGIGYACMhgYQYG8aHunHjykTFAwCy5ABQRgAKxhgMDCAEoOXHuoCWAMwbjJDAPwGAvAwB2MAO6KZcjOKUqNucwFcANu5UYAFlAjWFtYAoghgMAAOGBoQZg4A3GrcAL5JDGn0TAJCoqSStvKKKpzU6po6ehAMpkE2svIOTi5mHl4Mvv6BVgyh4VExcUqJpTypI9wZfNnEwiJ04hpmChrFaeW6GgwAPAwADE7Ve8NlPNob23vefgHm3b2R0bEJaWPqk1mCM6Io+fUKyqpxgwxskgA=
While the JIT can optimize
M2
(almost, but still curiously worse thanM4
) andM3
to a nop, it cannot optimizeM1
similarly.Found while discussing #75936.
Configuration
sharplab says "Core CLR 6.0.822.36306 on amd64".
I also tried 7.0.100-rc.1.22431.12 on amd64. The codegen for
M1
was not really better.Regression?
Probably not.
The text was updated successfully, but these errors were encountered: