Do not generate assumes for plain integer casts

This commit is contained in:
Simonas Kazlauskas 2018-08-12 15:27:03 +03:00
parent 0aa8d03202
commit dc02a6070f
3 changed files with 42 additions and 2 deletions

View file

@ -304,7 +304,9 @@ impl FunctionCx<'a, 'll, 'tcx> {
// then `i1 1` (i.e. E::B) is effectively `i8 -1`.
signed = !scalar.is_bool() && s;
if scalar.valid_range.end() > scalar.valid_range.start() {
let er = scalar.valid_range_exclusive(bx.cx);
if er.end != er.start &&
scalar.valid_range.end() > scalar.valid_range.start() {
// We want `table[e as usize]` to not
// have bound checks, and this is the most
// convenient place to put the `assume`.