@@ -475,21 +475,13 @@ pub fn size_and_align_of_dst<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>, in
475
475
//
476
476
// `size + ((size & (align-1)) ? align : 0)`
477
477
//
478
- // Currently I am emulating the above via :
478
+ // emulated via the semi-standard fast bit trick :
479
479
//
480
- // `size + ((size & (align-1)) * align-(size & (align-1)))`
481
- //
482
- // because I am not sure which is cheaper between a branch
483
- // or a multiply.
484
-
485
- let mask = Sub ( bcx, align, C_uint ( bcx. ccx ( ) , 1_u64 ) , dbloc) ;
486
- let lowbits = And ( bcx, size, mask, DebugLoc :: None ) ;
487
- let nonzero = ICmp ( bcx, llvm:: IntNE , lowbits, C_uint ( bcx. ccx ( ) , 0_u64 ) , dbloc) ;
488
- let add_size = Mul ( bcx,
489
- ZExt ( bcx, nonzero, Type :: i64 ( bcx. ccx ( ) ) ) ,
490
- Sub ( bcx, align, lowbits, dbloc) ,
491
- dbloc) ;
492
- let size = Add ( bcx, size, add_size, dbloc) ;
480
+ // `(size + (align-1)) & !align`
481
+
482
+ let addend = Sub ( bcx, align, C_uint ( bcx. ccx ( ) , 1_u64 ) , dbloc) ;
483
+ let size = And (
484
+ bcx, Add ( bcx, size, addend, dbloc) , Neg ( bcx, align, dbloc) , dbloc) ;
493
485
494
486
( size, align)
495
487
}
0 commit comments