summaryrefslogtreecommitdiff
path: root/compiler/rustc_mir_transform/src/jump_threading.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_mir_transform/src/jump_threading.rs')
-rw-r--r--compiler/rustc_mir_transform/src/jump_threading.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/rustc_mir_transform/src/jump_threading.rs b/compiler/rustc_mir_transform/src/jump_threading.rs
index 23cc0c46e73..279fd614918 100644
--- a/compiler/rustc_mir_transform/src/jump_threading.rs
+++ b/compiler/rustc_mir_transform/src/jump_threading.rs
@@ -494,6 +494,13 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
BinOp::Ne => ScalarInt::FALSE,
_ => return None,
};
+ if value.const_.ty().is_floating_point() {
+ // Floating point equality does not follow bit-patterns.
+ // -0.0 and NaN both have special rules for equality,
+ // and therefore we cannot use integer comparisons for them.
+ // Avoid handling them, though this could be extended in the future.
+ return None;
+ }
let value = value.const_.normalize(self.tcx, self.param_env).try_to_scalar_int()?;
let conds = conditions.map(self.arena, |c| Condition {
value,