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

[MIR] Fix double-rounding of float constants and ignore NaN sign in tests. #34006

Merged
merged 3 commits into from
Jun 6, 2016

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Jun 1, 2016

Fixes #32805 by handling f32 and f64 separately in rustc_const_eval.

Also removes #[rustc_no_mir] from a couple libstd tests by ignoring NaN sign.
Turns out that runtime evaluation of 0.0 / 0.0 produces a NaN with the sign bit set,
whereas LLVM constant folds it to a NaN with the sign bit unset, which we were testing for.

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

(FInfer { f64: a, .. }, FInfer { f64: b, .. }) => {
unsafe{transmute::<_,u64>(a) == transmute::<_,u64>(b)}
}
(F32(a), F32(b)) => {
Copy link
Contributor

@oli-obk oli-obk Jun 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also needs the FInfer + F32 branches for f32 inference

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, thanks for noticing!

@eddyb eddyb force-pushed the mir-const-fixes branch from 42c65a9 to 29b1af5 Compare June 1, 2016 10:50
// Ignore the "sign" (quiet / signalling flag) of NAN.
// It can vary between runtime operations and LLVM folding.
let (nan_m, nan_e, _nan_s) = NAN.integer_decode();
assert_eq!((nan_m, nan_e), (12582912, 105));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can’t believe this test worked for so long on all of the platforms we support, because mantissa of NaN is not specified to be anything in particular. The only requirement is that the MSB of the mantissa is set to 1 to differentiate from infinity.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nagisa Well, LLVM was always doing the folding for us, and it always produces the same result.

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jun 5, 2016

📌 Commit 29b1af5 has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Jun 5, 2016

🔒 Merge conflict

@bors
Copy link
Contributor

bors commented Jun 5, 2016

☔ The latest upstream changes (presumably #33905) made this pull request unmergeable. Please resolve the merge conflicts.

@eddyb eddyb force-pushed the mir-const-fixes branch from 29b1af5 to c77166c Compare June 5, 2016 16:18
@eddyb
Copy link
Member Author

eddyb commented Jun 5, 2016

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Jun 5, 2016

📌 Commit c77166c has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Jun 5, 2016

⌛ Testing commit c77166c with merge 6e577ca...

@bors
Copy link
Contributor

bors commented Jun 5, 2016

💔 Test failed - auto-win-msvc-64-opt

@eddyb
Copy link
Member Author

eddyb commented Jun 5, 2016

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Jun 5, 2016

📌 Commit f158a2f has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Jun 5, 2016

⌛ Testing commit f158a2f with merge e19ccb5...

@bors
Copy link
Contributor

bors commented Jun 5, 2016

⛄ The build was interrupted to prioritize another pull request.

@bors
Copy link
Contributor

bors commented Jun 5, 2016

⌛ Testing commit f158a2f with merge 323e9ca...

@bors
Copy link
Contributor

bors commented Jun 6, 2016

💔 Test failed - auto-mac-64-opt-rustbuild

@eddyb
Copy link
Member Author

eddyb commented Jun 6, 2016

@alexcrichton ^^ Spurious?

@alexcrichton
Copy link
Member

@eddyb hm maybe yeah, I can't really come up with an explanation otherwise. PR definitely doesn't touch Cargo.* anywhere as "cargo" isn't anywhere in the diff, so I'm not really sure how this could happen. Let's retry for now and if it happens again I can try to investigate further.

@bors: retry

@bors
Copy link
Contributor

bors commented Jun 6, 2016

⌛ Testing commit f158a2f with merge 763f923...

bors added a commit that referenced this pull request Jun 6, 2016
 [MIR] Fix double-rounding of float constants and ignore NaN sign in tests.

Fixes #32805 by handling f32 and f64 separately in rustc_const_eval.

Also removes `#[rustc_no_mir]` from a couple libstd tests by ignoring NaN sign.
Turns out that runtime evaluation of `0.0 / 0.0` produces a NaN with the sign bit set,
whereas LLVM constant folds it to a NaN with the sign bit unset, which we were testing for.
@bors bors merged commit f158a2f into rust-lang:master Jun 6, 2016
@eddyb eddyb deleted the mir-const-fixes branch June 6, 2016 15:21
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.

7 participants