Skip to content

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

Open
mstampfli wants to merge 1 commit into
gpuweb:mainfrom
mstampfli:test/i32-remainder-negative-dividend
Open

Add i32 % execution tests for negative dividends across non-power-of-two moduli#4665
mstampfli wants to merge 1 commit into
gpuweb:mainfrom
mstampfli:test/i32-remainder-negative-dividend

Conversation

@mstampfli

@mstampfli mstampfli commented Jun 14, 2026

Copy link
Copy Markdown

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.
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