@@ -572,8 +572,6 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
572572 ) {
573573 let zero = self . const_usize ( 0 ) ;
574574 let count = self . const_usize ( count) ;
575- let start = dest. project_index ( self , zero) . llval ;
576- let end = dest. project_index ( self , count) . llval ;
577575
578576 let header_bb = self . append_sibling_block ( "repeat_loop_header" ) ;
579577 let body_bb = self . append_sibling_block ( "repeat_loop_body" ) ;
@@ -582,24 +580,18 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
582580 self . br ( header_bb) ;
583581
584582 let mut header_bx = Self :: build ( self . cx , header_bb) ;
585- let current = header_bx. phi ( self . val_ty ( start ) , & [ start ] , & [ self . llbb ( ) ] ) ;
583+ let i = header_bx. phi ( self . val_ty ( zero ) , & [ zero ] , & [ self . llbb ( ) ] ) ;
586584
587- let keep_going = header_bx. icmp ( IntPredicate :: IntNE , current , end ) ;
585+ let keep_going = header_bx. icmp ( IntPredicate :: IntULT , i , count ) ;
588586 header_bx. cond_br ( keep_going, body_bb, next_bb) ;
589587
590588 let mut body_bx = Self :: build ( self . cx , body_bb) ;
591- let align = dest. align . restrict_for_offset ( dest. layout . field ( self . cx ( ) , 0 ) . size ) ;
592- cg_elem
593- . val
594- . store ( & mut body_bx, PlaceRef :: new_sized_aligned ( current, cg_elem. layout , align) ) ;
595-
596- let next = body_bx. inbounds_gep (
597- self . backend_type ( cg_elem. layout ) ,
598- current,
599- & [ self . const_usize ( 1 ) ] ,
600- ) ;
589+ let dest_elem = dest. project_index ( & mut body_bx, i) ;
590+ cg_elem. val . store ( & mut body_bx, dest_elem) ;
591+
592+ let next = body_bx. unchecked_uadd ( i, self . const_usize ( 1 ) ) ;
601593 body_bx. br ( header_bb) ;
602- header_bx. add_incoming_to_phi ( current , next, body_bb) ;
594+ header_bx. add_incoming_to_phi ( i , next, body_bb) ;
603595
604596 * self = Self :: build ( self . cx , next_bb) ;
605597 }
0 commit comments