diff options
| author | bors <bors@rust-lang.org> | 2020-07-02 23:18:15 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-07-02 23:18:15 +0000 |
| commit | 5f4abc16e1b2cb035eee6a5079ce45ce924c1f33 (patch) | |
| tree | 327e15fe3a91f01c5b4cf23b2a31366b384e97bd /src/librustc_codegen_ssa | |
| parent | 3503f565e1fb7296983757d2716346f48a4a262b (diff) | |
| parent | 7bd2f97cb61d4578ac55d54bfdfc7c4ade752374 (diff) | |
Auto merge of #73977 - Manishearth:rollup-2x4s7c6, r=Manishearth
Rollup of 8 pull requests Successful merges: - #73454 (Move contributing.md to rustc-dev-guide and point at getting started) - #73724 (Use WASM's saturating casts if they are available) - #73726 (resolve: disallow labelled breaks/continues through closures/async blocks) - #73753 (Use 'tcx for references to AccessLevels wherever possible.) - #73781 (Update psm version) - #73952 (Add option for local docker testing.) - #73957 (disable BTree min_max test in Miri for now) - #73975 (Document rustc_ast::ast::Pat) Failed merges: r? @ghost
Diffstat (limited to 'src/librustc_codegen_ssa')
| -rw-r--r-- | src/librustc_codegen_ssa/mir/rvalue.rs | 11 | ||||
| -rw-r--r-- | src/librustc_codegen_ssa/traits/builder.rs | 2 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/librustc_codegen_ssa/mir/rvalue.rs b/src/librustc_codegen_ssa/mir/rvalue.rs index 57f72b1065d..4b2be7b5321 100644 --- a/src/librustc_codegen_ssa/mir/rvalue.rs +++ b/src/librustc_codegen_ssa/mir/rvalue.rs @@ -774,12 +774,17 @@ fn cast_float_to_int<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( float_ty: Bx::Type, int_ty: Bx::Type, ) -> Bx::Value { - let fptosui_result = if signed { bx.fptosi(x, int_ty) } else { bx.fptoui(x, int_ty) }; - if let Some(false) = bx.cx().sess().opts.debugging_opts.saturating_float_casts { - return fptosui_result; + return if signed { bx.fptosi(x, int_ty) } else { bx.fptoui(x, int_ty) }; + } + + let try_sat_result = if signed { bx.fptosi_sat(x, int_ty) } else { bx.fptoui_sat(x, int_ty) }; + if let Some(try_sat_result) = try_sat_result { + return try_sat_result; } + let fptosui_result = if signed { bx.fptosi(x, int_ty) } else { bx.fptoui(x, int_ty) }; + let int_width = bx.cx().int_width(int_ty); let float_width = bx.cx().float_width(float_ty); // LLVM's fpto[su]i returns undef when the input x is infinite, NaN, or does not fit into the diff --git a/src/librustc_codegen_ssa/traits/builder.rs b/src/librustc_codegen_ssa/traits/builder.rs index 994d8e0395d..65eb70e173e 100644 --- a/src/librustc_codegen_ssa/traits/builder.rs +++ b/src/librustc_codegen_ssa/traits/builder.rs @@ -158,6 +158,8 @@ pub trait BuilderMethods<'a, 'tcx>: fn trunc(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; fn sext(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + fn fptoui_sat(&mut self, val: Self::Value, dest_ty: Self::Type) -> Option<Self::Value>; + fn fptosi_sat(&mut self, val: Self::Value, dest_ty: Self::Type) -> Option<Self::Value>; fn fptoui(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; fn fptosi(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; fn uitofp(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; |
