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

Integer bitwise rotate miscompilation #1062

Closed
averyanalex opened this issue May 21, 2023 · 2 comments · Fixed by #1129
Closed

Integer bitwise rotate miscompilation #1062

averyanalex opened this issue May 21, 2023 · 2 comments · Fixed by #1129
Labels
t: bug Something isn't working

Comments

@averyanalex
Copy link

Expected Behaviour

Bitwise rotating works correctly.

Example & Steps To Reproduce

I was porting SHA512 and this function worked differently on CPU and GPU:

fn big_sigma0(x: u64) -> u64 {
    x.rotate_right(28) ^ x.rotate_right(34) ^ x.rotate_right(39)
}

System Info

  • Rust: rustc 1.69.0-nightly (44cfafe2f 2023-03-03)
  • OS: NixOS Linux 5.15.110
  • GPU: AMD Radeon RX 6800 XT
  • GPU Driver: amdvlk
  • SPIR-V: v2023.2 unknown hash, 1980-01-01T00:00:00 (incorrect time because of NixOS)
@averyanalex averyanalex added the t: bug Something isn't working label May 21, 2023
@schell
Copy link

schell commented Jul 10, 2023

Just FYI the same thing happens with u32.

@averyanalex averyanalex changed the title u64 bitwise rotate works incorrectly Integer bitwise rotate miscompilation Jul 10, 2023
@eddyb
Copy link
Contributor

eddyb commented Feb 7, 2024

I think @chrisliebaer just ran into the same issue, and AFAICT it's just this being flipped:

let mask_is_zero = self
.emit()
.i_not_equal(bool, None, mask_shift.def(self), zero.def(self))
.unwrap()
.with_type(bool);

(based on the name it should clearly be == not !=)

eddyb added a commit to LykenSol/rust-gpu that referenced this issue Feb 7, 2024
eddyb added a commit to LykenSol/rust-gpu that referenced this issue Feb 7, 2024
eddyb added a commit that referenced this issue Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants