Skip to content

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

Draft
aneshlya wants to merge 5 commits into
ispc:mainfrom
aneshlya:gather-b1-tests
Draft

aneshlya wants to merge 5 commits into
ispc:mainfrom
aneshlya:gather-b1-tests

Conversation

@aneshlya

Copy link
Copy Markdown
Collaborator

Description

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

Bugs found along the way and filed separately: #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. The new and changed lit tests pass on LLVM 20, 21, 22, 23 and trunk.
  • The full functional suite passes with the guard pages on sse4-i32x4, avx2-i32x8, avx2-i32x16, avx512skx-x16 and avx512skx-x64, with --jit and with --addressing=64.
  • The tests of the last commit were run on sse4-i32x4, avx2-i32x8, avx2-i32x16 and avx1-i32x8 (gather-alias-1/2/3).

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

aneshlya and others added 5 commits October 26, 2026 15:30
New tests for the gather/scatter work. Each pins today's output and
documents the ideal output next to the checks, so the change that reaches
it updates them:

* gather-index-width: dword or qword gathers and scatters per index type,
  both addressing modes, with the original reproducer from ispc#1581.
* gather-scale: scale immediate vs pre-shifted index (ispc#1256, ispc#1531).
* inline-helper-gather: dword gathers and no llvm.stacksave for memory
  operations in large inline helpers (fails if the helpers are inlined
  after memory operations are lowered).
* perf-warn-inline-location: location and deduplication of performance
  warnings raised in inline helpers.
* pipeline-order: order of the memory operation passes and the inliner
  in --debug-pm output.
* 304, 2720-1, 2778, 2901, and 2308, 2919, 2943 (discussions): today's
  code and warnings for the issue reproducers.

Co-Authored-By: Claude Opus 5.5 <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.
A gather, scatter or vector access that touches memory past the end or
before the start of an input array now faults instead of passing
silently. WebAssembly has no page protection and keeps plain aligned
arrays. The full functional suite passes with the guards on sse4-i32x4,
avx2-i32x8, avx2-i32x16, avx512skx-x16 and avx512skx-x64, with --jit and
with --addressing=64.

'// rule: run|skip on addressing=32|64' selects tests by the addressing
mode ispc uses: the last --addressing flag of the ispc flags or of
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>
…apes

23 tests for the gather/scatter work, using the guard pages of the
functional test harness:

* Footprint: masked gathers, scatters, loads and stores whose inactive
  lanes point into the guard page after or before an input array, tails
  of foreach loops that end at the array boundary, and coalescable
  gathers whose last element is the last element of the array
  (gather-guard-1/2, scatter-guard-1/2, masked-load-guard,
  masked-store-guard, coalesce-guard-1/2, guard-neg-1/2).
* Index semantics: signed and unsigned 8-, 16-, 32- and 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).
* Conflicts: duplicate scatter indices and loads across aliasing stores
  (scatter-dup, gather-alias-1/2).
* Shapes: the RGBA8 kernel of discussion ispc#2943, byte struct copies of
  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>
* 01_trivial/18_gather_scatter: gathers and scatters of 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_gather_aos: moments of point records of 2, 3 and 4
  floats read packed, strided and indexed, with gathers, transposes and
  wide loads.
* 03_complex/02_inline_vector_gather: 16-byte records read and written
  through large inline helpers with an all-lanes-on fast path.
* 03_complex/03_rgba8_diff: the RGBA8 kernel of discussion ispc#2943, with a
  uint32 reference.
* 03_complex/04_bilinear_remap: the remap kernels of discussion ispc#2919,
  with a reference that deinterleaves the grid.
* 03_complex/05_struct_copy: byte struct copies of ispc#2778, with integer
  references of the same 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>
Switching off each transformation of the two passes one at a time showed six
that no lit test noticed (scale extraction, GetMoreConst, global-array bases,
2- and 4-wide coalescing loads, all-off masked store removal) and seven that
only one test noticed. The new and extended tests pin each of them, plus
--wrap-signed-int, --opt=force-aligned-memory, 32-bit x86, x64 coalescing,
barriers in the coalescing window and 32-bit offset narrowing; a functional
test checks values around an atomic and across two bases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.

1 participant