llvm-6502/test/Transforms
Chris Lattner 7e9b427c87 if an alloca is only ever accessed as a unit, and is accessed with load/store instructions,
then don't try to decimate it into its individual pieces.  This will just make a mess of the
IR and is pointless if none of the elements are individually accessed.  This was generating
really terrible code for std::bitset (PR8980) because it happens to be lowered by clang
as an {[8 x i8]} structure instead of {i64}.

The testcase now is optimized to:

define i64 @test2(i64 %X) {
  br label %L2

L2:                                               ; preds = %0
  ret i64 %X
}

before we generated:

define i64 @test2(i64 %X) {
  %sroa.store.elt = lshr i64 %X, 56
  %1 = trunc i64 %sroa.store.elt to i8
  %sroa.store.elt8 = lshr i64 %X, 48
  %2 = trunc i64 %sroa.store.elt8 to i8
  %sroa.store.elt9 = lshr i64 %X, 40
  %3 = trunc i64 %sroa.store.elt9 to i8
  %sroa.store.elt10 = lshr i64 %X, 32
  %4 = trunc i64 %sroa.store.elt10 to i8
  %sroa.store.elt11 = lshr i64 %X, 24
  %5 = trunc i64 %sroa.store.elt11 to i8
  %sroa.store.elt12 = lshr i64 %X, 16
  %6 = trunc i64 %sroa.store.elt12 to i8
  %sroa.store.elt13 = lshr i64 %X, 8
  %7 = trunc i64 %sroa.store.elt13 to i8
  %8 = trunc i64 %X to i8
  br label %L2

L2:                                               ; preds = %0
  %9 = zext i8 %1 to i64
  %10 = shl i64 %9, 56
  %11 = zext i8 %2 to i64
  %12 = shl i64 %11, 48
  %13 = or i64 %12, %10
  %14 = zext i8 %3 to i64
  %15 = shl i64 %14, 40
  %16 = or i64 %15, %13
  %17 = zext i8 %4 to i64
  %18 = shl i64 %17, 32
  %19 = or i64 %18, %16
  %20 = zext i8 %5 to i64
  %21 = shl i64 %20, 24
  %22 = or i64 %21, %19
  %23 = zext i8 %6 to i64
  %24 = shl i64 %23, 16
  %25 = or i64 %24, %22
  %26 = zext i8 %7 to i64
  %27 = shl i64 %26, 8
  %28 = or i64 %27, %25
  %29 = zext i8 %8 to i64
  %30 = or i64 %29, %28
  ret i64 %30
}

In this case, instcombine was able to eliminate the nonsense, but in PR8980 enough
PHIs are in play that instcombine backs off.  It's better to not generate this stuff
in the first place.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123571 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-16 06:18:28 +00:00
..
ADCE
ArgumentPromotion Make BasicAliasAnalysis a normal AliasAnalysis implementation which 2010-10-18 18:04:47 +00:00
BlockPlacement
BranchFolding
CodeExtractor
CodeGenPrepare temporarily revert r123526. While working on a follow-on patch I 2011-01-15 07:51:19 +00:00
ConstantMerge Make constmerge a two-pass algorithm so that it won't miss merging 2011-01-15 18:14:21 +00:00
ConstProp Teach constant folding to perform conversions from constant floating 2011-01-11 01:07:24 +00:00
CorrelatedValuePropagation Fix PR8790, another instance where unreachable code can cause instruction simplification to fail, 2010-12-15 00:55:35 +00:00
DeadArgElim Preserve debug info attached with call instruction while eliminating dead argument. 2010-04-30 20:23:54 +00:00
DeadStoreElimination Fix PR8728, a miscompilation I recently introduced. When optimizing 2010-12-06 01:48:06 +00:00
EarlyCSE Duncan deftly points out that readnone functions aren't 2011-01-03 23:38:13 +00:00
FunctionAttrs Make ModRefBehavior a lattice. Use this to clean up AliasAnalysis 2010-11-10 01:02:18 +00:00
GlobalDCE
GlobalOpt Improve the safety of my globalopt enhancement by ensuring that the bitcast 2011-01-16 04:33:33 +00:00
GVN Give GVN back the ability to perform simple conditional propagation on conditional branch values. 2010-12-21 23:54:34 +00:00
IndVarSimplify Remove LoopIndexSplit pass. It is neither maintained nor used by anyone. 2010-10-07 23:29:37 +00:00
Inline relax testcase a bit. 2011-01-14 07:46:33 +00:00
InstCombine enhance FoldOpIntoPhi in instcombine to try harder when a phi has 2011-01-16 05:28:59 +00:00
InstSimplify Turn X-(X-Y) into Y. According to my auto-simplifier this is the most common 2011-01-14 15:26:10 +00:00
Internalize
IPConstantProp more test cleanup 2010-09-02 22:38:56 +00:00
JumpThreading Teach jump threading to "look through" a select when the branch direction of a terminator depends on it. 2010-12-15 09:51:20 +00:00
LCSSA Avoid depending on LCSSA implicitly pulling in LoopSimplify. 2010-07-26 18:00:43 +00:00
LICM Enhance LICM to promote alias sets whose pointers themselves are stored, 2010-12-19 05:57:25 +00:00
LoopDeletion Make LoopSimplify change conditional branches in loop exiting blocks 2010-02-25 06:57:05 +00:00
LoopIdiom Teach loop-idiom to turn a loop containing a memset into a larger memset 2011-01-04 07:46:33 +00:00
LoopRotate merge tests into one crash.ll test. 2011-01-11 07:50:07 +00:00
LoopSimplify Fix PR8702 by not having LoopSimplify claim to preserve LCSSA form. As described 2011-01-02 13:38:21 +00:00
LoopStrengthReduce Correct bogus module triple specifications. 2010-08-30 10:48:29 +00:00
LoopUnroll Revert r113439, which relaxed the requirement that loops containing calls cannot be unrolled. After some discussion, 2010-09-09 20:02:23 +00:00
LoopUnswitch Factor code for testing whether replacing one value with another 2010-11-18 19:59:41 +00:00
LowerAtomic Add an atomic lowering pass 2010-08-03 16:19:16 +00:00
LowerInvoke
LowerSetJmp
LowerSwitch
Mem2Reg Copy location info for current function argument from dbg.declare if respective store instruction does not have any location info. 2010-06-04 22:27:30 +00:00
MemCpyOpt revert 123144, reenabling the rest of memset formation. 2011-01-12 03:25:15 +00:00
MergeFunc Arrays and vectors with different numbers of elements are not equivalent. 2010-07-16 06:31:12 +00:00
PruneEH fix some failures my callgraph dump format change broke. 2010-04-23 18:38:40 +00:00
Reassociate fix a nice subtle reassociate bug which would only occur 2010-03-05 07:18:54 +00:00
ScalarRepl if an alloca is only ever accessed as a unit, and is accessed with load/store instructions, 2011-01-16 06:18:28 +00:00
SCCP fix PR7876: If ipsccp decides that a function's address is taken 2010-08-12 22:25:23 +00:00
SimplifyCFG SimplifyCFG: Ranges can be larger than 64 bits. Fixes Release-selfhost build. 2010-12-17 10:48:14 +00:00
SimplifyLibCalls Revert r64460. strtol and friends cannot be marked readonly, even with 2010-12-17 01:09:43 +00:00
Sink Make BasicAliasAnalysis a normal AliasAnalysis implementation which 2010-10-18 18:04:47 +00:00
SRETPromotion
StripSymbols DIGlobalVariable can be used to encode debug info for globals that are directly folded into a constant by FE. 2010-08-25 18:52:02 +00:00
TailCallElim merge two tests. 2010-08-31 18:44:03 +00:00
TailDup The output of opt -stats must be sent to stderr. Patch by NAKAMURA Takumi! 2010-09-01 18:32:56 +00:00