summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorCameron Zwarich <zwarich@apple.com>2011-01-06 02:44:52 +0000
committerCameron Zwarich <zwarich@apple.com>2011-01-06 02:44:52 +0000
commitd28c78eb4f01fb9199072d661a04032b5be7a224 (patch)
tree682d383c0c905f5b557565f1bd7232eed3534d42 /llvm/lib/Transforms
parent14ac865ca9aeba54dc52b75710a375a7531aae5b (diff)
downloadbcm5719-llvm-d28c78eb4f01fb9199072d661a04032b5be7a224.tar.gz
bcm5719-llvm-d28c78eb4f01fb9199072d661a04032b5be7a224.zip
Move the GEP handling in CodeGenPrepare to OptimizeInst().
llvm-svn: 122944
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp b/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
index 4f14a479eb4..166d9d6ee3f 100644
--- a/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
@@ -1003,6 +1003,17 @@ bool CodeGenPrepare::OptimizeInst(Instruction *I) {
MadeChange |= OptimizeMemoryInst(I, SI->getOperand(1),
SI->getOperand(0)->getType(),
SunkAddrs);
+ } else if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(I)) {
+ if (GEPI->hasAllZeroIndices()) {
+ /// The GEP operand must be a pointer, so must its result -> BitCast
+ Instruction *NC = new BitCastInst(GEPI->getOperand(0), GEPI->getType(),
+ GEPI->getName(), GEPI);
+ GEPI->replaceAllUsesWith(NC);
+ GEPI->eraseFromParent();
+ ++NumGEPsElim;
+ MadeChange = true;
+ OptimizeInst(NC);
+ }
}
return MadeChange;
@@ -1031,18 +1042,7 @@ bool CodeGenPrepare::OptimizeBlock(BasicBlock &BB) {
for (BasicBlock::iterator BBI = BB.begin(), E = BB.end(); BBI != E; ) {
Instruction *I = BBI++;
- if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(I)) {
- if (GEPI->hasAllZeroIndices()) {
- /// The GEP operand must be a pointer, so must its result -> BitCast
- Instruction *NC = new BitCastInst(GEPI->getOperand(0), GEPI->getType(),
- GEPI->getName(), GEPI);
- GEPI->replaceAllUsesWith(NC);
- GEPI->eraseFromParent();
- ++NumGEPsElim;
- MadeChange = true;
- BBI = NC;
- }
- } else if (CallInst *CI = dyn_cast<CallInst>(I)) {
+ if (CallInst *CI = dyn_cast<CallInst>(I)) {
// If we found an inline asm expession, and if the target knows how to
// lower it to normal LLVM code, do so now.
if (TLI && isa<InlineAsm>(CI->getCalledValue())) {
OpenPOWER on IntegriCloud