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