Skip to content

Conversation

@tannergooding
Copy link
Member

This ensures that more SIMD compares can undergo constant folding and light up as optimizations alongside the broader handling.

@github-actions github-actions bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 27, 2025
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@tannergooding tannergooding marked this pull request as ready for review June 27, 2025 22:50
Copilot AI review requested due to automatic review settings June 27, 2025 22:50
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 extends the constant folding optimizations for SIMD compare operations on XARCH targets. Key changes include:

  • Adding new handling for AVX/AVX512 compare intrinsics in rationalize.cpp
  • Enhancing the transformation logic in morph.cpp and lowering in lowerxarch.cpp for more SIMD compare cases
  • Removing the now-unused float comparison swap helper in hwintrinsicxarch.cpp and its declaration in hwintrinsic.h, and adding additional folding logic in gentree.cpp

Reviewed Changes

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

Show a summary per file
File Description
src/coreclr/jit/rationalize.cpp Adds a new switch case for AVX/AVX512 compare constants folding on XARCH
src/coreclr/jit/morph.cpp Introduces transformations for folding compare intrinsics with constant mode adjustments
src/coreclr/jit/lowerxarch.cpp Updates mask intrinsic handling and constant folding logic for compare operations
src/coreclr/jit/hwintrinsicxarch.cpp Removes the obsolete lookupFloatComparisonModeForSwappedArgs function
src/coreclr/jit/hwintrinsic.h Removes the declaration of the obsolete lookupFloatComparisonModeForSwappedArgs
src/coreclr/jit/gentree.cpp Extends folding logic to support additional SIMD compare intrinsics
Comments suppressed due to low confidence (2)

src/coreclr/jit/morph.cpp:9927

  • In this branch, the constant value should be updated to 'newMode' instead of 'mode' to reflect the intended transformation when the mode is modified.
                        FloatComparisonMode mode =

src/coreclr/jit/lowerxarch.cpp:3077

  • This update should assign 'newMode' to cmpOp3 rather than the original 'mode' to ensure the transformation correctly folds the intrinsic.
                                        cmpOp3->AsIntConCommon()->SetIntegralValue(static_cast<uint8_t>(mode));

@tannergooding
Copy link
Member Author

CC. @dotnet/jit-contrib, small improvement to the xarch codegen and constant folding around compares. Normalizes more of the compare constants to require less nodes and does so early, allowing more constant folding and small output in some scenarios.

@tannergooding tannergooding merged commit 1742b6c into dotnet:main Jul 1, 2025
110 of 112 checks passed
@tannergooding tannergooding deleted the better-simd-cmp branch July 1, 2025 15:46
@github-actions github-actions bot locked and limited conversation to collaborators Aug 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants