Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/resources/cache/hashes.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,26 @@ export const d = makeCaseCache('binary/i32_arithmetic', {
remainder_const: () => {
return generateBinaryToI32Cases(sparseI32Range(), sparseI32Range(), i32_remainder_const);
},
// Negative dividends across non-power-of-two moduli. The default sparse i32
// range only exercises the moduli 10 and 256, so it misses value-dependent
// codegen paths (e.g. modulus 768) where some implementations compute signed
// `%` as if it were unsigned (e.g. lowering to a poison-prone `OpSRem`),
// yielding 255 instead of -1 for `-1 % 768`. See
// https://github.com/gfx-rs/wgpu/issues/8191.
remainder_negative_non_const: () => {
return generateBinaryToI32Cases(
[-1, -2, -5, -255, -256, -768, -769, -1000, -1234567],
[3, 7, 100, 256, 768, 1000],
i32_remainder_non_const
);
},
remainder_negative_const: () => {
return generateBinaryToI32Cases(
[-1, -2, -5, -255, -256, -768, -769, -1000, -1234567],
[3, 7, 100, 256, 768, 1000],
i32_remainder_const
);
},
addition_scalar_vector2: () => {
return generateI32VectorBinaryToVectorCases(sparseI32Range(), vectorI32Range(2), i32_add);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,28 @@ Expression: x %= y
await run(t, compoundBinary('%='), [Type.i32, Type.i32], Type.i32, t.params, cases);
});

g.test('remainder_negative')
.specURL('https://www.w3.org/TR/WGSL/#arithmetic-expr')
.desc(
`
Expression: x % y, with negative dividends across non-power-of-two moduli.

Regression coverage for implementations that compute signed remainder as
unsigned for negative operands (e.g. lowering to a poison-prone OpSRem without
VK_KHR_maintenance8), which returns 255 instead of -1 for -1 % 768.
See https://github.com/gfx-rs/wgpu/issues/8191.
`
)
.params(u =>
u.combine('inputSource', allInputSources).combine('vectorize', [undefined, 2, 3, 4] as const)
)
.fn(async t => {
const cases = await d.get(
t.params.inputSource === 'const' ? 'remainder_negative_const' : 'remainder_negative_non_const'
);
await run(t, binary('%'), [Type.i32, Type.i32], Type.i32, t.params, cases);
});

g.test('addition_scalar_vector')
.specURL('https://www.w3.org/TR/WGSL/#arithmetic-expr')
.desc(
Expand Down