rust/src/librustc/mir
Nicholas Nethercote 5515a97646 Introduce a special case in IntRange::from_const.
The `if let Some(val) = value.try_eval_bits(...)` branch in `from_const()` is
very hot for the `unicode_normalization` benchmark.

This commit introduces a special-case alternative for scalars that avoids
`try_eval_bits()` and all the functions it calls (`Const::eval()`,
`ConstValue::try_to_bits()`, `ConstValue::try_to_scalar()`, and
`Scalar::to_bits()`), instead extracting the result immediately.

The type and value checking done by `Scalar::to_bits()` is replicated by moving
it into a new function `Scalar::check_raw()` and using that new function in the
special case.

PR #64673 introduced some special-case handling of scalar types in
`Const::try_eval_bits()`. This handling is now moved out of that function into
the new `IntRange::integral_size_and_signed_bias` function.

This commit reduces the instruction count for
`unicode_normalization-check-clean` by about 10%.
2019-10-04 17:03:41 +10:00
..
interpret Introduce a special case in IntRange::from_const. 2019-10-04 17:03:41 +10:00
cache.rs remove indexed_vec re-export from rustc_data_structures 2019-09-29 16:48:31 +00:00
mod.rs remove indexed_vec re-export from rustc_data_structures 2019-09-29 16:48:31 +00:00
mono.rs Switch over all StableHash impls to new format 2019-09-28 11:47:36 -04:00
tcx.rs Rename sty to kind 2019-09-25 15:50:04 +01:00
traversal.rs remove bit_set re-export from rustc_data_structures 2019-09-29 16:11:30 +00:00
visit.rs Make Place Boxed on Statement to reduce size from 64 bytes to 32 bytes 2019-09-11 16:28:06 -03:00