Skip to content
  • Chris Lattner's avatar
    Fix a FIXME: if we are inserting code for a PHI argument, split the critical · 4fec86d3
    Chris Lattner authored
    edge so that the code is not always executed for both operands.  This
    prevents LSR from inserting code into loops whose exit blocks contain
    PHI uses of IV expressions (which are outside of loops).  On gzip, for
    example, we turn this ugly code:
    
    .LBB_test_1:    ; loopentry
            add r27, r3, r28
            lhz r27, 3(r27)
            add r26, r4, r28
            lhz r26, 3(r26)
            add r25, r30, r28    ;; Only live if exiting the loop
            add r24, r29, r28    ;; Only live if exiting the loop
            cmpw cr0, r27, r26
            bne .LBB_test_5 ; loopexit
    
    into this:
    
    .LBB_test_1:    ; loopentry
            or r27, r28, r28
            add r28, r3, r27
            lhz r28, 3(r28)
            add r26, r4, r27
            lhz r26, 3(r26)
            cmpw cr0, r28, r26
            beq .LBB_test_3 ; shortcirc_next.0
    .LBB_test_2:    ; loopentry.loopexit_crit_edge
            add r2, r30, r27
            add r8, r29, r27
            b .LBB_test_9   ; loopexit
    .LBB_test_2:    ; shortcirc_next.0
            ...
            blt .LBB_test_1
    
    
    into this:
    
    .LBB_test_1:    ; loopentry
            or r27, r28, r28
            add r28, r3, r27
            lhz r28, 3(r28)
            add r26, r4, r27
            lhz r26, 3(r26)
            cmpw cr0, r28, r26
            beq .LBB_test_3 ; shortcirc_next.0
    .LBB_test_2:    ; loopentry.loopexit_crit_edge
            add r2, r30, r27
            add r8, r29, r27
            b .LBB_t_3:    ; shortcirc_next.0
    .LBB_test_3:    ; shortcirc_next.0
            ...
            blt .LBB_test_1
    
    
    Next step: get the block out of the loop so that the loop is all
    fall-throughs again.
    
    llvm-svn: 22766
    4fec86d3
Loading