aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-04-14 00:17:39 +0000
committerChris Lattner <sabre@nondot.org>2007-04-14 00:17:39 +0000
commitf25646bfb375b614cddcc8b6fda2b524feae1efa (patch)
tree4ef07c3f5700d77996cea4cee42b5327c9538dfb
parent6f771d435111cd943414ab570e9aec0c7a6c2954 (diff)
use an accessor to simplify code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35979 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/CodeGenPrepare.cpp16
1 files changed, 1 insertions, 15 deletions
diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp
index 32226a02aa..8c321f4719 100644
--- a/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp
@@ -886,21 +886,7 @@ bool CodeGenPrepare::OptimizeBlock(BasicBlock &BB) {
SI->getOperand(0)->getType(),
SunkAddrs);
} else if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(I)) {
- bool HasNonZeroIdx = false;
- for (GetElementPtrInst::op_iterator OI = GEPI->op_begin()+1,
- E = GEPI->op_end(); OI != E; ++OI) {
- if (ConstantInt *CI = dyn_cast<ConstantInt>(*OI)) {
- if (!CI->isZero()) {
- HasNonZeroIdx = true;
- break;
- }
- } else {
- HasNonZeroIdx = true;
- break;
- }
- }
-
- if (!HasNonZeroIdx) {
+ 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);