final step needed to resolve PR6627, which allows us to flatten the code down to

a nice and tidy:
  %x1 = load i32* %0, align 4
  %1 = icmp eq i32 %x1, 1179403647
  br i1 %1, label %if.then, label %if.end

instead of doing lots of loads and branches.  May the FreeBSD bootloader
long fit in its allocated space.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130416 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2011-04-28 18:15:47 +00:00
parent ad3ba6a7de
commit 0a9e3d613b
3 changed files with 78 additions and 7 deletions

View File

@ -432,14 +432,14 @@ namespace {
/// addToLeaderTable - Push a new Value to the LeaderTable onto the list for
/// its value number.
void addToLeaderTable(uint32_t N, Value *V, BasicBlock *BB) {
LeaderTableEntry& Curr = LeaderTable[N];
LeaderTableEntry &Curr = LeaderTable[N];
if (!Curr.Val) {
Curr.Val = V;
Curr.BB = BB;
return;
}
LeaderTableEntry* Node = TableAllocator.Allocate<LeaderTableEntry>();
LeaderTableEntry *Node = TableAllocator.Allocate<LeaderTableEntry>();
Node->Val = V;
Node->BB = BB;
Node->Next = Curr.Next;
@ -944,7 +944,10 @@ static Value *GetLoadValueForLoad(LoadInst *SrcVal, unsigned Offset,
Value *PtrVal = SrcVal->getPointerOperand();
IRBuilder<> Builder(SrcVal->getParent(), SrcVal);
// Insert the new load after the old load. This ensures that subsequent
// memdep queries will find the new load. We can't easily remove the old
// load completely because it is already in the value numbering table.
IRBuilder<> Builder(SrcVal->getParent(), ++BasicBlock::iterator(SrcVal));
const Type *DestPTy =
IntegerType::get(LoadTy->getContext(), NewLoadSize*8);
DestPTy = PointerType::get(DestPTy,
@ -967,6 +970,7 @@ static Value *GetLoadValueForLoad(LoadInst *SrcVal, unsigned Offset,
RV = Builder.CreateTrunc(RV, SrcVal->getType());
SrcVal->replaceAllUsesWith(RV);
gvn.getMemDep().removeInstruction(SrcVal);
//gvn.markInstructionForDeletion(SrcVal);
SrcVal = NewLoad;
}