diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2023-02-01 13:55:28 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2023-02-01 13:55:28 +0000 |
| commit | df04fd6fba2e1b2b85a108e3ec7e56c731456ba9 (patch) | |
| tree | 28af2041f265868ec36fa0ae513fbb09f02bf83a | |
| parent | 79f4cc0822578199fa9ffee6f0abf909b8976ab9 (diff) | |
| download | rust-df04fd6fba2e1b2b85a108e3ec7e56c731456ba9.tar.gz rust-df04fd6fba2e1b2b85a108e3ec7e56c731456ba9.zip | |
Don't force many scalar pair values to the stack in write_cvalue_maybe_transmute
Sometimes it is necessary for handling vector to scalar pair transmutes, but if the types are the same there is no need for this. This improves runtime performance on simple-raytracer by 12%.
| -rw-r--r-- | src/abi/comments.rs | 4 | ||||
| -rw-r--r-- | src/value_and_place.rs | 11 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/abi/comments.rs b/src/abi/comments.rs index 7f4619b5c94..abf63e33c35 100644 --- a/src/abi/comments.rs +++ b/src/abi/comments.rs @@ -98,12 +98,12 @@ pub(super) fn add_local_place_comments<'tcx>( } CPlaceInner::VarPair(place_local, var1, var2) => { assert_eq!(local, place_local); - ("ssa", Cow::Owned(format!(",var=({}, {})", var1.index(), var2.index()))) + ("ssa", Cow::Owned(format!("var=({}, {})", var1.index(), var2.index()))) } CPlaceInner::VarLane(_local, _var, _lane) => unreachable!(), CPlaceInner::Addr(ptr, meta) => { let meta = if let Some(meta) = meta { - Cow::Owned(format!(",meta={}", meta)) + Cow::Owned(format!("meta={}", meta)) } else { Cow::Borrowed("") }; diff --git a/src/value_and_place.rs b/src/value_and_place.rs index fa06d6c3ba7..cc4493d442f 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -588,10 +588,13 @@ impl<'tcx> CPlace<'tcx> { return; } CPlaceInner::VarPair(_local, var1, var2) => { - let (ptr, meta) = from.force_stack(fx); - assert!(meta.is_none()); - let (data1, data2) = - CValue(CValueInner::ByRef(ptr, None), dst_layout).load_scalar_pair(fx); + let (data1, data2) = if self.layout().ty == dst_layout.ty { + CValue(from.0, dst_layout).load_scalar_pair(fx) + } else { + let (ptr, meta) = from.force_stack(fx); + assert!(meta.is_none()); + CValue(CValueInner::ByRef(ptr, None), dst_layout).load_scalar_pair(fx) + }; let (dst_ty1, dst_ty2) = fx.clif_pair_type(self.layout().ty).unwrap(); transmute_value(fx, var1, data1, dst_ty1); transmute_value(fx, var2, data2, dst_ty2); |
