Repository navigation
minmax / minmax_element: avoid synthesizing _Min / _Max in traits - #6472
Open
Alex Guteniev (AlexGuteniev) wants to merge 5 commits into
Open
Alex Guteniev (AlexGuteniev) wants to merge 5 commits into
Alex Guteniev (AlexGuteniev) wants to merge 5 commits into
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
Copilot started reviewing on behalf of
Alex Guteniev (AlexGuteniev)
October 1, 2026 16:02
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Cross-architecture SIMD behavior, particularly Neon, requires platform-specific compilation and testing.
Review effort: Balanced
Findings: None
What changed in this PR
Refactors vectorized minmax and minmax_element to synthesize 64-bit min/max operations at call sites when SIMD instructions are unavailable.
Changes:
- Adds
_Has_min_maxcapability flags to SIMD traits. - Replaces synthesized 64-bit trait operations with comparison-and-blend wrappers.
- Simplifies native min/max trait signatures.
| File | Description |
|---|---|
stl/src/vector_algorithms.cpp |
Refactors SIMD min/max traits and implementations across SSE, AVX2, and Neon. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Slightly more code, but clearer
Copilot started reviewing on behalf of
Alex Guteniev (AlexGuteniev)
October 3, 2026 05:52
View session
Copilot started reviewing on behalf of
Alex Guteniev (AlexGuteniev)
October 3, 2026 06:23
View session
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow up to #6459
SSE4.2, AVX2, and Neon all lack 64-bit min/max instructions. We have to use blending instead with comparison result in
minmax_element, and produce such a result inminmax.Instead of synthesizing
_Minand_Maxin traits, let's do this in a lambda directly in the implementation. The traits now have_Has_min_maxbool constant, and only have_Minand_Maxif there are instructions. The traits don't need overloads or default parameters to have 3-arg_Minand_Max. The trick of using blending is now transparent,There isn't significant code reduction, it is mostly for clarity.
And also anticipation of future AVX-512, which does have 64-bit min/max instructions.
Hari Limaye (@hazzlim) please check if I didn't regress Neon.