aboutsummaryrefslogtreecommitdiffstats
path: root/lib
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
commit865ae1a9e77920e07c4a6a992736109c2cd4fe02 (patch)
treef95c4369a6e85b66cbc26dd9f45b4e596f4fbd77 /lib
parentc061101e03ef6d2ca550f8fe71594a5e1c02e348 (diff)
downloadexternal_llvm-865ae1a9e77920e07c4a6a992736109c2cd4fe02.zip
external_llvm-865ae1a9e77920e07c4a6a992736109c2cd4fe02.tar.gz
external_llvm-865ae1a9e77920e07c4a6a992736109c2cd4fe02.tar.bz2
Move the GEP handling in CodeGenPrepare to OptimizeInst().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122944 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Scalar/CodeGenPrepare.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp
index 4f14a47..166d9d6 100644
--- a/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/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())) {