llvm-6502/lib/Transforms/Scalar
Chris Lattner 5e8ca66914 Make IVUseShouldUsePostIncValue more aggressive when the use is a PHI. In
particular, it should realize that phi's use their values in the pred block
not the phi block itself.  This change turns our em3d loop from this:

_test:
        cmpwi cr0, r4, 0
        bgt cr0, LBB_test_2     ; entry.no_exit_crit_edge
LBB_test_1:     ; entry.loopexit_crit_edge
        li r2, 0
        b LBB_test_6    ; loopexit
LBB_test_2:     ; entry.no_exit_crit_edge
        li r6, 0
LBB_test_3:     ; no_exit
        or r2, r6, r6
        lwz r6, 0(r3)
        cmpw cr0, r6, r5
        beq cr0, LBB_test_6     ; loopexit
LBB_test_4:     ; endif
        addi r3, r3, 4
        addi r6, r2, 1
        cmpw cr0, r6, r4
        blt cr0, LBB_test_3     ; no_exit
LBB_test_5:     ; endif.loopexit.loopexit_crit_edge
        addi r3, r2, 1
        blr
LBB_test_6:     ; loopexit
        or r3, r2, r2
        blr

into:

_test:
        cmpwi cr0, r4, 0
        bgt cr0, LBB_test_2     ; entry.no_exit_crit_edge
LBB_test_1:     ; entry.loopexit_crit_edge
        li r2, 0
        b LBB_test_5    ; loopexit
LBB_test_2:     ; entry.no_exit_crit_edge
        li r6, 0
LBB_test_3:     ; no_exit
        lwz r2, 0(r3)
        cmpw cr0, r2, r5
        or r2, r6, r6
        beq cr0, LBB_test_5     ; loopexit
LBB_test_4:     ; endif
        addi r3, r3, 4
        addi r6, r6, 1
        cmpw cr0, r6, r4
        or r2, r6, r6
        blt cr0, LBB_test_3     ; no_exit
LBB_test_5:     ; loopexit
        or r3, r2, r2
        blr


Unfortunately, this is actually worse code, because the register coallescer
is getting confused somehow.  If it were doing its job right, it could turn the
code into this:

_test:
        cmpwi cr0, r4, 0
        bgt cr0, LBB_test_2     ; entry.no_exit_crit_edge
LBB_test_1:     ; entry.loopexit_crit_edge
        li r6, 0
        b LBB_test_5    ; loopexit
LBB_test_2:     ; entry.no_exit_crit_edge
        li r6, 0
LBB_test_3:     ; no_exit
        lwz r2, 0(r3)
        cmpw cr0, r2, r5
        beq cr0, LBB_test_5     ; loopexit
LBB_test_4:     ; endif
        addi r3, r3, 4
        addi r6, r6, 1
        cmpw cr0, r6, r4
        blt cr0, LBB_test_3     ; no_exit
LBB_test_5:     ; loopexit
        or r3, r6, r6
        blr

... which I'll work on next. :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23604 91177308-0d34-0410-b5e6-96231b3b80d8
2005-10-03 02:50:05 +00:00
..
ADCE.cpp preserve calling conventions when hacking on code 2005-05-14 12:25:32 +00:00
BasicBlockPlacement.cpp Remove trailing whitespace 2005-04-21 23:48:37 +00:00
CondPropagate.cpp Fix a fixme in CondPropagate.cpp by moving a PhiNode optimization into 2005-08-04 23:24:19 +00:00
ConstantProp.cpp Remove trailing whitespace 2005-04-21 23:48:37 +00:00
CorrelatedExprs.cpp Remove trailing whitespace 2005-04-21 23:48:37 +00:00
DCE.cpp clean up and modernize this pass. 2005-05-08 18:45:26 +00:00
DeadStoreElimination.cpp Remove trailing whitespace 2005-04-21 23:48:37 +00:00
GCSE.cpp Remove trailing whitespace 2005-04-21 23:48:37 +00:00
IndVarSimplify.cpp Allow indvar simplify to canonicalize ANY affine IV, not just affine IVs with 2005-08-10 01:12:06 +00:00
InstructionCombining.cpp Factor the GetGEPGlobalInitializer out of this pass and into Transforms/Utils 2005-09-26 05:28:06 +00:00
LICM.cpp prevent va_arg from being hoisted from a loop 2005-06-20 13:36:33 +00:00
LoopStrengthReduce.cpp Make IVUseShouldUsePostIncValue more aggressive when the use is a PHI. In 2005-10-03 02:50:05 +00:00
LoopUnroll.cpp Eliminate tabs and trailing spaces 2005-04-23 21:38:35 +00:00
LoopUnswitch.cpp Remove trailing whitespace 2005-04-21 23:48:37 +00:00
LowerConstantExprs.cpp Remove trailing whitespace 2005-04-21 23:48:37 +00:00
LowerGC.cpp Remove trailing whitespace 2005-04-21 23:48:37 +00:00
LowerPacked.cpp Remove trailing whitespace 2005-04-21 23:48:37 +00:00
Makefile Change Library Names Not To Conflict With Others When Installed 2004-10-27 23:18:45 +00:00
PRE.cpp Remove trailing whitespace 2005-04-21 23:48:37 +00:00
Reassociate.cpp Fix a problem that Dan Berlin noticed, where reassociation would not succeed 2005-09-02 07:07:58 +00:00
ScalarReplAggregates.cpp Remove trailing whitespace 2005-04-21 23:48:37 +00:00
SCCP.cpp Eliminate GetGEPGlobalInitializer in favor of the more powerful 2005-09-26 05:28:52 +00:00
SimplifyCFG.cpp Remove trailing whitespace 2005-04-21 23:48:37 +00:00
TailDuplication.cpp Remove trailing whitespace 2005-04-21 23:48:37 +00:00
TailRecursionElimination.cpp Use the new 'moveBefore' method to simplify some code. Really, which is 2005-08-08 19:11:57 +00:00