-
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
Value num refine phis #104752
Value num refine phis #104752
Conversation
@jakobbotsch FYI |
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
{ | ||
if (vn1 == vn2) | ||
{ | ||
return true; |
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.
is it fine if boths are NoVN ? I mean can the caller assume it can apply some opts
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 expect callers to screen these out. I guess I should add asserts here.
Diffs. TP is indeed down a bit from the other PR. Looks like there's a set of novel test failures on arm/arm64. |
The NAOT failure is looking suspiciously like another case of #88091. In Need to try and extract this pattern as a repro case. Not sure why it is seemingly arm/naot only yet, maybe the CSE only happens there. |
Repro case is something like the following using System.Runtime.CompilerServices;
unsafe
{
string example = "./";
fixed (char* p = example)
{
int result = Problem(p, 0, example.Length);
Console.WriteLine($"result={result}");
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
static void Expose(ref int x)
{ }
static unsafe int Problem(char* pString, int idx, int length)
{
bool dotFound = false;
int end = 0;
Expose(ref end);
for (end = idx; end < length; ++end)
{
if (dotFound && (pString[end] == '/' || pString[end] == '?' || pString[end] == '#'))
break;
else if (end < (idx + 2) && pString[end] == '.')
{
// allow one or two dots
dotFound = true;
}
else
{
//failure
return -1;
}
}
return 0;
} (if Here RBO can see while (true)
{
if (end < (idx + 2) && pString[end] == '.')
{
//
}
else
{
return -1;
}
end++;
if (end < length) break;
if (pString[end] == '/' || pString[end] == '?' || pString[end] == '#')
{
break;
}
} and CSE commons up all the One possible fix is to rework the Another though is to try and somehow capture the dependence of the memory load VNs on the VN for end, but I'm not sure how to approach that. |
/azp run runtime-coreclr jitstress, runtime-coreclr libraries-jitstress |
Azure Pipelines successfully started running 2 pipeline(s). |
There is a related stress failure with the assertion prop check. |
/azp run runtime-coreclr jitstress, runtime-coreclr libraries-jitstress |
Azure Pipelines successfully started running 2 pipeline(s). |
@jakobbotsch PTAL |
TP cost is all in copyprop, I think we can get some/most of this back by reducing the number of candidates it considers. |
@@ -6770,6 +6770,138 @@ const char* ValueNumStore::VNRelationString(VN_RELATION_KIND vrk) | |||
} | |||
#endif | |||
|
|||
bool ValueNumStore::IsVNPhiDef(ValueNum vn) |
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.
This looks unused
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.
Yeah, I'll remove it soon, if I don't find some other use for it.
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
Alternative take on #104458.
VN doesn't always give PHI defs the best possible values (in particular if there are backedge PHI args). Revise VN to run intg a "loop-respecting" RPO where we don't visit any loop successors until all loop blocks have been visited. Once the loop is done, update the header PHI VNs since all PHI arg VNs are now known.
Then look for equivalent PHI defs in copy prop and enable copy prop when two locals have the same values at the head of a loop.
Addresses the regression case noted in #95645 (comment) where cross-block morph's copy prop plus loop bottom testing has created some unnecessary loop-carried values.
Closes #95645.