diff options
| author | Eduard Burtescu <edy.burt@gmail.com> | 2016-01-20 00:26:52 +0000 |
|---|---|---|
| committer | Eduard Burtescu <edy.burt@gmail.com> | 2016-01-20 00:26:52 +0000 |
| commit | 23c4d83aa310903484cb80d2ab8197444a96d2e0 (patch) | |
| tree | ac05f68ed8bb9f322915e975209ee53e19cb180d /llvm/lib/Target | |
| parent | 7077f0af26f4929835f8c500a29f31ff289efe6b (diff) | |
| download | bcm5719-llvm-23c4d83aa310903484cb80d2ab8197444a96d2e0.tar.gz bcm5719-llvm-23c4d83aa310903484cb80d2ab8197444a96d2e0.zip | |
[NFC] Replace several manual GEP loops with gep_type_iterator.
Reviewers: dblaikie
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D16335
llvm-svn: 258262
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/AArch64/AArch64FastISel.cpp | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64FastISel.cpp b/llvm/lib/Target/AArch64/AArch64FastISel.cpp index 1e4be55aee6..5b6880db849 100644 --- a/llvm/lib/Target/AArch64/AArch64FastISel.cpp +++ b/llvm/lib/Target/AArch64/AArch64FastISel.cpp @@ -555,10 +555,9 @@ bool AArch64FastISel::computeAddress(const Value *Obj, Address &Addr, Type *Ty) // Iterate through the GEP folding the constants into offsets where // we can. - gep_type_iterator GTI = gep_type_begin(U); - for (User::const_op_iterator i = U->op_begin() + 1, e = U->op_end(); i != e; - ++i, ++GTI) { - const Value *Op = *i; + for (gep_type_iterator GTI = gep_type_begin(U), E = gep_type_end(U); + GTI != E; ++GTI) { + const Value *Op = GTI.getOperand(); if (StructType *STy = dyn_cast<StructType>(*GTI)) { const StructLayout *SL = DL.getStructLayout(STy); unsigned Idx = cast<ConstantInt>(Op)->getZExtValue(); @@ -4814,24 +4813,18 @@ bool AArch64FastISel::selectGetElementPtr(const Instruction *I) { // Keep a running tab of the total offset to coalesce multiple N = N + Offset // into a single N = N + TotalOffset. uint64_t TotalOffs = 0; - Type *Ty = I->getOperand(0)->getType(); MVT VT = TLI.getPointerTy(DL); - for (auto OI = std::next(I->op_begin()), E = I->op_end(); OI != E; ++OI) { - const Value *Idx = *OI; - if (auto *StTy = dyn_cast<StructType>(Ty)) { + for (gep_type_iterator GTI = gep_type_begin(I), E = gep_type_end(I); + GTI != E; ++GTI) { + const Value *Idx = GTI.getOperand(); + if (auto *StTy = dyn_cast<StructType>(*GTI)) { unsigned Field = cast<ConstantInt>(Idx)->getZExtValue(); // N = N + Offset if (Field) TotalOffs += DL.getStructLayout(StTy)->getElementOffset(Field); - Ty = StTy->getElementType(Field); } else { - if (Ty->isPointerTy()) { - // The only pointer type is for the very first index, - // therefore the next type is the source element type. - Ty = cast<GEPOperator>(I)->getSourceElementType(); - } else { - Ty = cast<SequentialType>(Ty)->getElementType(); - } + Type *Ty = GTI.getIndexedType(); + // If this is a constant subscript, handle it quickly. if (const auto *CI = dyn_cast<ConstantInt>(Idx)) { if (CI->isZero()) |

