[PATCH] D21735: [ConstantFolding] Fix bitcast vector of i1
Igor Breger via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 26 06:57:25 PDT 2016
igorb created this revision.
igorb added reviewers: craig.topper, majnemer, delena.
igorb added a subscriber: llvm-commits.
igorb set the repository for this revision to rL LLVM.
[ConstantFolding] Fix bitcast vector of i1.
StoreSizeInBytes of i1 is 8,so current implementation return incorrect result.
For example: bitcast <8 x i1> <i1 true, i1 true, i1 false, i1 true, i1 false, i1 true, i1 false, i1 true> to i8
converted to i8 1
Repository:
rL LLVM
http://reviews.llvm.org/D21735
Files:
lib/Analysis/ConstantFolding.cpp
test/Transforms/InstCombine/bitcast.ll
Index: test/Transforms/InstCombine/bitcast.ll
===================================================================
--- test/Transforms/InstCombine/bitcast.ll
+++ test/Transforms/InstCombine/bitcast.ll
@@ -262,3 +262,10 @@
; 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
+}
Index: lib/Analysis/ConstantFolding.cpp
===================================================================
--- lib/Analysis/ConstantFolding.cpp
+++ lib/Analysis/ConstantFolding.cpp
@@ -81,7 +81,7 @@
// 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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21735.61911.patch
Type: text/x-patch
Size: 1007 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160626/8e738e05/attachment.bin>
More information about the llvm-commits
mailing list