-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Arm64 SVE: Fix conditionalselect with constant arguments #116852
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
Conversation
Fixes dotnet#116847 When folding, allow arg1 to be a constant mask
@dotnet/arm64-contrib @kunalspathak |
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
/azp run Antigen, Fuzzlyn |
Azure Pipelines successfully started running 2 pipeline(s). |
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 is a bug in EvaluateSimdVectorToPattern
where we are not validating it against the contents of arg0
.
The simd.h changes in this PR are out of date. We should wait for #116854 to be merged first. |
i will hold off reviewing this until #116854 is merged. |
Fuzzlyn was showing some errors with
This is due to The fix is closely related to the fix in this PR, so I've put it into this PR with a test. I've also updated simd.h to the latest from #116854 |
This reverts commit b923b28.
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
I've switched I put it in this PR as it's all related to constant vectors/masks. With these changes, I'm not currently seeing any Fuzzlyn failures. |
Couple minor changes needed, but otherwise LGTM |
Fuzzlyn isn't completely clean, I'm seeing one issue per hour. public static int M12()
{
for (int lvar0 = 2; lvar0 > 0; lvar0--)
{
var vr3 = Sve.ConditionalSelect(Vector128.CreateScalar((byte)1).AsVector(), Vector.Create<byte>(0), Vector.Create<byte>(1));
uint var1 = (uint)Sve.SaturatingIncrementByActiveElementCount(s_11, vr3);
Consume(var1);
}
return 0;
}
What's happening is the conditionalSelect has been optimised down to a constant vector, but it's only used as a mask, so it gets replaced with a constant mask. This mask is then stored as a local variable. When lowering the mask, it fails to find an SVE mask pattern, so it tries to convert it back to a constant vector. To do that it needs the type of vector type of the user of the mask. But the user is a lcl store, so it asserts. I don't think there is any obvious way of fixing this inside lowering. Is it safe to have lcl vars stored as masks? Can we get the required base types from tree of the LCL_VAR (urgh) ? Should we just prevent constant vectors being converted to masks when being stored as local vars? |
Yes, this is intentional to allow CSE and other core optimizations to lightup
Not trivially today, and it should generally be assumed there may be cases that it is not possible.
I don't think this is desirable. Rather you want to ensure that the But, we may still get non-propagatable scenarios, so really this should be just loading a mask constant, rather than doing the |
Yes it can, but that is SVE2.1 and there aren't any machines that support it yet. |
If the PR is functionally ok as is, could we push this to another PR. That way we can get fuzzlyn working again with this PR. |
Yeah, for sure. That isn't a functionality issue just something that can help improve codegen. Was more calling it out as what you'd want to do to avoid the more expensive path if we have places that can otherwise optimize. |
This PR is looking good now. Fuzzlyn looks happy (except for hitting the known #113940). CI failures aren't related to this PR. @amanasifkhalid |
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.
@tannergooding any other comments?
Fixes #116847
When folding, allow arg1 to be a constant mask