@@ -426,49 +426,26 @@ pub fn iter_vec_loop<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
426
426
let _icx = push_ctxt ( "tvec::iter_vec_loop" ) ;
427
427
let fcx = bcx. fcx ;
428
428
429
- let next_bcx = fcx. new_temp_block ( "expr_repeat: while next" ) ;
430
429
let loop_bcx = fcx. new_temp_block ( "expr_repeat" ) ;
431
- let cond_bcx = fcx. new_temp_block ( "expr_repeat: loop cond" ) ;
432
- let body_bcx = fcx. new_temp_block ( "expr_repeat: body: set" ) ;
433
- let inc_bcx = fcx. new_temp_block ( "expr_repeat: body: inc" ) ;
434
- Br ( bcx, loop_bcx. llbb , DebugLoc :: None ) ;
430
+ let next_bcx = fcx. new_temp_block ( "expr_repeat: next" ) ;
435
431
436
- let loop_counter = {
437
- // i = 0
438
- let i = alloca ( loop_bcx, bcx. ccx ( ) . int_type ( ) , "__i" ) ;
439
- Store ( loop_bcx, C_uint ( bcx. ccx ( ) , 0 us) , i) ;
432
+ Br ( bcx, loop_bcx. llbb , DebugLoc :: None ) ;
440
433
441
- Br ( loop_bcx, cond_bcx. llbb , DebugLoc :: None ) ;
442
- i
443
- } ;
434
+ let loop_counter = Phi ( loop_bcx, bcx. ccx ( ) . int_type ( ) , & [ C_uint ( bcx. ccx ( ) , 0 us) ] , & [ bcx. llbb ] ) ;
444
435
445
- { // i < count
446
- let lhs = Load ( cond_bcx, loop_counter) ;
447
- let rhs = count;
448
- let cond_val = ICmp ( cond_bcx, llvm:: IntULT , lhs, rhs, DebugLoc :: None ) ;
436
+ let bcx = loop_bcx;
449
437
450
- CondBr ( cond_bcx, cond_val, body_bcx. llbb , next_bcx. llbb , DebugLoc :: None ) ;
451
- }
452
-
453
- { // loop body
454
- let i = Load ( body_bcx, loop_counter) ;
455
- let lleltptr = if vt. llunit_alloc_size == 0 {
456
- data_ptr
457
- } else {
458
- InBoundsGEP ( body_bcx, data_ptr, & [ i] )
459
- } ;
460
- let body_bcx = f ( body_bcx, lleltptr, vt. unit_ty ) ;
461
-
462
- Br ( body_bcx, inc_bcx. llbb , DebugLoc :: None ) ;
463
- }
464
-
465
- { // i += 1
466
- let i = Load ( inc_bcx, loop_counter) ;
467
- let plusone = Add ( inc_bcx, i, C_uint ( bcx. ccx ( ) , 1 us) , DebugLoc :: None ) ;
468
- Store ( inc_bcx, plusone, loop_counter) ;
438
+ let lleltptr = if vt. llunit_alloc_size == 0 {
439
+ data_ptr
440
+ } else {
441
+ InBoundsGEP ( bcx, data_ptr, & [ loop_counter] )
442
+ } ;
443
+ let bcx = f ( bcx, lleltptr, vt. unit_ty ) ;
444
+ let plusone = Add ( bcx, loop_counter, C_uint ( bcx. ccx ( ) , 1 us) , DebugLoc :: None ) ;
445
+ AddIncomingToPhi ( loop_counter, plusone, bcx. llbb ) ;
469
446
470
- Br ( inc_bcx , cond_bcx . llbb , DebugLoc :: None ) ;
471
- }
447
+ let cond_val = ICmp ( bcx , llvm :: IntULT , plusone , count , DebugLoc :: None ) ;
448
+ CondBr ( bcx , cond_val , loop_bcx . llbb , next_bcx . llbb , DebugLoc :: None ) ;
472
449
473
450
next_bcx
474
451
}
0 commit comments