Repository navigation
Overhaul the regression test for minmax_element()'s AVX2 tail - #6536
Open
Stephan T. Lavavej (StephanTLavavej) wants to merge 1 commit into
Open
Stephan T. Lavavej (StephanTLavavej) wants to merge 1 commit into
Stephan T. Lavavej (StephanTLavavej) wants to merge 1 commit into
Conversation
Stephan T. Lavavej (StephanTLavavej)
requested a review
from a team
as a code owner
November 21, 2026 19:51
This comment was marked as resolved.
This comment was marked as resolved.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified in the regression-test update covering AVX2 tail handling and iterator tie-breaking.
No open issues 🎉
What changed in this PR
Strengthens the regression test for GH-6520’s AVX2 tail bug, covering both minimum and maximum results without changing the algorithm implementation.
Changes:
- Uses a two-portion prefix and a 12-byte tail designed to exercise vectorized tail processing.
- Checks exact iterator positions, including first-largest behavior for
max_element()and last-largest behavior forminmax_element(). - Explains the portion size and tail alignment requirements in comments.
| File | Description |
|---|---|
tests/std/tests/VSO_0000000_vector_algorithms/test.cpp |
Reworks the AVX2 tail regression input and assertions to cover minimums, maximums, and tie-breaking. |
Review effort: Balanced
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.
This overhauls the regression test that AlexGuteniev just added in #6521 while fixing #6520.
While writing up the Changelog, I wondered, "why did this asymmetrically affect
max_element()and the maximum part ofminmax_element(), but not the minimums?" And indeed, the minimums were affected, they just weren't exercised by the example test data.Here, I'm overhauling the test to exercise both the minimum and maximum, with a single test input. I reworked how we set up the initial portions, with better comments, and carefully crafted the tail to exercise the vectorized code. I also exercised the "first largest" and "last largest" behavioral difference. I've verified that all of the iterators were incorrect before the fix.
Opus 5.5 helped me figure out why the tail had to be a multiple of 4 bytes (my original tail "fluffykitty" was only 11 bytes long, so the final 'y' was processed by the scalar loop and didn't reveal the bug). This also indicated a silent, confusing deficiency in the original tail, where "second" was 6 bytes and therefore only "seco" was being processed by the AVX2 tail, with "nd" being scalar, it just didn't matter for the maximum there. (All of the code, the comments, and this writeup are mine.)