aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/InstructionSimplify.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-08-27 20:08:34 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-08-27 20:08:34 +0000
commit11ca2971e88f37dc1b40f00542cb6228e255fee4 (patch)
treea5f723b13e06407de3cda365680ad038ae39df81 /llvm/lib/Analysis/InstructionSimplify.cpp
parent48c82400edc6244073fa90dcd805b23e0d077d79 (diff)
downloadllvm-11ca2971e88f37dc1b40f00542cb6228e255fee4.zip
llvm-11ca2971e88f37dc1b40f00542cb6228e255fee4.tar.gz
llvm-11ca2971e88f37dc1b40f00542cb6228e255fee4.tar.bz2
InstSimplify: Don't simplify gep X, (Y-X) to Y if types differ
It's incorrect to perform this simplification if the types differ. A bitcast would need to be inserted for this to work. This fixes PR20771. llvm-svn: 216597
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 118579d..9f3b2876 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -2837,7 +2837,8 @@ static Value *SimplifyGEPInst(ArrayRef<Value *> Ops, const Query &Q, unsigned) {
return Constant::getNullValue(GEPTy);
Value *Temp;
if (match(P, m_PtrToInt(m_Value(Temp))))
- return Temp;
+ if (Temp->getType() == GEPTy)
+ return Temp;
return nullptr;
};