forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#128271 - Nilstrieb:jump-into-a-can-of-worms-called-float-equality, r=compiler-errors Disable jump threading of float equality Jump threading stores values as `u128` (`ScalarInt`) and does its comparisons for equality as integer comparisons. This works great for integers. Sadly, not everything is an integer. Floats famously have wonky equality semantcs, with `NaN!=NaN` and `0.0 == -0.0`. This does not match our beautiful integer bitpattern equality and therefore causes things to go horribly wrong. While jump threading could be extended to support floats by remembering that they're floats in the value state and handling them properly, it's signficantly easier to just disable it for now. fixes rust-lang#128243
- Loading branch information
Showing
4 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
tests/mir-opt/jump_threading.floats.JumpThreading.panic-abort.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
- // MIR for `floats` before JumpThreading | ||
+ // MIR for `floats` after JumpThreading | ||
|
||
fn floats() -> u32 { | ||
let mut _0: u32; | ||
let _1: f64; | ||
let mut _2: bool; | ||
let mut _3: bool; | ||
let mut _4: f64; | ||
scope 1 { | ||
debug x => _1; | ||
} | ||
|
||
bb0: { | ||
StorageLive(_1); | ||
StorageLive(_2); | ||
_2 = const true; | ||
- switchInt(move _2) -> [0: bb2, otherwise: bb1]; | ||
+ goto -> bb1; | ||
} | ||
|
||
bb1: { | ||
_1 = const -0f64; | ||
goto -> bb3; | ||
} | ||
|
||
bb2: { | ||
_1 = const 1f64; | ||
goto -> bb3; | ||
} | ||
|
||
bb3: { | ||
StorageDead(_2); | ||
StorageLive(_3); | ||
StorageLive(_4); | ||
_4 = _1; | ||
_3 = Eq(move _4, const 0f64); | ||
switchInt(move _3) -> [0: bb5, otherwise: bb4]; | ||
} | ||
|
||
bb4: { | ||
StorageDead(_4); | ||
_0 = const 0_u32; | ||
goto -> bb6; | ||
} | ||
|
||
bb5: { | ||
StorageDead(_4); | ||
_0 = const 1_u32; | ||
goto -> bb6; | ||
} | ||
|
||
bb6: { | ||
StorageDead(_3); | ||
StorageDead(_1); | ||
return; | ||
} | ||
} | ||
|
59 changes: 59 additions & 0 deletions
59
tests/mir-opt/jump_threading.floats.JumpThreading.panic-unwind.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
- // MIR for `floats` before JumpThreading | ||
+ // MIR for `floats` after JumpThreading | ||
|
||
fn floats() -> u32 { | ||
let mut _0: u32; | ||
let _1: f64; | ||
let mut _2: bool; | ||
let mut _3: bool; | ||
let mut _4: f64; | ||
scope 1 { | ||
debug x => _1; | ||
} | ||
|
||
bb0: { | ||
StorageLive(_1); | ||
StorageLive(_2); | ||
_2 = const true; | ||
- switchInt(move _2) -> [0: bb2, otherwise: bb1]; | ||
+ goto -> bb1; | ||
} | ||
|
||
bb1: { | ||
_1 = const -0f64; | ||
goto -> bb3; | ||
} | ||
|
||
bb2: { | ||
_1 = const 1f64; | ||
goto -> bb3; | ||
} | ||
|
||
bb3: { | ||
StorageDead(_2); | ||
StorageLive(_3); | ||
StorageLive(_4); | ||
_4 = _1; | ||
_3 = Eq(move _4, const 0f64); | ||
switchInt(move _3) -> [0: bb5, otherwise: bb4]; | ||
} | ||
|
||
bb4: { | ||
StorageDead(_4); | ||
_0 = const 0_u32; | ||
goto -> bb6; | ||
} | ||
|
||
bb5: { | ||
StorageDead(_4); | ||
_0 = const 1_u32; | ||
goto -> bb6; | ||
} | ||
|
||
bb6: { | ||
StorageDead(_3); | ||
StorageDead(_1); | ||
return; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters