Skip to content
  • Chris Lattner's avatar
    _test: · a6764839
    Chris Lattner authored
            li r2, 0
    LBB_test_1:     ; no_exit.2
            li r5, 0
            stw r5, 0(r3)
            addi r2, r2, 1
            addi r3, r3, 4
            cmpwi cr0, r2, 701
            blt cr0, LBB_test_1     ; no_exit.2
    LBB_test_2:     ; loopexit.2.loopexit
            addi r2, r2, 1
            stw r2, 0(r4)
            blr
    [zion ~/llvm]$ cat > ~/xx
    Uses of IV's outside of the loop should use hte post-incremented version
    of the IV, not the preincremented version.  This helps many loops (e.g. in sixtrack)
    which used to generate code like this (this is the code from the
    dont-hoist-simple-loop-constants.ll testcase):
    
    _test:
            li r2, 0                 **** IV starts at 0
    LBB_test_1:     ; no_exit.2
            or r5, r2, r2            **** Copy for loop exit
            li r2, 0
            stw r2, 0(r3)
            addi r3, r3, 4
            addi r2, r5, 1
            addi r6, r5, 2           **** IV+2
            cmpwi cr0, r6, 701
            blt cr0, LBB_test_1     ; no_exit.2
    LBB_test_2:     ; loopexit.2.loopexit
            addi r2, r5, 2       ****  IV+2
            stw r2, 0(r4)
            blr
    
    And now generated code like this:
    
    _test:
            li r2, 1               *** IV starts at 1
    LBB_test_1:     ; no_exit.2
            li r5, 0
            stw r5, 0(r3)
            addi r2, r2, 1
            addi r3, r3, 4
            cmpwi cr0, r2, 701     *** IV.postinc + 0
            blt cr0, LBB_test_1
    LBB_test_2:     ; loopexit.2.loopexit
            stw r2, 0(r4)          *** IV.postinc + 0
            blr
    
    llvm-svn: 23313
    a6764839
Loading