diff options
author | Matthew Simpson <mssimpso@codeaurora.org> | 2018-03-15 16:00:29 +0000 |
---|---|---|
committer | Matthew Simpson <mssimpso@codeaurora.org> | 2018-03-15 16:00:29 +0000 |
commit | c1c4ad6e64fc0037f4f21952bc6d1a569bce2fa1 (patch) | |
tree | 4336aca3876235b0a7e20243a3ae58b4ea25bdbb /llvm/lib/Analysis/InstructionSimplify.cpp | |
parent | f3de222b0d3c169985ba9d61f479f3e8a3675100 (diff) | |
download | bcm5719-llvm-c1c4ad6e64fc0037f4f21952bc6d1a569bce2fa1.tar.gz bcm5719-llvm-c1c4ad6e64fc0037f4f21952bc6d1a569bce2fa1.zip |
[ConstantFolding, InstSimplify] Handle more vector GEPs
This patch addresses some additional cases where the compiler crashes upon
encountering vector GEPs. This should fix PR36116.
Differential Revision: https://reviews.llvm.org/D44219
Reference: https://bugs.llvm.org/show_bug.cgi?id=36116
llvm-svn: 327638
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 5e43cb7cec1..67669c2eca1 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -3723,7 +3723,7 @@ static Value *SimplifyGEPInst(Type *SrcTy, ArrayRef<Value *> Ops, if (Ops.size() == 2) { // getelementptr P, 0 -> P. - if (match(Ops[1], m_Zero())) + if (match(Ops[1], m_Zero()) && Ops[0]->getType() == GEPTy) return Ops[0]; Type *Ty = SrcTy; @@ -3732,7 +3732,7 @@ static Value *SimplifyGEPInst(Type *SrcTy, ArrayRef<Value *> Ops, uint64_t C; uint64_t TyAllocSize = Q.DL.getTypeAllocSize(Ty); // getelementptr P, N -> P if P points to a type of zero size. - if (TyAllocSize == 0) + if (TyAllocSize == 0 && Ops[0]->getType() == GEPTy) return Ops[0]; // The following transforms are only safe if the ptrtoint cast |