From 11ca2971e88f37dc1b40f00542cb6228e255fee4 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Wed, 27 Aug 2014 20:08:34 +0000 Subject: 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 --- llvm/lib/Analysis/InstructionSimplify.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'llvm/lib') diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 118579d5b72..9f3b2876afe 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -2837,7 +2837,8 @@ static Value *SimplifyGEPInst(ArrayRef 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; }; -- cgit v1.2.3