From 721c201bd55ffb73cb2ba8d39e0570fa38c44e15 Mon Sep 17 00:00:00 2001 From: dim Date: Wed, 15 Aug 2012 19:34:23 +0000 Subject: Vendor import of llvm trunk r161861: http://llvm.org/svn/llvm-project/llvm/trunk@161861 --- lib/Analysis/InstructionSimplify.cpp | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'lib/Analysis/InstructionSimplify.cpp') diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp index 16e7a72..379a35a 100644 --- a/lib/Analysis/InstructionSimplify.cpp +++ b/lib/Analysis/InstructionSimplify.cpp @@ -47,7 +47,7 @@ struct Query { const DominatorTree *DT; Query(const TargetData *td, const TargetLibraryInfo *tli, - const DominatorTree *dt) : TD(td), TLI(tli), DT(dt) {}; + const DominatorTree *dt) : TD(td), TLI(tli), DT(dt) {} }; static Value *SimplifyAndInst(Value *, Value *, const Query &, unsigned); @@ -1719,10 +1719,13 @@ static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, return ConstantInt::get(ITy, false); // A local identified object (alloca or noalias call) can't equal any - // incoming argument, unless they're both null. - if (isa(LHSPtr) && isa(RHSPtr) && - Pred == CmpInst::ICMP_EQ) - return ConstantInt::get(ITy, false); + // incoming argument, unless they're both null or they belong to + // different functions. The latter happens during inlining. + if (Instruction *LHSInst = dyn_cast(LHSPtr)) + if (Argument *RHSArg = dyn_cast(RHSPtr)) + if (LHSInst->getParent()->getParent() == RHSArg->getParent() && + Pred == CmpInst::ICMP_EQ) + return ConstantInt::get(ITy, false); } // Assume that the constant null is on the right. @@ -1732,14 +1735,17 @@ static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS, else if (Pred == CmpInst::ICMP_NE) return ConstantInt::get(ITy, true); } - } else if (isa(LHSPtr)) { + } else if (Argument *LHSArg = dyn_cast(LHSPtr)) { RHSPtr = RHSPtr->stripInBoundsOffsets(); - // An alloca can't be equal to an argument. - if (isa(RHSPtr)) { - if (Pred == CmpInst::ICMP_EQ) - return ConstantInt::get(ITy, false); - else if (Pred == CmpInst::ICMP_NE) - return ConstantInt::get(ITy, true); + // An alloca can't be equal to an argument unless they come from separate + // functions via inlining. + if (AllocaInst *RHSInst = dyn_cast(RHSPtr)) { + if (LHSArg->getParent() == RHSInst->getParent()->getParent()) { + if (Pred == CmpInst::ICMP_EQ) + return ConstantInt::get(ITy, false); + else if (Pred == CmpInst::ICMP_NE) + return ConstantInt::get(ITy, true); + } } } -- cgit v1.1