@@ -572,8 +572,6 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
572
572
) {
573
573
let zero = self . const_usize ( 0 ) ;
574
574
let count = self . const_usize ( count) ;
575
- let start = dest. project_index ( self , zero) . llval ;
576
- let end = dest. project_index ( self , count) . llval ;
577
575
578
576
let header_bb = self . append_sibling_block ( "repeat_loop_header" ) ;
579
577
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> {
582
580
self . br ( header_bb) ;
583
581
584
582
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 ( ) ] ) ;
586
584
587
- let keep_going = header_bx. icmp ( IntPredicate :: IntNE , current , end ) ;
585
+ let keep_going = header_bx. icmp ( IntPredicate :: IntULT , i , count ) ;
588
586
header_bx. cond_br ( keep_going, body_bb, next_bb) ;
589
587
590
588
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 ) ) ;
601
593
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) ;
603
595
604
596
* self = Self :: build ( self . cx , next_bb) ;
605
597
}
0 commit comments