llvm-6502/lib/Transforms/Scalar
Chris Lattner 79b3bd395d If an alloca only has two types of uses: 1) reads 2) a memcpy/memmove that
copies from a constant global, then we can change the reads to read from the
global instead of from the alloca.  This eliminates the alloca and the memcpy,
and promotes secondary optimizations (because the loads are now loads from
a constant global).

This is important for a common C idiom:

void foo() {
   int A[] = {1,2,3,4,5,6,7,8,9...};
   ... only reads of A ...
}

For some reason, people forget to mark the array static or const.

This triggers on these multisource benchmarks:
JM/ldecode: block_pos, [3 x [4 x [4 x i32]]]
FreeBench/mason: m, [18 x i32], inlined 4 times
MiBench/office-stringsearch: search_strings, [1332 x i8*]
MiBench/office-stringsearch: find_strings, [1333 x i8*]
Prolangs-C++/city: dirs, [9 x i8*], inlined 4 places

and these spec benchmarks:
177.mesa: message, [8 x [32 x i8]]
186.crafty: bias_rl45, [64 x i32]
186.crafty: diag_sq, [64 x i32]
186.crafty: empty, [9 x i8]
186.crafty: xlate, [15 x i8]
186.crafty: status, [13 x i8]
186.crafty: bdinfo, [25 x i8]
445.gobmk: routines, [16 x i8*]
458.sjeng: piece_rep, [14 x i8*]
458.sjeng: t, [13 x i32], inlined 4 places.
464.h264ref: block8x8_idx, [3 x [4 x [4 x i32]]]
464.h264ref: block_pos, [3 x [4 x [4 x i32]]]
464.h264ref: j_off_tab, [12 x i32]

This implements Transforms/ScalarRepl/memcpy-from-global.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36429 91177308-0d34-0410-b5e6-96231b3b80d8
2007-04-25 06:40:51 +00:00
..
ADCE.cpp Revert changes that caused breakage. 2007-04-18 06:46:57 +00:00
BasicBlockPlacement.cpp Apply the VISIBILITY_HIDDEN field to the remaining anonymous classes in 2007-02-05 23:32:05 +00:00
CodeGenPrepare.cpp Fix 2007-04-25 00:37:04 +00:00
CondPropagate.cpp Prefer non-virtual calls to ConstantInt::isZero over virtual calls to 2007-03-02 00:28:52 +00:00
ConstantProp.cpp Apply the VISIBILITY_HIDDEN field to the remaining anonymous classes in 2007-02-05 23:32:05 +00:00
CorrelatedExprs.cpp Use ETForest instead of DominatorTree. 2007-04-18 05:25:43 +00:00
DCE.cpp Apply the VISIBILITY_HIDDEN field to the remaining anonymous classes in 2007-02-05 23:32:05 +00:00
DeadStoreElimination.cpp Apply the VISIBILITY_HIDDEN field to the remaining anonymous classes in 2007-02-05 23:32:05 +00:00
GCSE.cpp fix long lines 2007-04-14 23:32:02 +00:00
IndVarSimplify.cpp Now IndVarSimplify is a LoopPass. 2007-03-07 06:39:01 +00:00
InstructionCombining.cpp Make use of ConstantInt::isZero instead of ConstantInt::isNullValue. 2007-04-19 05:39:12 +00:00
LICM.cpp Rollback some changes that adversely affected performance. I'm currently rethinking 2007-04-24 06:40:39 +00:00
LoopRotation.cpp fix long lines 2007-04-14 23:32:02 +00:00
LoopStrengthReduce.cpp Fix 2007-04-23 22:42:03 +00:00
LoopUnroll.cpp Fix 2007-04-16 23:03:45 +00:00
LoopUnswitch.cpp Now LoopUnswitch is a LoopPass. 2007-03-07 00:26:10 +00:00
LowerGC.cpp Eliminate use of ctors that take vectors. 2007-02-13 02:10:56 +00:00
LowerPacked.cpp Removed tabs everywhere except autogenerated & external files. Add make 2007-04-16 18:10:23 +00:00
Makefile DONT_BUILD_RELINKED is gone and implied by BUILD_ARCHIVE now 2005-10-24 02:26:13 +00:00
PredicateSimplifier.cpp Undo my previous changes. Since my approach to this problem is being revised, 2007-04-25 04:18:54 +00:00
Reassociate.cpp Prefer non-virtual calls to ConstantInt::isZero over virtual calls to 2007-03-02 00:28:52 +00:00
Reg2Mem.cpp Removed tabs everywhere except autogenerated & external files. Add make 2007-04-16 18:10:23 +00:00
ScalarReplAggregates.cpp If an alloca only has two types of uses: 1) reads 2) a memcpy/memmove that 2007-04-25 06:40:51 +00:00
SCCP.cpp fix long lines 2007-04-14 23:32:02 +00:00
SimplifyCFG.cpp Use a worklist-driven algorithm instead of a recursive one. 2007-04-05 01:27:02 +00:00
TailDuplication.cpp Apply the VISIBILITY_HIDDEN field to the remaining anonymous classes in 2007-02-05 23:32:05 +00:00
TailRecursionElimination.cpp Change uses of Function::front to Function::getEntryBlock for readability. 2007-03-22 16:38:57 +00:00