diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp index 5bf5539f5c9..0a9d725db58 100644 --- a/lib/Analysis/ConstantFolding.cpp +++ b/lib/Analysis/ConstantFolding.cpp @@ -81,7 +81,7 @@ Constant *FoldBitCast(Constant *C, Type *DestTy, const DataLayout &DL) { // Now that we know that the input value is a vector of integers, just shift // and insert them into our result. - unsigned BitShift = DL.getTypeAllocSizeInBits(SrcEltTy); + unsigned BitShift = DL.getTypeSizeInBits(SrcEltTy); APInt Result(IT->getBitWidth(), 0); for (unsigned i = 0; i != NumSrcElts; ++i) { Constant *Element; diff --git a/test/Transforms/InstCombine/bitcast.ll b/test/Transforms/InstCombine/bitcast.ll index 254b6116e4c..74958596f23 100644 --- a/test/Transforms/InstCombine/bitcast.ll +++ b/test/Transforms/InstCombine/bitcast.ll @@ -262,3 +262,10 @@ define <2 x i64> @test7(<2 x i8*>* %arg) nounwind { ; CHECK: bitcast ; CHECK: load } + +define i8 @test8() { + %res = bitcast <8 x i1> to i8 + ret i8 %res +; CHECK: @test8 +; CHECK: ret i8 -85 +}