Skip to content

Commit ff234bf

Browse files
committed
---
yaml --- r: 229185 b: refs/heads/try c: 21be094 h: refs/heads/master i: 229183: 80eba7c v: v3
1 parent 935272b commit ff234bf

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: aca2057ed5fb7af3f8905b2bc01f72fa001c35c8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: 26f4ebe7a0b166cbfb04f6e8df16cb799f81058b
4+
refs/heads/try: 21be09448b21c25570f28ddd597f3d30ccc6fabf
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/librustc_trans/trans/glue.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -475,21 +475,13 @@ pub fn size_and_align_of_dst<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>, in
475475
//
476476
// `size + ((size & (align-1)) ? align : 0)`
477477
//
478-
// Currently I am emulating the above via:
478+
// emulated via the semi-standard fast bit trick:
479479
//
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);
493485

494486
(size, align)
495487
}

0 commit comments

Comments
 (0)