]> granicus.if.org Git - llvm/commitdiff
[ConstantFolding] Fix bitcast vector of i1.
authorIgor Breger <igor.breger@intel.com>
Mon, 27 Jun 2016 06:42:54 +0000 (06:42 +0000)
committerIgor Breger <igor.breger@intel.com>
Mon, 27 Jun 2016 06:42:54 +0000 (06:42 +0000)
Differential Revision: http://reviews.llvm.org/D21735

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273845 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ConstantFolding.cpp
test/Transforms/InstCombine/bitcast.ll

index 5bf5539f5c9758b2d7d1cf6a33b5ebb54b78cd36..0a9d725db5827574e4842117ae9d0cbba37f33aa 100644 (file)
@@ -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;
index 254b6116e4cc5930fba47575597ba71afedb6b9f..74958596f23f3e449b24ffe8849a5a8e8006cdae 100644 (file)
@@ -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> <i1 true, i1 true, i1 false, i1 true, i1 false, i1 true, i1 false, i1 true> to i8
+  ret i8 %res
+; CHECK: @test8
+; CHECK: ret i8 -85
+}