double* to <2 x double>*

Does anyone know how to instrument double* to <2 x doulbe>*, e.g., 2.2 → <2.2, 2.2>?
For example, I want to change the following IR code

%arrayidx1 = getelementptr inbounds [100 x double]* @main.B, i32 0, i32 %i.021

%1 = load double* %arrayidx1, align 4, !tbaa !0

to:

%arrayidx1 = getelementptr inbounds [100 x double]* @main.B, i32 0, i32 %i.021
%1 = bitcast double* %arrayidx1 to <2 x double>*

%2 = load <2 x double>* %1, align 4

what I right now doing is:
Assume pInst is %1 = load double* %arrayidx1, align 4, !tbaa !0

Value *loadValue = pInst->getOperand(0);

Type *vecTy = VectorType::get(Type::getDoublePtrTy(currF->getContext()), 2);
Value emptyVec = UndefValue::get(vecTy);
Type
u32Ty = Type::getInt32Ty(currF->getContext());
Value *index0 = ConstantInt::get(u32Ty, 0);
Value *index1 = ConstantInt::get(u32Ty, 1);

Instruction *InsertVal = InsertElementInst::Create(emptyVec, loadValue, index0, “”);
InsertVal = InsertElementInst::Create(emptyVec, loadValue, index1, “”);
InsertVal->insertBefore(pInst);

It turned out that the way I am doing is not right because the output is <2 x double*>. Any help will be appreciated!

BTW, can I use bitcastInst (if so, how?) or I have to use insertelementInst?

Thanks,

Zhi

The result of getelementptr is a pointer to double, you want a pointer
to 2 x double, not a type of 2 x double *.

So, you need to make a pointer to a 2 x double (writing from memory,
so syntax may be off, but conceptually this should be right)
vecPtrTy = Type::getUnqualPtr(VectorType:get(Type::getDoubleTy(), 2));

Thanks, Mats. But, it seems that there is no getUnqualPtr member function in Type.

Best,
Zhi

Sorry. You probably mean pointerType::getUnqual(VectorType::get(Type::getDoubleTy(LLVMContext), 2));