+
+ case Instruction::GetElementPtr: {
+ // Convert a one index getelementptr into just about anything that is
+ // desired.
+ //
+ BasicBlock::iterator It = I;
+ const Type *OldElTy = cast<PointerType>(I->getType())->getElementType();
+ unsigned DataSize = TD.getTypeSize(OldElTy);
+ Value *Index = I->getOperand(1);
+
+ if (DataSize != 1) {
+ // Insert a multiply of the old element type is not a unit size...
+ Index = BinaryOperator::create(Instruction::Mul, Index,
+ ConstantSInt::get(Type::LongTy, DataSize),
+ "scale", It);
+ }
+
+ // Perform the conversion now...
+ //
+ std::vector<Value*> Indices;
+ const Type *ElTy = ConvertableToGEP(NewVal->getType(), Index, Indices, &It);
+ assert(ElTy != 0 && "GEP Conversion Failure!");
+ Res = new GetElementPtrInst(NewVal, Indices, Name);
+ assert(Res->getType() == PointerType::get(ElTy) &&
+ "ConvertableToGet failed!");
+ }
+#if 0
+ if (I->getType() == PointerType::get(Type::SByteTy)) {
+ // Convert a getelementptr sbyte * %reg111, uint 16 freely back to
+ // anything that is a pointer type...
+ //
+ BasicBlock::iterator It = I;
+
+ // Check to see if the second argument is an expression that can
+ // be converted to the appropriate size... if so, allow it.
+ //
+ std::vector<Value*> Indices;
+ const Type *ElTy = ConvertableToGEP(NewVal->getType(), I->getOperand(1),
+ Indices, &It);
+ assert(ElTy != 0 && "GEP Conversion Failure!");
+
+ Res = new GetElementPtrInst(NewVal, Indices, Name);
+ } else {
+ // Convert a getelementptr ulong * %reg123, uint %N
+ // to getelementptr long * %reg123, uint %N
+ // ... where the type must simply stay the same size...
+ //
+ GetElementPtrInst *GEP = cast<GetElementPtrInst>(I);
+ std::vector<Value*> Indices(GEP->idx_begin(), GEP->idx_end());
+ Res = new GetElementPtrInst(NewVal, Indices, Name);
+ }
+#endif
+ break;
+