Skip to content

Overhaul the regression test for minmax_element()'s AVX2 tail - #6536

Open
Stephan T. Lavavej (StephanTLavavej) wants to merge 1 commit into
microsoft:mainfrom
StephanTLavavej:fluffy-kitty-tail
Open

Stephan T. Lavavej (StephanTLavavej) wants to merge 1 commit into
microsoft:mainfrom
StephanTLavavej:fluffy-kitty-tail

Conversation

@StephanTLavavej

Copy link
Copy Markdown
Member

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 of minmax_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.)

@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) added the test Related to test code label Nov 21, 2026
Copilot AI balanced review requested due to automatic review settings November 21, 2026 19:51
@github-project-automation github-project-automation Bot moved this to Copilot Review in STL Code Reviews Nov 21, 2026
@azure-pipelines

This comment was marked as resolved.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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 for minmax_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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Related to test code

Projects

Status: Final Review

Development

Successfully merging this pull request may close these issues.

2 participants