summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-12-09 07:14:34 +0000
committerChris Lattner <sabre@nondot.org>2004-12-09 07:14:34 +0000
commitf17a2fb8498f6c3f5806af04fe25d5b773241a60 (patch)
treed1f4e2fd5d8f8c1f1abbd3ee5890408b7effdbea /llvm/lib
parent6225146f201913b2da5ba8249ca68eb3818a5a12 (diff)
downloadbcm5719-llvm-f17a2fb8498f6c3f5806af04fe25d5b773241a60.tar.gz
bcm5719-llvm-f17a2fb8498f6c3f5806af04fe25d5b773241a60.zip
Implement trivial sinking for load instructions. This causes us to sink 567 loads in spec
llvm-svn: 18692
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 9e37d96f59e..40b2d485437 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -4206,7 +4206,17 @@ static bool TryToSinkInstruction(Instruction *I, BasicBlock *DestBlock) {
if (isa<AllocaInst>(I) && I->getParent() == &DestBlock->getParent()->front())
return false;
- if (isa<LoadInst>(I)) return false;
+ // We can only sink load instructions if there is nothing between the load and
+ // the end of block that could change the value.
+ if (LoadInst *LI = dyn_cast<LoadInst>(I)) {
+ if (LI->isVolatile()) return false; // Don't sink volatile loads.
+
+ for (BasicBlock::iterator Scan = LI, E = LI->getParent()->end();
+ Scan != E; ++Scan)
+ if (Scan->mayWriteToMemory())
+ return false;
+ std::cerr << "SUNK LOAD: " << *LI;
+ }
BasicBlock::iterator InsertPos = DestBlock->begin();
while (isa<PHINode>(InsertPos)) ++InsertPos;
OpenPOWER on IntegriCloud