Skip to content

Add tests and benchmarks for the gather/scatter rewrite - #3987

Merged
aneshlya merged 5 commits into
ispc:mainfrom
aneshlya:gather-b1-tests
Nov 4, 2026
Merged

aneshlya merged 5 commits into
ispc:mainfrom
aneshlya:gather-b1-tests

Conversation

@aneshlya

@aneshlya aneshlya commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Tests and benchmarks for the gather/scatter work, ahead of rewriting ImproveMemoryOps and GatherCoalescePass (#3990). No compiler changes.

Bugs found along the way and filed separately: #3983 (integer-to-pointer casts lose provenance), #3984 (GatherCoalescePass and negative offsets with --addressing=32), #3985 (nsw on unsigned index scaling), #3986 (crash after an undeclared symbol in a template).

Testing

  • check-all passes on the current main (ded7463) with LLVM 21.1.8: 711 passed, 18 expected failures, 121 unsupported, no failures. The new and changed lit tests were also run on LLVM 20, 22, 23 and trunk in earlier revisions of this branch.
  • The functional suite passes with the guard pages on avx2-i32x8 at the current main: 1668 tests, no compilation or execution failures, 7 skipped (AMX, Xe and the --addressing=64-only gather-index-overflow-2). Earlier revisions of this branch were run on sse4-i32x4, avx2-i32x8, avx2-i32x16, avx512skx-x16 and avx512skx-x64, with --jit and with --addressing=64.
  • Every XFAIL build/check/run step was verified independently (lit stops at the first failure, so an XFAIL result alone does not establish every case): each fails on its own with the intended wrong result, and the passing variants pass.

Related Issue

Checklist

  • Code has been formatted with clang-format (e.g., clang-format -i src/ispc.cpp)
  • Git history has been squashed to meaningful commits (one commit per logical change)
  • Compiler changes are covered by lit tests
  • Language/stdlib changes include new functional tests for runtime behavior
  • Documentation updated if needed

🤖 Generated with Claude Code

@dbabokin

dbabokin commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T18:41:45.682645Z f69ec26 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: f69ec26442

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@aneshlya
aneshlya force-pushed the gather-b1-tests branch 3 times, most recently from bc42224 to 09fdd0f Compare November 2, 2026 21:54
aneshlya and others added 5 commits November 3, 2026 13:55
Pins the index width, scale, factored offsets, gather-to-load, coalescing
and known-mask decisions of ImproveMemoryOps and GatherCoalescePass, the
order of the memory passes and the inliner, the location of performance
warnings in inline helpers, and the code and warnings of the ispc#304, ispc#2720,
ispc#2778, ispc#2901, ispc#2308, ispc#2919 and ispc#2943 reproducers. Switching off each
transformation of the two passes one at a time showed six that no lit test
noticed and seven that only one test noticed; every pin fails with its
transformation switched off. Correct but suboptimal output carries an
issue-linked TODO stating the condition for changing the check.
memory-access-fallback.ll and memory-access-failed-match.ll (XFAIL) cover
the general-address fallback and unchanged IR after a rejected match for
the ispc#3990 rewrite.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…rule key

The four input arrays of the functional test harness (AOT and JIT) are now
allocated next to an inaccessible page: vfloat and vdouble end right at a
trailing guard page, vint and vint2 start right after a leading one, so a
gather, scatter or vector access past the end or before the start of an
input faults instead of passing silently. WebAssembly has no page
protection and keeps plain aligned arrays. The new rule key
'// rule: run|skip on addressing=32|64' selects tests by the addressing
mode ispc uses: the last --addressing flag of the ispc flags or ISPC_ARGS
on 64-bit architectures, 32 on 32-bit architectures and in JIT mode, 64 on
xe64.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…apes

24 tests using the guard pages of the functional test harness: masked
gathers, scatters, loads and stores whose inactive lanes point into the
guard page after or before an input, foreach tails and coalescable gathers
that end at the array boundary (gather-guard-1/2, scatter-guard-1/2,
masked-load-guard, masked-store-guard, coalesce-guard-1/2, guard-neg-1/2);
signed and unsigned 8- to 64-bit indices for every element type, negative
indices and byte offsets of 2^31 or more in both addressing modes
(gather-index-1..4, scatter-index-1, gather-index-overflow-1/2); duplicate
scatter indices and loads across aliasing stores, an atomic and two bases
(scatter-dup, gather-alias-1/2/3); and the shapes of discussion ispc#2943,
ispc#2778 and records read through inline helpers (rgba8-2943,
struct-copy-2778, vector-gather-helper).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
01_trivial/18_gather_scatter gathers and scatters int8, int32 and double
elements through int32, uint32, int16 and uint16 index arrays, with partial
masks and tails, and index patterns the compiler can see (broadcast of 4,
reverse, stride 2 and 4). 03_complex/01..05 cover moments of AOS point
records read packed, strided and indexed, 16-byte records read and written
through large inline helpers, the RGBA8 kernel of discussion ispc#2943, the
bilinear remap of discussion ispc#2919 and the byte struct copies of ispc#2778,
each with a reference implementation of the same element size. The weekly
dashboard shows them in the not gated section until they have a stable
history.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Guard-page runtime tests and IR tests for the gather, scatter and vector
load/store address gaps that remain after ispc#3985: lane 0 off with a signed
offset that overflows, offsets that wrap at 2^32 between lanes, a signed
constant split without nsw, a struct member at 2 GB through a varying
pointer, new[] sign extending an unsigned count, an unfolded +2^31
displacement, nneg copied to split or rescaled operands, a nested-index
sum of two signed-i32 byte offsets that reaches 2^31, an explicit int64
sum converted to a varying pointer, and the integer-to-pointer provenance
loss of ispc#3983. Each XFAIL test runs only the configurations that fail
today; address-gaps-ok.ispc, address-nested-sum.ispc and
address-provenance.ispc run the passing ones as regression gates, with
the kernels and drivers shared in address-gaps.inc and
address-provenance.inc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@aneshlya
aneshlya marked this pull request as ready for review November 3, 2026 22:58
@aneshlya
aneshlya requested review from azwolski and dbabokin November 3, 2026 23:01

@dbabokin dbabokin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Adversarial review of f670e9e: no actionable correctness or regression defects found.

I reviewed this from four independent angles: shared harness/argument handling and portability; functional-test semantics, bounds and oracles; lit/FileCheck and expected-failure coverage; benchmark correctness, measurement boundaries and dashboard integration.

Validation using a fresh build of this revision with LLVM 23.1.2 on macOS ARM64:

  • cmake --build build-review --target check-all -j 8: 622 passed, 11 expected failures, 217 unsupported, no unexpected failures.
  • All 24 new functional tests checked on neon-i32x4 and generic-i1x64, with both addressing modes: 23 passed plus the intended addressing-only skip in each 32-bit run; all 24 passed in each 64-bit run. Native JIT: 23 passed plus the intended skip.
  • Full functional suite on neon-i32x4/aarch64: 1,653 passed, 15 skipped out of 1,668, zero compilation or execution failures.
  • All six new benchmarks compiled and passed their C++ correctness checks on both targets: 502 cases total. Dashboard selection also matched the intended not-gated cases.
  • Direct harness probes verified 64-byte alignment, valid boundary accesses and faults immediately beyond the protected boundary. Addressing-selection probes covered flag precedence, fixed-width architectures and JIT.
  • Independently compiled and checked the standalone IR XFAILs to confirm they fail for their documented transformations, rather than an unrelated compilation error.

Nonblocking coverage suggestion: split independent runtime configurations into separate XFAIL tests. For example, in address-gap-nested-sum.ispc:9–18, the first failing execution prevents the --wrap-signed-int and -O0 runs from executing in CI. Separate tests would continuously exercise each configuration and produce an XPASS when one is fixed. The PR explicitly acknowledges this limitation and reports independent manual checks, so I am not treating it as a blocking defect.

Local coverage limits: Linux-only guard-page runtime reproducers, native x86/Windows execution and other LLVM versions were not independently rerun. The current PR CI is green, but the local results above do not replace that platform coverage.

@aneshlya
aneshlya merged commit e1d896f into ispc:main Nov 4, 2026
161 checks passed
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.

2 participants