+ if (const VectorType *DestVTy = dyn_cast<VectorType>(DestTy)) {
+ if (DestVTy->getNumElements() == 1) {
+ if (!isa<VectorType>(SrcTy)) {
+ Value *Elem = InsertCastBefore(Instruction::BitCast, Src,
+ DestVTy->getElementType(), CI);
+ return InsertElementInst::Create(Context->getUndef(DestTy), Elem,
+ Context->getNullValue(Type::Int32Ty));
+ }
+ // FIXME: Canonicalize bitcast(insertelement) -> insertelement(bitcast)
+ }
+ }
+
+ if (const VectorType *SrcVTy = dyn_cast<VectorType>(SrcTy)) {
+ if (SrcVTy->getNumElements() == 1) {
+ if (!isa<VectorType>(DestTy)) {
+ Instruction *Elem =
+ new ExtractElementInst(Src, Context->getNullValue(Type::Int32Ty));
+ InsertNewInstBefore(Elem, CI);
+ return CastInst::Create(Instruction::BitCast, Elem, DestTy);
+ }
+ }
+ }
+