@@ -364,101 +364,101 @@ impl<'a, F: Function> Env<'a, F> {
364364 }
365365
366366 block = block. next ( ) ;
367+ }
367368
368- // Scan over blocks whose beginnings are covered by
369- // this range and for which the vreg is live at the
370- // start of the block. For each, for each predecessor,
371- // add a Dest half-move.
372- let mut block = self . cfginfo . insn_block [ range. from . inst ( ) . index ( ) ] ;
373- if self . cfginfo . block_entry [ block. index ( ) ] < range. from {
374- block = block. next ( ) ;
369+ // Scan over blocks whose beginnings are covered by
370+ // this range and for which the vreg is live at the
371+ // start of the block. For each, for each predecessor,
372+ // add a Dest half-move.
373+ let mut block = self . cfginfo . insn_block [ range. from . inst ( ) . index ( ) ] ;
374+ if self . cfginfo . block_entry [ block. index ( ) ] < range. from {
375+ block = block. next ( ) ;
376+ }
377+ while block. is_valid ( ) && block. index ( ) < self . func . num_blocks ( ) {
378+ if self . cfginfo . block_entry [ block. index ( ) ] >= range. to {
379+ break ;
375380 }
376- while block. is_valid ( ) && block. index ( ) < self . func . num_blocks ( ) {
377- if self . cfginfo . block_entry [ block. index ( ) ] >= range. to {
381+
382+ // Add half-moves for blockparam inputs.
383+ trace ! (
384+ "scanning blockparam_ins at vreg {} block {}: blockparam_in_idx = {}" ,
385+ vreg. index( ) ,
386+ block. index( ) ,
387+ blockparam_in_idx
388+ ) ;
389+ while blockparam_in_idx < self . blockparam_ins . len ( ) {
390+ let BlockparamIn {
391+ from_block,
392+ to_block,
393+ to_vreg,
394+ } = self . blockparam_ins [ blockparam_in_idx] ;
395+ if ( to_vreg, to_block) > ( vreg, block) {
378396 break ;
379397 }
380-
381- // Add half-moves for blockparam inputs.
382- trace ! (
383- "scanning blockparam_ins at vreg {} block {}: blockparam_in_idx = {}" ,
384- vreg. index( ) ,
385- block. index( ) ,
386- blockparam_in_idx
387- ) ;
388- while blockparam_in_idx < self . blockparam_ins . len ( ) {
389- let BlockparamIn {
390- from_block,
391- to_block,
392- to_vreg,
393- } = self . blockparam_ins [ blockparam_in_idx] ;
394- if ( to_vreg, to_block) > ( vreg, block) {
395- break ;
396- }
397- if ( to_vreg, to_block) == ( vreg, block) {
398- half_moves. push ( HalfMove {
399- key : half_move_key (
400- from_block,
401- to_block,
402- to_vreg,
403- HalfMoveKind :: Dest ,
398+ if ( to_vreg, to_block) == ( vreg, block) {
399+ half_moves. push ( HalfMove {
400+ key : half_move_key (
401+ from_block,
402+ to_block,
403+ to_vreg,
404+ HalfMoveKind :: Dest ,
405+ ) ,
406+ alloc,
407+ } ) ;
408+ trace ! (
409+ "match: blockparam_in: v{} in block{} from block{} into {}" ,
410+ to_vreg. index( ) ,
411+ to_block. index( ) ,
412+ from_block. index( ) ,
413+ alloc,
414+ ) ;
415+ #[ cfg( debug_assertions) ]
416+ if self . annotations_enabled {
417+ self . annotate (
418+ self . cfginfo . block_entry [ block. index ( ) ] ,
419+ format ! (
420+ "blockparam-in: block{} to block{}:into v{} in {}" ,
421+ from_block. index( ) ,
422+ to_block. index( ) ,
423+ to_vreg. index( ) ,
424+ alloc
404425 ) ,
405- alloc,
406- } ) ;
407- trace ! (
408- "match: blockparam_in: v{} in block{} from block{} into {}" ,
409- to_vreg. index( ) ,
410- to_block. index( ) ,
411- from_block. index( ) ,
412- alloc,
413426 ) ;
414- #[ cfg( debug_assertions) ]
415- if self . annotations_enabled {
416- self . annotate (
417- self . cfginfo . block_entry [ block. index ( ) ] ,
418- format ! (
419- "blockparam-in: block{} to block{}:into v{} in {}" ,
420- from_block. index( ) ,
421- to_block. index( ) ,
422- to_vreg. index( ) ,
423- alloc
424- ) ,
425- ) ;
426- }
427427 }
428- blockparam_in_idx += 1 ;
429428 }
429+ blockparam_in_idx += 1 ;
430+ }
430431
431- if !self . is_live_in ( block, vreg) {
432- block = block. next ( ) ;
433- continue ;
434- }
432+ if !self . is_live_in ( block, vreg) {
433+ block = block. next ( ) ;
434+ continue ;
435+ }
436+
437+ trace ! (
438+ "scanning preds at vreg {} block {} for ends outside the range" ,
439+ vreg. index( ) ,
440+ block. index( )
441+ ) ;
435442
443+ // Now find any preds whose ends are not in the
444+ // same range, and insert appropriate moves.
445+ for & pred in self . func . block_preds ( block) {
436446 trace ! (
437- "scanning preds at vreg {} block {} for ends outside the range " ,
438- vreg . index( ) ,
439- block . index( )
447+ "pred block {} has exit {:?} " ,
448+ pred . index( ) ,
449+ self . cfginfo . block_exit [ pred . index( ) ]
440450 ) ;
441-
442- // Now find any preds whose ends are not in the
443- // same range, and insert appropriate moves.
444- for & pred in self . func . block_preds ( block) {
445- trace ! (
446- "pred block {} has exit {:?}" ,
447- pred. index( ) ,
448- self . cfginfo. block_exit[ pred. index( ) ]
449- ) ;
450- if range. contains_point ( self . cfginfo . block_exit [ pred. index ( ) ] ) {
451- continue ;
452- }
453- trace ! ( " -> requires half-move" ) ;
454- half_moves. push ( HalfMove {
455- key : half_move_key ( pred, block, vreg, HalfMoveKind :: Dest ) ,
456- alloc,
457- } ) ;
451+ if range. contains_point ( self . cfginfo . block_exit [ pred. index ( ) ] ) {
452+ continue ;
458453 }
459-
460- block = block. next ( ) ;
454+ trace ! ( " -> requires half-move" ) ;
455+ half_moves. push ( HalfMove {
456+ key : half_move_key ( pred, block, vreg, HalfMoveKind :: Dest ) ,
457+ alloc,
458+ } ) ;
461459 }
460+
461+ block = block. next ( ) ;
462462 }
463463
464464 // Scan over def/uses and apply allocations.
0 commit comments