Skip to content

Conversation

@stephentoub
Copy link
Member

No description provided.

@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Oct 16, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enables the CA1516 analyzer rule ("Use cross-platform intrinsics") which encourages the use of cross-platform SIMD operator overloads instead of platform-specific intrinsic methods. The changes replace platform-specific intrinsic calls (like AdvSimd.ShiftRightArithmetic, Sse2.Or, Avx2.Add) with their equivalent C# operator overloads (like >>, |, +) that work across multiple platforms.

Key changes:

  • Replaced arithmetic and bitwise intrinsic method calls with operator overloads throughout the codebase
  • Enabled CA1516 as a warning in source code analysis configuration
  • Disabled CA1516 in test code and intrinsics implementation folders where the rule shouldn't apply

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
eng/CodeAnalysis.src.globalconfig Enabled CA1516 as a warning for source code
eng/CodeAnalysis.test.globalconfig Disabled CA1516 for test code
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/.editorconfig Disabled CA1516 for intrinsics implementations
src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8Utility.Validation.cs Replaced AdvSimd.ShiftRightArithmetic and AdvSimd.And with >> and & operators
src/libraries/System.Private.CoreLib/src/System/Text/Latin1Utility.cs Replaced Sse2.Or with `
src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs Replaced AdvSimd.ShiftRightArithmetic and AdvSimd.And with >> and & operators
src/libraries/System.Private.CoreLib/src/System/SearchValues/IndexOfAnyAsciiSearcher.cs Replaced AdvSimd.ShiftRightArithmetic with >> operator
src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64EncoderHelper.cs Replaced Avx2.And, Avx2.MultiplyLow, Avx2.Or, Avx2.Subtract, Avx2.Add, and AdvSimd.ShiftRightLogical with operators
src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Helper/Base64DecoderHelper.cs Replaced Avx2.And and Avx2.Add with & and + operators
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.LeadingZeroCount.cs Replaced shift and bitwise intrinsics with operator overloads
src/libraries/Common/src/System/HexConverter.cs Replaced AdvSimd.ShiftLeftLogical and PackedSimd.ShiftLeft with << operator

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-runtime-intrinsics
See info in area-owners.md if you want to be subscribed.

Copy link
Member

@tannergooding tannergooding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad to see this picking up some cases and simplifying the implementation!

There's more scenarios we'll want to add to the analyzer over time, but this is a great first step!

@stephentoub stephentoub enabled auto-merge (squash) October 16, 2025 15:45
@stephentoub
Copy link
Member Author

@tannergooding, please also see dotnet/sdk#51299. I hit that while running the analyzer (it fails to show the description in the diagnostic as a result).

@stephentoub stephentoub merged commit 2519e77 into dotnet:main Oct 16, 2025
152 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants