Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Aug 31, 2024

Conversation

sagudev
Copy link
Contributor

@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 as a code owner August 31, 2024 07:03
@teoxoy teoxoy merged commit 26398ea into gfx-rs:trunk Aug 31, 2024
25 checks passed
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