Skip to content

[naga] Use checked_mul or leading_zeros to detect shl overflows#6186

Merged
teoxoy merged 1 commit intogfx-rs:trunkfrom
sagudev:bitshift-const-overflow
Aug 31, 2024
Merged

[naga] Use checked_mul or leading_zeros to detect shl overflows#6186
teoxoy merged 1 commit intogfx-rs:trunkfrom
sagudev:bitshift-const-overflow

Conversation

@sagudev
Copy link
Copy Markdown
Collaborator

@sagudev sagudev commented Aug 31, 2024

Connections
fixes #6175

Description
On u32 we can use a.checked_mul(1.checked_shl(b)?)? to detect overflows, but unfortunetly same trick does not work for signed numbers, where we simply follow spec per letter.

Testing
Tested via CTS run in servo, makes all subtests of _webgpu/webgpu/cts.https.html?q=webgpu:shader,validation,expression,binary,bitwise_shift:shift_left_concrete:* pass in servo

Checklist

  • Run cargo fmt.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown
    • --target wasm32-unknown-emscripten
  • Run cargo xtask test to run tests.
  • Add change to CHANGELOG.md. See simple instructions inside file.

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
@sagudev sagudev marked this pull request as ready for review August 31, 2024 07:03
@sagudev sagudev requested a review from a team August 31, 2024 07:03
@teoxoy teoxoy merged commit 26398ea into gfx-rs:trunk Aug 31, 2024
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.

Report overflow when shl overflows into sign bit

2 participants