8000 Rollup of 7 pull requests by Centril · Pull Request #67426 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Rollup of 7 pull requests #67426

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

Closed
wants to merge 23 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3980342
Use structured suggestion for disambiguating method calls
estebank Dec 4, 2019
8c4f1d5
review comments
estebank Dec 12, 2019
6ad0b55
Remove now-redundant range check on u128 -> f32 casts
Dec 15, 2019
c6321a4
Add benchmarks for string::insert(_str)
llogiq Dec 13, 2019
c1241bf
add debuginfo in generator_interior
csmoe Oct 16, 2019
ff4f6a1
record previous unresolve span for generator error reporting
csmoe Oct 21, 2019
17aa0cb
Remove a const-if-hack in RawVec
mark-i-m Nov 25, 2019
3ec3fca
remove a bit more hackery
mark-i-m Nov 25, 2019
baaf864
use usize::MAX instead of !0
mark-i-m Nov 26, 2019
951f041
fix import
mark-i-m Nov 26, 2019
2535435
add fixme
mark-i-m Nov 26, 2019
7d26811
no need to bootstrap
mark-i-m Dec 18, 2019
35af4e2
Normalize identifiers in librustc_parse.
crlf0710 Nov 23, 2019
5a75934
Add a test and bless existing test case.
crlf0710 Nov 23, 2019
49f3bc9
Add unicode-normalization to whitelist.
crlf0710 Dec 19, 2019
bfc02bd
Fix documentation typo
LeSeulArtichaut Dec 19, 2019
02206dc
Rollup merge of #66670 - crlf0710:normalize_ident, r=estebank
Centril Dec 19, 2019
208f353
Rollup merge of #66755 - mark-i-m:const-vec-new, r=ecstatic-morse
Centril Dec 19, 2019
8c15656
Rollup merge of #67127 - estebank:disambiguate-suggestion, r=varkor
Centril Dec 19, 2019
4254d29
Rollup merge of #67281 - llogiq:nonoverlapping-insert, r=alexcrichton
Centril Dec 19, 2019
3d21aa6
Rollup merge of #67328 - rkruppe:simplify-u128-f32-cast, r=matthewjasper
Centril Dec 19, 2019
c014c45
Rollup merge of #67392 - csmoe:async-typeinfo, r=estebank
Centril Dec 19, 2019
4ff4d6c
Rollup merge of #67421 - LeSeulArtichaut:patch-1, r=Centril
Centril Dec 19, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove now-redundant range check on u128 -> f32 casts
This code was added to avoid UB in LLVM 6 and earlier, but we no longer support those LLVM versions.
Since https://reviews.llvm.org/D47807 (released in LLVM 7), uitofp does exactly what we need.

Closes #51872
  • Loading branch information
Robin Kruppe committed Dec 15, 2019
commit 6ad0b55597d58f65b775cc32588d5cb396993c0c
43 changes: 7 additions & 36 deletions src/librustc_codegen_ssa/mir/rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,13 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
llval
}
}
(CastTy::Int(_), CastTy::Float) => {
if signed {
bx.sitofp(llval, ll_t_out)
} else {
bx.uitofp(llval, ll_t_out)
}
}
(CastTy::Ptr(_), CastTy::Ptr(_)) |
(CastTy::FnPtr, CastTy::Ptr(_)) |
(CastTy::RPtr(_), CastTy::Ptr(_)) =>
Expand All @@ -352,8 +359,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
let usize_llval = bx.intcast(llval, bx.cx().type_isize(), signed);
bx.inttoptr(usize_llval, ll_t_out)
}
(CastTy::Int(_), CastTy::Float) =>
cast_int_to_float(&mut bx, signed, llval, ll_t_in, ll_t_out),
(CastTy::Float, CastTy::Int(IntTy::I)) =>
cast_float_to_int(&mut bx, true, llval, ll_t_in, ll_t_out),
(CastTy::Float, CastTy::Int(_)) =>
Expand Down Expand Up @@ -720,40 +725,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
}
}

fn cast_int_to_float<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx: &mut Bx,
signed: bool,
x: Bx::Value,
int_ty: Bx::Type,
float_ty: Bx::Type
) -> Bx::Value {
// Most integer types, even i128, fit into [-f32::MAX, f32::MAX] after rounding.
// It's only u128 -> f32 that can cause overflows (i.e., should yield infinity).
// LLVM's uitofp produces undef in those cases, so we manually check for that case.
let is_u128_to_f32 = !signed &&
bx.cx().int_width(int_ty) == 128 &&
bx.cx().float_width(float_ty) == 32;
if is_u128_to_f32 {
// All inputs greater or equal to (f32::MAX + 0.5 ULP) are rounded to infinity,
// and for everything else LLVM's uitofp works just fine.
use rustc_apfloat::ieee::Single;
const MAX_F32_PLUS_HALF_ULP: u128 = ((1 << (Single::PRECISION + 1)) - 1)
<< (Single::MAX_EXP - Single::PRECISION as i16);
let max = bx.cx().const_uint_big(int_ty, MAX_F32_PLUS_HALF_ULP);
let overflow = bx.icmp(IntPredicate::IntUGE, x, max);
let infinity_bits = bx.cx().const_u32(ieee::Single::INFINITY.to_bits() as u32);
let infinity = bx.bitcast(infinity_bits, float_ty);
let fp = bx.uitofp(x, float_ty);
bx.select(overflow, infinity, fp)
} else {
if signed {
bx.sitofp(x, float_ty)
} else {
bx.uitofp(x, float_ty)
}
}
}

fn cast_float_to_int<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx: &mut Bx,
signed: bool,
Expand Down
0