llvm-6502/test/Transforms/ScalarRepl
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
..
2003-05-29-ArrayFail.ll
2003-05-30-InvalidIndices.ll
2003-05-30-MultiLevel.ll
2003-09-12-IncorrectPromote.ll
2003-10-29-ArrayProblem.ll
2005-12-14-UnionPromoteCrash.ll
2006-01-24-IllegalUnionPromoteCrash.ll
2006-04-20-PromoteCrash.ll
2006-10-23-PointerUnionCrash.ll
2006-11-07-InvalidArrayPromote.ll
2006-12-11-SROA-Crash.ll
2007-03-19-CanonicalizeMemcpy.ll
2007-05-24-LargeAggregate.ll
2007-05-29-MemcpyPreserve.ll
2007-11-03-bigendian_apint.ll
2008-01-29-PromoteBug.ll
2008-02-28-SubElementExtractCrash.ll
2008-06-05-loadstore-agg.ll
2008-06-22-LargeArray.ll
2008-08-22-out-of-range-array-promote.ll
2008-09-22-vector-gep.ll
2009-01-09-scalarrepl-empty.ll Delete useless trailing semicolons. 2010-01-05 17:55:26 +00:00
2009-02-02-ScalarPromoteOutOfRange.ll
2009-02-05-LoadFCA.ll
2009-03-04-MemCpyAlign.ll
2009-03-05-Aggre2Scalar-dbg.ll
2009-04-21-ZeroLengthMemSet.ll
2009-05-08-I1Crash.ll
2009-06-01-BitcastIntPadding.ll
2009-08-16-VLA.ll
2009-12-11-NeonTypes.ll Remove arm_apcscc from the test files. It is the default and doing this 2010-06-17 15:18:27 +00:00
2010-01-18-SelfCopy.ll Remove arm_apcscc from the test files. It is the default and doing this 2010-06-17 15:18:27 +00:00
2010-11-24-IndirectVoid.ll Treat a call of function pointer like a load of the pointer when considering 2010-11-24 22:04:20 +00:00
address-space.ll Fix the second half of PR7437: scalarrepl wasn't preserving 2010-07-08 00:27:05 +00:00
AggregatePromote.ll
arraytest.ll
badarray.ll
basictest.ll 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
bitfield-sroa.ll
copy-aggregate.ll Extend SROA to handle arrays accessed as homogeneous structs and vice versa. 2011-01-13 17:45:11 +00:00
debuginfo.ll
dg.exp
DifferingTypes.ll
load-store-aggregate.ll
memcpy-align.ll Remove the arm_aapcscc marker from the tests. It is the default 2010-06-15 19:04:29 +00:00
memcpy-from-global.ll allow eliminating an alloca that is just copied from an constant global 2010-11-18 06:41:51 +00:00
memset-aggregate-byte-leader.ll
memset-aggregate.ll
nonzero-first-index.ll Generalize SROA to allow the first index of a GEP to be non-zero. Add a 2009-12-22 06:57:14 +00:00
not-a-vector.ll
phinodepromote.ll
select_promote.ll
sroa_two.ll
sroa-fca.ll
union-fp-int.ll
union-packed.ll
union-pointer.ll
vector_memcpy.ll
vector_promote.ll deepen my MMX/SRoA hack to avoid hurting non-x86 codegen. 2010-09-01 23:09:27 +00:00
volatile.ll