- for uint::range(0, count) |i| {
- let lleltptr = GEPi(bcx, lldest, [i]);
- if i < count - 1 {
- // Copy all but the last one in.
- bcx = tmpdatum.copy_to(bcx, INIT, lleltptr);
- } else {
- // Move the last one in.
- bcx = tmpdatum.move_to(bcx, INIT, lleltptr);
- }
- add_clean_temp_mem(bcx, lleltptr, vt.unit_ty);
- temp_cleanups.push(lleltptr);
+ let loop_counter = {
+ // i = 0
+ let i = alloca(loop_bcx, T_i64());
+ Store(loop_bcx, C_i64(0), i);
+
+ Br(loop_bcx, cond_bcx.llbb);
+ i
+ };
+
+ { // i < count
+ let lhs = Load(cond_bcx, loop_counter);
+ let rhs = C_integral(T_i64(), count as u64, lib::llvm::False);
+ let cmp_lr = ICmp(cond_bcx, lib::llvm::IntULT, lhs, rhs);
+ let zext = ZExt(cond_bcx, cmp_lr, T_i8());
+ let cond_val = ICmp(cond_bcx, lib::llvm::IntNE, zext, C_u8(0));
+
+ CondBr(cond_bcx, cond_val, set_bcx.llbb, next_bcx.llbb);