[llvm] r273845 - [ConstantFolding] Fix bitcast vector of i1.
Igor Breger via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 26 23:42:54 PDT 2016
Author: ibreger
Date: Mon Jun 27 01:42:54 2016
New Revision: 273845
URL: http://llvm.org/viewvc/llvm-project?rev=273845&view=rev
Log:
[ConstantFolding] Fix bitcast vector of i1.
Differential Revision: http://reviews.llvm.org/D21735
Modified:
llvm/trunk/lib/Analysis/ConstantFolding.cpp
llvm/trunk/test/Transforms/InstCombine/bitcast.ll
Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=273845&r1=273844&r2=273845&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original)
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Mon Jun 27 01:42:54 2016
@@ -81,7 +81,7 @@ Constant *FoldBitCast(Constant *C, Type
// 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;
Modified: llvm/trunk/test/Transforms/InstCombine/bitcast.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/bitcast.ll?rev=273845&r1=273844&r2=273845&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/bitcast.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/bitcast.ll Mon Jun 27 01:42:54 2016
@@ -262,3 +262,10 @@ define <2 x i64> @test7(<2 x i8*>* %arg)
; 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
+}
More information about the llvm-commits
mailing list