about summary refs log tree commit diff
path: root/src/test/codegen
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-05-06 16:58:50 +0200
committerGitHub <noreply@github.com>2020-05-06 16:58:50 +0200
commit14d608f1d8a0b84da5f3bccecb3efb3d35f980dc (patch)
treebb359957d2ab7197b0179d8f59310da9c1108520 /src/test/codegen
parent339f574809bf8e4166b8de3cdbe7df181d37af3d (diff)
parentf63b8bffefb0f652dc164859f4c8a10329c9117a (diff)
downloadrust-14d608f1d8a0b84da5f3bccecb3efb3d35f980dc.tar.gz
rust-14d608f1d8a0b84da5f3bccecb3efb3d35f980dc.zip
Rollup merge of #71269 - Mark-Simulacrum:sat-float-casts, r=nikic
Define UB in float-to-int casts to saturate

This closes #10184 by defining the behavior there to saturate infinities and values exceeding the integral range (on the lower or upper end). `NaN` is sent to zero.
Diffstat (limited to 'src/test/codegen')
-rw-r--r--src/test/codegen/unchecked-float-casts.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/test/codegen/unchecked-float-casts.rs b/src/test/codegen/unchecked-float-casts.rs
index 34e96122223..789feea12d6 100644
--- a/src/test/codegen/unchecked-float-casts.rs
+++ b/src/test/codegen/unchecked-float-casts.rs
@@ -1,7 +1,7 @@
-// compile-flags: -C no-prepopulate-passes
+// This file tests that we don't generate any code for saturation when using the
+// unchecked intrinsics.
 
-// This file tests that we don't generate any code for saturation if
-// -Z saturating-float-casts is not enabled.
+// compile-flags: -C opt-level=3
 
 #![crate_type = "lib"]
 
@@ -12,7 +12,7 @@ pub fn f32_to_u32(x: f32) -> u32 {
     // CHECK-NOT: fcmp
     // CHECK-NOT: icmp
     // CHECK-NOT: select
-    x as u32
+    unsafe { x.to_int_unchecked() }
 }
 
 // CHECK-LABEL: @f32_to_i32
@@ -22,7 +22,7 @@ pub fn f32_to_i32(x: f32) -> i32 {
     // CHECK-NOT: fcmp
     // CHECK-NOT: icmp
     // CHECK-NOT: select
-    x as i32
+    unsafe { x.to_int_unchecked() }
 }
 
 #[no_mangle]
@@ -31,5 +31,5 @@ pub fn f64_to_u16(x: f64) -> u16 {
     // CHECK-NOT: fcmp
     // CHECK-NOT: icmp
     // CHECK-NOT: select
-    x as u16
+    unsafe { x.to_int_unchecked() }
 }