Skip to content

Add i32 % execution tests for negative dividends across non-power-of-two moduli#4665

Merged
zoddicus merged 2 commits into
gpuweb:mainfrom
mstampfli:test/i32-remainder-negative-dividend
Jun 16, 2026
Merged

Add i32 % execution tests for negative dividends across non-power-of-two moduli#4665
zoddicus merged 2 commits into
gpuweb:mainfrom
mstampfli:test/i32-remainder-negative-dividend

Conversation

@mstampfli

@mstampfli mstampfli commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

The existing binary,i32_arithmetic:remainder cases draw operands from the sparse i32 range, whose only divisors are 10 and 256. That misses value-dependent codegen paths - e.g. modulus 768 - where some implementations compute signed % as if it were unsigned for negative dividends, returning 255 instead of -1 for -1 % 768.

This adds a remainder_negative test (and cache builders) exercising negative dividends (-1, -2, -5, -255, -256, -768, -769, -1000, -1234567) across moduli (3, 7, 100, 256, 768, 1000). Expected values use the existing i32_remainder_* reference helpers (truncated remainder, sign of dividend), unchanged.

The regenerated case cache (src/resources/cache/.../i32_arithmetic.bin + hashes.json) is included. npm run typecheck and npm run lint pass.

Context: discovered via the wgpu/naga OpSRem poison issue, gfx-rs/wgpu#8191.

…o moduli

The existing remainder cases only use moduli 10 and 256 (from the sparse i32 range), missing value-dependent codegen paths such as modulus 768 where some implementations compute signed % as unsigned for negative operands (e.g. -1 % 768 returns 255 instead of -1). Add a remainder_negative test covering negative dividends across moduli 3/7/100/256/768/1000. See gfx-rs/wgpu#8191.
@kainino0x kainino0x requested a review from zoddicus June 16, 2026 00:38
@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

Results for build job (at 2992a57):

+webgpu:shader,execution,expression,binary,i32_arithmetic:remainder_negative:* - 16 cases, 16 subcases (~1/case)
-TOTAL: 283213 cases, 2325024 subcases
+TOTAL: 283229 cases, 2325040 subcases

@zoddicus zoddicus merged commit cf00736 into gpuweb:main Jun 16, 2026
1 check passed
mstampfli added a commit to mstampfli/mstampfli that referenced this pull request Jun 16, 2026
mstampfli added a commit to mstampfli/mstampfli.com that referenced this pull request Jun 16, 2026
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