llvm-6502/lib
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
..
Analysis fix PR8983, a broken assertion. 2011-01-16 03:43:53 +00:00
Archive Revert "Archive: Replace all internal uses of PathV1 with PathV2. The external API still uses PathV1." 2011-01-16 01:43:22 +00:00
AsmParser Allow unnamed_addr on declarations. 2011-01-15 08:15:00 +00:00
Bitcode FixedNumOperandTraits and VariadicOperandTraits assumed that, given a 2011-01-11 15:07:38 +00:00
CodeGen reapply my fix for PR8961 with a tweak to properly handle 2011-01-16 02:27:38 +00:00
CompilerDriver Support/Path: Deprecate PathV1::exists and replace all uses with PathV2::fs::exists. 2011-01-10 02:34:23 +00:00
ExecutionEngine Rename TargetFrameInfo into TargetFrameLowering. Also, put couple of FIXMEs and fixes here and there. 2011-01-10 12:39:04 +00:00
Linker Allow unnamed_addr on declarations. 2011-01-15 08:15:00 +00:00
MC Use common style for .cfi directives 2011-01-14 21:57:39 +00:00
Object
Support Support/PathV2: Add identify_magic. 2011-01-15 20:39:36 +00:00
Target Spill R4 if it's going to be used to restore SP from FP. 2011-01-16 05:14:33 +00:00
Transforms 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
VMCore Allow unnamed_addr on declarations. 2011-01-15 08:15:00 +00:00
Makefile