[PATCH] D26060: [ConstantFolding] Don't try to cast vectors to pointer if they have different size
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 27 19:35:21 PDT 2016
davide created this revision.
davide added reviewers: majnemer, RKSimon, filcab, Bigcheese.
davide added a subscriber: llvm-commits.
An attempt to fix the bug reported by Michael on https://reviews.llvm.org/D26014
https://reviews.llvm.org/D26060
Files:
lib/Analysis/ConstantFolding.cpp
test/Transforms/InstCombine/gep-vector.ll
Index: test/Transforms/InstCombine/gep-vector.ll
===================================================================
--- test/Transforms/InstCombine/gep-vector.ll
+++ test/Transforms/InstCombine/gep-vector.ll
@@ -13,3 +13,13 @@
%el = getelementptr inbounds i64, i64* undef, <8 x i64> undef
ret <8 x i64*> %el
}
+
+%struct.foo = type { [0 x i64] }
+
+; CHECK-LABEL: patatino3
+; CHECK-NEXT: ret <8 x i64*> undef
+define <8 x i64*> @patatino3(%struct.foo*) {
+ %2 = getelementptr inbounds %struct.foo, %struct.foo* undef, i64 0,
+ i32 0, <8 x i64> undef
+ ret <8 x i64*> %2
+}
Index: lib/Analysis/ConstantFolding.cpp
===================================================================
--- lib/Analysis/ConstantFolding.cpp
+++ lib/Analysis/ConstantFolding.cpp
@@ -726,9 +726,11 @@
SmallVector<Constant*, 32> NewIdxs;
for (unsigned i = 1, e = Ops.size(); i != e; ++i) {
if ((i == 1 ||
- !isa<StructType>(GetElementPtrInst::getIndexedType(SrcElemTy,
- Ops.slice(1, i - 1)))) &&
- Ops[i]->getType() != IntPtrTy) {
+ !isa<StructType>(GetElementPtrInst::getIndexedType(
+ SrcElemTy, Ops.slice(1, i - 1)))) &&
+ Ops[i]->getType() != IntPtrTy && IntPtrTy->isVectorTy() &&
+ Ops[i]->getType()->getPrimitiveSizeInBits() ==
+ IntPtrTy->getPrimitiveSizeInBits()) {
Any = true;
NewIdxs.push_back(ConstantExpr::getCast(CastInst::getCastOpcode(Ops[i],
true,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26060.76158.patch
Type: text/x-patch
Size: 1548 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161028/5b0fe6c1/attachment.bin>
More information about the llvm-commits
mailing list