llvm-6502/lib/Transforms/Scalar
Chris Lattner 020f714a93 If an indvar with a variable stride is used by the exit condition, go ahead
and handle it like constant stride vars.  This fixes some bad codegen in
variable stride cases.  For example, it compiles this:

void foo(int k, int i) {
  for (k=i+i; k <= 8192; k+=i)
    flags2[k] = 0;
}

to:

LBB1_1: #bb.preheader
        movl %eax, %ecx
        addl %ecx, %ecx
        movl L_flags2$non_lazy_ptr, %edx
LBB1_2: #bb
        movb $0, (%edx,%ecx)
        addl %eax, %ecx
        cmpl $8192, %ecx
        jle LBB1_2      #bb
LBB1_5: #return
        ret

or (if the array is local and we are in dynamic-nonpic or static mode):

LBB3_2: #bb
        movb $0, _flags2(%ecx)
        addl %eax, %ecx
        cmpl $8192, %ecx
        jle LBB3_2      #bb

and:

        lis r2, ha16(L_flags2$non_lazy_ptr)
        lwz r2, lo16(L_flags2$non_lazy_ptr)(r2)
        slwi r3, r4, 1
LBB1_2: ;bb
        li r5, 0
        add r6, r4, r3
        stbx r5, r2, r3
        cmpwi cr0, r6, 8192
        bgt cr0, LBB1_5 ;return

instead of:

        leal (%eax,%eax,2), %ecx
        movl %eax, %edx
        addl %edx, %edx
        addl L_flags2$non_lazy_ptr, %edx
        xorl %esi, %esi
LBB1_2: #bb
        movb $0, (%edx,%esi)
        movl %eax, %edi
        addl %esi, %edi
        addl %ecx, %esi
        cmpl $8192, %esi
        jg LBB1_5       #return

and:

        lis r2, ha16(L_flags2$non_lazy_ptr)
        lwz r2, lo16(L_flags2$non_lazy_ptr)(r2)
        mulli r3, r4, 3
        slwi r5, r4, 1
        li r6, 0
        add r2, r2, r5
LBB1_2: ;bb
        li r5, 0
        add r7, r3, r6
        stbx r5, r2, r6
        add r6, r4, r6
        cmpwi cr0, r7, 8192
        ble cr0, LBB1_2 ;bb

This speeds up Benchmarks/Shootout/sieve from 8.533s to 6.464s and
implements LoopStrengthReduce/var_stride_used_by_compare.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31809 91177308-0d34-0410-b5e6-96231b3b80d8
2006-11-17 06:17:33 +00:00
..
ADCE.cpp eliminate RegisterOpt. It does the same thing as RegisterPass. 2006-08-27 22:42:52 +00:00
BasicBlockPlacement.cpp eliminate RegisterOpt. It does the same thing as RegisterPass. 2006-08-27 22:42:52 +00:00
CondPropagate.cpp There can be more than one PHINode at the start of the block. 2006-11-01 23:04:45 +00:00
ConstantProp.cpp eliminate RegisterOpt. It does the same thing as RegisterPass. 2006-08-27 22:42:52 +00:00
CorrelatedExprs.cpp remove dead code 2006-11-03 01:34:58 +00:00
DCE.cpp eliminate RegisterOpt. It does the same thing as RegisterPass. 2006-08-27 22:42:52 +00:00
DeadStoreElimination.cpp eliminate RegisterOpt. It does the same thing as RegisterPass. 2006-08-27 22:42:52 +00:00
GCSE.cpp eliminate RegisterOpt. It does the same thing as RegisterPass. 2006-08-27 22:42:52 +00:00
IndVarSimplify.cpp Fix Transforms/IndVarsSimplify/2006-09-20-LFTR-Crash.ll 2006-09-21 05:12:20 +00:00
InstructionCombining.cpp Fix a gcc 4.2 warning. 2006-11-15 04:53:24 +00:00
LICM.cpp An sinkable instruction may exist with uses, if those uses are in dead blocks. 2006-09-12 19:17:09 +00:00
LoopStrengthReduce.cpp If an indvar with a variable stride is used by the exit condition, go ahead 2006-11-17 06:17:33 +00:00
LoopUnroll.cpp For PR786: 2006-11-02 20:25:50 +00:00
LoopUnswitch.cpp For PR786: 2006-11-02 20:25:50 +00:00
LowerGC.cpp For PR950: 2006-10-20 07:07:24 +00:00
LowerPacked.cpp For PR950: 2006-10-20 07:07:24 +00:00
Makefile DONT_BUILD_RELINKED is gone and implied by BUILD_ARCHIVE now 2005-10-24 02:26:13 +00:00
PredicateSimplifier.cpp Unbreak VC++ build. 2006-11-05 19:31:28 +00:00
Reassociate.cpp For PR950: 2006-11-02 01:53:59 +00:00
Reg2Mem.cpp eliminate RegisterOpt. It does the same thing as RegisterPass. 2006-08-27 22:42:52 +00:00
ScalarReplAggregates.cpp For PR950: 2006-11-08 06:47:33 +00:00
SCCP.cpp For PR786: 2006-11-02 20:25:50 +00:00
SimplifyCFG.cpp eliminate RegisterOpt. It does the same thing as RegisterPass. 2006-08-27 22:42:52 +00:00
TailDuplication.cpp set DEBUG_TYPE right 2006-09-27 04:58:23 +00:00
TailRecursionElimination.cpp For PR786: 2006-11-02 20:25:50 +00:00