-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Fix operator precedence consistency in ASCIIUtility.GetIndexOfFirstNonAsciiByte #64814
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
|
Tagging subscribers to this area: @dotnet/area-system-runtime-intrinsics Issue DetailsThe
|
|
Does it make any difference? Sse2 is only x86 and that's always little endian. |
|
@filipnavara in theory it shouldn't make a difference however we found this while investigating an issue where this apparently lead to a miscompilation in Mono AOT+LLVM where we were calling |
Presumably that's also being fixed separately? |
|
Sure, if that turns out to be the issue, we're still discussing :) I just happened to see this and throw up a PR. |
|
This PR is not fixing any real bug. The code is correct as-is. If this is a workaround for a bug to unblock something, that's ok - but the PR description should describe it as such. We have similar conditions based on the assumption that x86 is always little endian in number of other places. For example, here: runtime/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8Utility.Transcoding.cs Line 887 in 57bfe47
|
|
I was mainly doing this since the Debug.Assert(Sse2.IsSupported || AdvSimd.Arm64.IsSupported, "Sse2 or AdvSimd64 required.");
Debug.Assert(BitConverter.IsLittleEndian, "This SSE2/Arm64 implementation assumes little-endian.");so my mind translated that as
I agree that it doesn't change the behavior after you think it through but the change makes it more consistent, is there a perf or other concern that'd apply here for why we don't want to do it? |
|
I think the ask is to update the PR title. There is no actual error here, just a consistency/readability thing. Since x86/x64 can only target little endian, doing |
|
Sure that's fine, I'll make the two places consistent in ASCIIUtility.cs which also makes it consistent with Utf8Utility.Transcoding.cs |
…nAsciiByte The `&&` operator takes precedence over `||`, make it explicit by wrapping in parenthesis which also makes it consistent with other usages like https://github.com/dotnet/runtime/blob/57bfe474518ab5b7cfe6bf7424a79ce3af9d6657/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8Utility.Transcoding.cs#L887
1c926f8 to
36fe2cc
Compare
jkotas
left a comment
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.
Thanks
The
&&operator takes precedence over||, make it explicit by wrapping in parenthesis which also makes it consistent with other usages likeruntime/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8Utility.Transcoding.cs
Line 887 in 57bfe47
Sse2 implies little endian so the check only needs to apply to AdvSimd.