Skip to content

Improved code generation for mixed-size Index/Data gather (issue #69) - #76

Open
danieltowner wants to merge 2 commits into
freestanding_modefrom
issue_69
Open

danieltowner wants to merge 2 commits into
freestanding_modefrom
issue_69

Conversation

@danieltowner

Copy link
Copy Markdown
Contributor

Previously gather would canonicalise the indexes and data-elements to be the same size which would result in a size promotion before the gather or a truncation after. However, AVX-512 allows them to be different sizes so the new code handles different sizes. The avx512 gather code has also been factored out into its own function to make it easier to reuse for 128-bit elements in the future.

@danieltowner
danieltowner added this pull request to stack #75 November 20, 2026 21:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Regression coverage is missing for oversized tables with narrow index types and for unsigned 32- and 64-bit indexes, leaving new bounds-checking and hardware-index selection paths untested.

2 open issues
What changed in this PR

This PR improves x86 SIMD gather code generation for mixed-width indexes and data, avoiding unnecessary conversions and factoring hardware gather operations into a reusable helper.

Changes:

  • Selects AVX2 and AVX-512 gather instructions based on index and element widths.
  • Updates bounds checking and adds mixed-width regression coverage.
  • Adds performance scenarios and baselines for both mixed-width combinations.
File Description
test/​TestSimdGatherScatter.cpp Adds mixed-width gather and bounds-check regression tests.
test/​performance/​scenarios/​gather_u64_i32.cpp Measures 64-bit data gathers with 32-bit indexes.
test/​performance/​scenarios/​gather_u32_i64.cpp Measures 32-bit data gathers with 64-bit indexes.
test/​performance/​baselines.json Records baselines for the new performance scenarios.
include/​xvec/​x86/​x86_impl.hpp Extracts the hardware gather helper and supports mixed widths with revised bounds checking.

Review effort: Balanced

Comment thread test/TestSimdGatherScatter.cpp Resolved
Comment thread test/TestSimdGatherScatter.cpp Resolved
@danieltowner
danieltowner force-pushed the issue_69 branch 2 times, most recently from 4366b6e to 61210e4 Compare November 21, 2026 17:34
Previously gather would canonicalise the indexes and data-elements to be
the same size which would result in a size promotion before the gather
or a truncation after. However, AVX-512 allows them to be different sizes
so the new code handles different sizes. The avx512 gather code has also been factored
out into its own function to make it easier to reuse for 128-bit
elements in the future.
Add copyright notice to gather_u64_i32 scenario, and add tests for
unsigned-index masked gathers and ranges exceeding the index type maximum.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants