Index: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp =================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp @@ -2475,11 +2475,12 @@ Type *SelectorTy = Type::getInt1Ty(Context); - // If CurTy is a vector of length n, then Record[0] must be a - // vector. Otherwise, it must be a single bit. + // The selector might be an i1 or an + // Get the type from the ValueList before getting a forward ref. if (VectorType *VTy = dyn_cast(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), Index: llvm/trunk/test/Bitcode/select.ll =================================================================== --- llvm/trunk/test/Bitcode/select.ll +++ llvm/trunk/test/Bitcode/select.ll @@ -8,3 +8,11 @@ ; CHECK: define <2 x i32> @main() { ; CHECK: ret <2 x i32> ; CHECK: } + +define <2 x float> @f() { + ret <2 x float> select (i1 ptrtoint (<2 x float> ()* @f to i1), <2 x float> , <2 x float> zeroinitializer) +} + +; CHECK: define <2 x float> @f() { +; CHECK: ret <2 x float> select (i1 ptrtoint (<2 x float> ()* @f to i1), <2 x float> , <2 x float> zeroinitializer) +; CHECK: }