diff options
author | Chris Lattner <sabre@nondot.org> | 2011-04-28 18:15:47 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-04-28 18:15:47 +0000 |
commit | 0a9e3d613bbbd8c47f4edf6841f566fa22775932 (patch) | |
tree | ce37bda53452205e6f348395e81f1e9de97c4d6e /lib/Transforms/Scalar/GVN.cpp | |
parent | ad3ba6a7de5eb24ea58ba0ec9dd1e41912f678a9 (diff) | |
download | external_llvm-0a9e3d613bbbd8c47f4edf6841f566fa22775932.zip external_llvm-0a9e3d613bbbd8c47f4edf6841f566fa22775932.tar.gz external_llvm-0a9e3d613bbbd8c47f4edf6841f566fa22775932.tar.bz2 |
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
Diffstat (limited to 'lib/Transforms/Scalar/GVN.cpp')
-rw-r--r-- | lib/Transforms/Scalar/GVN.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp index 7480ed8..abd7689 100644 --- a/lib/Transforms/Scalar/GVN.cpp +++ b/lib/Transforms/Scalar/GVN.cpp @@ -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; } |