Skip to content

Commit df04fd6

Browse files
committed
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%.
1 parent 79f4cc0 commit df04fd6

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/abi/comments.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ pub(super) fn add_local_place_comments<'tcx>(
9898
}
9999
CPlaceInner::VarPair(place_local, var1, var2) => {
100100
assert_eq!(local, place_local);
101-
("ssa", Cow::Owned(format!(",var=({}, {})", var1.index(), var2.index())))
101+
("ssa", Cow::Owned(format!("var=({}, {})", var1.index(), var2.index())))
102102
}
103103
CPlaceInner::VarLane(_local, _var, _lane) => unreachable!(),
104104
CPlaceInner::Addr(ptr, meta) => {
105105
let meta = if let Some(meta) = meta {
106-
Cow::Owned(format!(",meta={}", meta))
106+
Cow::Owned(format!("meta={}", meta))
107107
} else {
108108
Cow::Borrowed("")
109109
};

src/value_and_place.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -588,10 +588,13 @@ impl<'tcx> CPlace<'tcx> {
588588
return;
589589
}
590590
CPlaceInner::VarPair(_local, var1, var2) => {
591-
let (ptr, meta) = from.force_stack(fx);
592-
assert!(meta.is_none());
593-
let (data1, data2) =
594-
CValue(CValueInner::ByRef(ptr, None), dst_layout).load_scalar_pair(fx);
591+
let (data1, data2) = if self.layout().ty == dst_layout.ty {
592+
CValue(from.0, dst_layout).load_scalar_pair(fx)
593+
} else {
594+
let (ptr, meta) = from.force_stack(fx);
595+
assert!(meta.is_none());
596+
CValue(CValueInner::ByRef(ptr, None), dst_layout).load_scalar_pair(fx)
597+
};
595598
let (dst_ty1, dst_ty2) = fx.clif_pair_type(self.layout().ty).unwrap();
596599
transmute_value(fx, var1, data1, dst_ty1);
597600
transmute_value(fx, var2, data2, dst_ty2);

0 commit comments

Comments
 (0)