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

Possible incorrect result in compiler-rt 128x128 wideMultiply #90009

Closed
tgross35 opened this issue Apr 25, 2024 · 1 comment · Fixed by #97257
Closed

Possible incorrect result in compiler-rt 128x128 wideMultiply #90009

tgross35 opened this issue Apr 25, 2024 · 1 comment · Fixed by #97257

Comments

@tgross35
Copy link

tgross35 commented Apr 25, 2024

This bit of code seems to have a bug where it is missing the carry bit. This was discovered when I was porting the function to Rust's compiler-rt and results of unit tests disagreed with Python, see rust-lang/compiler-builtins#587 (comment) and the followup discussion.

To reproduce - "0xffffffffffffffffffffffffffffffff * 0xffffffffffffffffffffffffffffffff should be 0xfffffffffffffffffffffffffffffffe00000000000000000000000000000001, but this function returns 0xfffffffffffffffffffffffffffffffd00000000000000000000000000000001.

cc @marthadev who found a fix for the Rust side.

Appears to cause #91840 (comment)

@tgross35 tgross35 changed the title Possible bug in compiler-rt 128x128 wideMultiply Possible incorrect result in compiler-rt 128x128 wideMultiply Apr 25, 2024
@tgross35
Copy link
Author

I suspect this just hasn't come up because a u128 is never saturated by the mantissa of a f128

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants