if (const StructType *ST = dyn_cast<StructType>(*GTI)) {
// N = N + Offset
- Offset += TD.getStructLayout(ST)->MemberOffsets[CI->getZExtValue()];
+ Offset += TD.getStructLayout(ST)->getElementOffset(CI->getZExtValue());
} else {
const SequentialType *ST = cast<SequentialType>(*GTI);
Offset += TD.getTypeSize(ST->getElementType())*CI->getSExtValue();
break;
}
if (isFoldableGEP) {
- std::vector<Value*> NewOps(Ops+1, Ops+NumOps);
- uint64_t Offset = TD->getIndexedOffset(Ptr->getType(), NewOps);
+ uint64_t Offset = TD->getIndexedOffset(Ptr->getType(),
+ (Value**)Ops+1, NumOps-1);
Constant *C = ConstantInt::get(TD->getIntPtrType(), Offset);
return ConstantExpr::getIntToPtr(C, ResultTy);
}
case Instruction::Call:
if (Function *F = dyn_cast<Function>(Ops[0]))
if (canConstantFoldCallTo(F))
- return ConstantFoldCall(F, Ops+1, NumOps);
+ return ConstantFoldCall(F, Ops+1, NumOps-1);
return 0;
case Instruction::ICmp:
case Instruction::FCmp:
return ConstantExpr::getCompare(cast<CmpInst>(I)->getPredicate(), Ops[0],
Ops[1]);
- case Instruction::Shl:
- case Instruction::LShr:
- case Instruction::AShr:
- return ConstantExpr::get(Opc, Ops[0], Ops[1]);
case Instruction::Trunc:
case Instruction::ZExt:
case Instruction::SExt:
C = UndefValue::get(ATy->getElementType());
else
return 0;
- } else if (const PackedType *PTy = dyn_cast<PackedType>(*I)) {
+ } else if (const VectorType *PTy = dyn_cast<VectorType>(*I)) {
if (CI->getZExtValue() >= PTy->getNumElements())
return 0;
- if (ConstantPacked *CP = dyn_cast<ConstantPacked>(C))
+ if (ConstantVector *CP = dyn_cast<ConstantVector>(C))
C = CP->getOperand(CI->getZExtValue());
else if (isa<ConstantAggregateZero>(C))
C = Constant::getNullValue(PTy->getElementType());