@@ -1461,14 +1461,35 @@ pub fn trans_adt<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
1461
1461
None => { }
1462
1462
} ;
1463
1463
1464
- // Now, we just overwrite the fields we've explicitly specified
1465
- for & ( i, ref e) in fields. iter ( ) {
1466
- let dest = adt:: trans_field_ptr ( bcx, & * repr, addr, discr, i) ;
1467
- let e_ty = expr_ty_adjusted ( bcx, & * * e) ;
1468
- bcx = trans_into ( bcx, & * * e, SaveIn ( dest) ) ;
1469
- let scope = cleanup:: CustomScope ( custom_cleanup_scope) ;
1470
- fcx. schedule_lifetime_end ( scope, dest) ;
1471
- fcx. schedule_drop_mem ( scope, dest, e_ty) ;
1464
+ if ty:: type_is_simd ( bcx. tcx ( ) , ty) {
1465
+ // This is the constructor of a SIMD type, such types are
1466
+ // always primitive machine types and so do not have a
1467
+ // destructor or require any clean-up.
1468
+ let llty = type_of:: type_of ( bcx. ccx ( ) , ty) ;
1469
+
1470
+ // keep a vector as a register, and running through the field
1471
+ // `insertelement`ing them directly into that register
1472
+ // (i.e. avoid GEPi and `store`s to an alloca) .
1473
+ let mut vec_val = C_undef ( llty) ;
1474
+
1475
+ for & ( i, ref e) in fields. iter ( ) {
1476
+ let block_datum = trans ( bcx, & * * e) ;
1477
+ bcx = block_datum. bcx ;
1478
+ let position = C_uint ( bcx. ccx ( ) , i) ;
1479
+ let value = block_datum. datum . to_llscalarish ( bcx) ;
1480
+ vec_val = InsertElement ( bcx, vec_val, value, position) ;
1481
+ }
1482
+ Store ( bcx, vec_val, addr) ;
1483
+ } else {
1484
+ // Now, we just overwrite the fields we've explicitly specified
1485
+ for & ( i, ref e) in fields. iter ( ) {
1486
+ let dest = adt:: trans_field_ptr ( bcx, & * repr, addr, discr, i) ;
1487
+ let e_ty = expr_ty_adjusted ( bcx, & * * e) ;
1488
+ bcx = trans_into ( bcx, & * * e, SaveIn ( dest) ) ;
1489
+ let scope = cleanup:: CustomScope ( custom_cleanup_scope) ;
1490
+ fcx. schedule_lifetime_end ( scope, dest) ;
1491
+ fcx. schedule_drop_mem ( scope, dest, e_ty) ;
1492
+ }
1472
1493
}
1473
1494
1474
1495
adt:: trans_set_discr ( bcx, & * repr, addr, discr) ;
0 commit comments