Type *SelectorTy = Type::getInt1Ty(Context);
- // If CurTy is a vector of length n, then Record[0] must be a <n x i1>
- // vector. Otherwise, it must be a single bit.
+ // The selector might be an i1 or an <n x i1>
+ // Get the type from the ValueList before getting a forward ref.
if (VectorType *VTy = dyn_cast<VectorType>(CurTy))
- SelectorTy = VectorType::get(Type::getInt1Ty(Context),
- VTy->getNumElements());
+ if (Value *V = ValueList[Record[0]])
+ if (SelectorTy != V->getType())
+ SelectorTy = VectorType::get(SelectorTy, VTy->getNumElements());
V = ConstantExpr::getSelect(ValueList.getConstantFwdRef(Record[0],
SelectorTy),