Copy 1-element arrays as scalars, not vectors
For `[T; 1]` it's silly to copy as `<1 x T>` when we can just copy as `T`.
This commit is contained in:
parent
579be69de9
commit
ae9cec5839
4 changed files with 80 additions and 1 deletions
|
@ -397,7 +397,12 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
|
|||
// extracts all the individual values.
|
||||
|
||||
let ety = element.llvm_type(cx);
|
||||
return Some(cx.type_vector(ety, *count));
|
||||
if *count == 1 {
|
||||
// Emitting `<1 x T>` would be silly; just use the scalar.
|
||||
return Some(ety);
|
||||
} else {
|
||||
return Some(cx.type_vector(ety, *count));
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: The above only handled integer arrays; surely more things
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue