diff options
author | Jay Foad <jay.foad@gmail.com> | 2011-07-19 15:07:52 +0000 |
---|---|---|
committer | Jay Foad <jay.foad@gmail.com> | 2011-07-19 15:07:52 +0000 |
commit | b992a635fbc849c9b24852224326b18d140a63b9 (patch) | |
tree | 9c02ae0583847aee0069df744ad74b6bccfd4c04 /llvm/lib/Analysis/InstructionSimplify.cpp | |
parent | 528bedaf5d0d97b706c942260a84b3b406b35be3 (diff) | |
download | bcm5719-llvm-b992a635fbc849c9b24852224326b18d140a63b9.tar.gz bcm5719-llvm-b992a635fbc849c9b24852224326b18d140a63b9.zip |
Convert SimplifyGEPInst to use ArrayRef.
llvm-svn: 135482
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 5080106be7f..740351ceb8b 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -2219,24 +2219,24 @@ Value *llvm::SimplifySelectInst(Value *CondVal, Value *TrueVal, Value *FalseVal, /// SimplifyGEPInst - Given operands for an GetElementPtrInst, see if we can /// fold the result. If not, this returns null. -Value *llvm::SimplifyGEPInst(Value *const *Ops, unsigned NumOps, +Value *llvm::SimplifyGEPInst(ArrayRef<Value *> Ops, const TargetData *TD, const DominatorTree *) { // The type of the GEP pointer operand. PointerType *PtrTy = cast<PointerType>(Ops[0]->getType()); // getelementptr P -> P. - if (NumOps == 1) + if (Ops.size() == 1) return Ops[0]; if (isa<UndefValue>(Ops[0])) { // Compute the (pointer) type returned by the GEP instruction. - Type *LastType = GetElementPtrInst::getIndexedType(PtrTy, &Ops[1], - NumOps-1); + Type *LastType = GetElementPtrInst::getIndexedType(PtrTy, Ops.data() + 1, + Ops.size() - 1); Type *GEPTy = PointerType::get(LastType, PtrTy->getAddressSpace()); return UndefValue::get(GEPTy); } - if (NumOps == 2) { + if (Ops.size() == 2) { // getelementptr P, 0 -> P. if (ConstantInt *C = dyn_cast<ConstantInt>(Ops[1])) if (C->isZero()) @@ -2250,12 +2250,13 @@ Value *llvm::SimplifyGEPInst(Value *const *Ops, unsigned NumOps, } // Check to see if this is constant foldable. - for (unsigned i = 0; i != NumOps; ++i) + for (unsigned i = 0, e = Ops.size(); i != e; ++i) if (!isa<Constant>(Ops[i])) return 0; return ConstantExpr::getGetElementPtr(cast<Constant>(Ops[0]), - (Constant *const*)Ops+1, NumOps-1); + (Constant *const*)Ops.data() + 1, + Ops.size() - 1); } /// SimplifyPHINode - See if we can fold the given phi. If not, returns null. @@ -2456,7 +2457,7 @@ Value *llvm::SimplifyInstruction(Instruction *I, const TargetData *TD, break; case Instruction::GetElementPtr: { SmallVector<Value*, 8> Ops(I->op_begin(), I->op_end()); - Result = SimplifyGEPInst(&Ops[0], Ops.size(), TD, DT); + Result = SimplifyGEPInst(Ops, TD, DT); break; } case Instruction::PHI: |