Skip to content
  • Chris Lattner's avatar
    Implement a simple optimization for the termination condition of the loop. · 9bfa6f87
    Chris Lattner authored
    The termination condition actually wants to use the post-incremented value
    of the loop, not a new indvar with an unusual base.
    
    On PPC, for example, this allows us to compile
    LoopStrengthReduce/exit_compare_live_range.ll to:
    
    _foo:
            li r2, 0
    .LBB_foo_1:     ; no_exit
            li r5, 0
            stw r5, 0(r3)
            addi r2, r2, 1
            cmpw cr0, r2, r4
            bne .LBB_foo_1  ; no_exit
            blr
    
    instead of:
    
    _foo:
            li r2, 1                ;; IV starts at 1, not 0
    .LBB_foo_1:     ; no_exit
            li r5, 0
            stw r5, 0(r3)
            addi r5, r2, 1
            cmpw cr0, r2, r4
            or r2, r5, r5           ;; Reg-reg copy, extra live range
            bne .LBB_foo_1  ; no_exit
            blr
    
    This implements LoopStrengthReduce/exit_compare_live_range.ll
    
    llvm-svn: 22699
    9bfa6f87
Loading