Carry ExtractMostSignificantBits through to LIR and add constant folding support#117673
Carry ExtractMostSignificantBits through to LIR and add constant folding support#117673tannergooding merged 4 commits intodotnet:mainfrom
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
|
Diffs look positive and it's a nice throughput improvement as well. The few regressions are from places we have multiple We should get even bigger wins if we add some optimizations for particular |
|
/azp run Fuzzlyn |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull Request Overview
This PR carries the ExtractMostSignificantBits intrinsic through to the LIR (Low-level Intermediate Representation) and adds constant folding support. The main goal is to enable better codegen optimization for SIMD operations that extract the most significant bits from vector elements.
- Removes early expansion of ExtractMostSignificantBits intrinsics during import phase
- Adds constant folding capabilities for ExtractMostSignificantBits in both value numbering and expression folding
- Implements LIR-level rewriting for ExtractMostSignificantBits with platform-specific optimizations
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/jit/valuenum.cpp | Adds constant folding support for ExtractMostSignificantBits in value numbering |
| src/coreclr/jit/simd.h | Implements EvaluateExtractMSB template functions for constant evaluation |
| src/coreclr/jit/rationalize.h | Declares RewriteHWIntrinsicExtractMsb method for LIR rewriting |
| src/coreclr/jit/rationalize.cpp | Implements platform-specific LIR rewriting for ExtractMostSignificantBits |
| src/coreclr/jit/hwintrinsicxarch.cpp | Removes early expansion logic for x86/x64 short/ushort cases |
| src/coreclr/jit/hwintrinsiclistxarch.h | Updates intrinsic flags to enable special import and disable early codegen |
| src/coreclr/jit/hwintrinsiclistarm64.h | Updates intrinsic flags to enable special import and disable early codegen |
| src/coreclr/jit/hwintrinsicarm64.cpp | Removes early expansion logic for ARM64 ExtractMostSignificantBits |
| src/coreclr/jit/gentree.cpp | Adds constant folding support for ExtractMostSignificantBits in expression folding |
45e74a4 to
ac33bfe
Compare
|
/ba-g unrelated android timeout and image acquisition failure that passed on last run. |
This doesn't update the IR to take advantage of any special patterns yet.
It does, however, simplify the codegen for
V128<byte>.ExtractMostSignificantBits.The logic was previously:
The updated logic is:
The original logic would generate:
While the newer logic is a bit smaller and avoids a second more expensive
addvinstruction: