summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2012-02-25 20:19:07 +0000
committerNick Lewycky <nicholas@mxc.ca>2012-02-25 20:19:07 +0000
commiteeeffbb497e7611dc8445924bfe47c54c94b8c5c (patch)
tree6ad3b0583477d5a0f6732d98c98f571d9b4716aa /llvm/lib/Analysis
parent167d0fbb8adc7d42b4d99df6b823fe411cacec1f (diff)
downloadbcm5719-llvm-eeeffbb497e7611dc8445924bfe47c54c94b8c5c.tar.gz
bcm5719-llvm-eeeffbb497e7611dc8445924bfe47c54c94b8c5c.zip
An argument and a local identified object (eg. a noalias call) could turn out
equal if both are null. In the test, scope type %t and global @y by adding a 'gep' prefix to them. llvm-svn: 151452
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 11afa851597..93f55684c24 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -1626,21 +1626,22 @@ static Value *SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS,
LHSPtr = stripPointerAdjustments(LHSPtr);
if (llvm::isIdentifiedObject(LHSPtr)) {
RHSPtr = stripPointerAdjustments(RHSPtr);
- // If both sides are different identified objects, they aren't equal unless
- // they're null.
- if (LHSPtr != RHSPtr && llvm::isIdentifiedObject(RHSPtr) &&
- (llvm::isKnownNonNull(LHSPtr) || llvm::isKnownNonNull(RHSPtr)))
- return ConstantInt::get(ITy, CmpInst::isFalseWhenEqual(Pred));
+ if (llvm::isKnownNonNull(LHSPtr) || llvm::isKnownNonNull(RHSPtr)) {
+ // If both sides are different identified objects, they aren't equal
+ // unless they're null.
+ if (LHSPtr != RHSPtr && llvm::isIdentifiedObject(RHSPtr))
+ return ConstantInt::get(ITy, CmpInst::isFalseWhenEqual(Pred));
+
+ // A local identified object (alloca or noalias call) can't equal any
+ // incoming argument, unless they're both null.
+ if ((isa<Instruction>(LHSPtr) && isa<Argument>(RHSPtr)) ||
+ (isa<Instruction>(RHSPtr) && isa<Argument>(LHSPtr)))
+ return ConstantInt::get(ITy, CmpInst::isFalseWhenEqual(Pred));
+ }
- // Assume that the null is on the right.
+ // Assume that the constant null is on the right.
if (llvm::isKnownNonNull(LHSPtr) && isa<ConstantPointerNull>(RHSPtr))
return ConstantInt::get(ITy, CmpInst::isFalseWhenEqual(Pred));
-
- // A local instruction (alloca or noalias call) can't equal any incoming
- // argument.
- if ((isa<Instruction>(LHSPtr) && isa<Argument>(RHSPtr)) ||
- (isa<Instruction>(RHSPtr) && isa<Argument>(LHSPtr)))
- return ConstantInt::get(ITy, CmpInst::isFalseWhenEqual(Pred));
}
// If we are comparing with zero then try hard since this is a common case.
OpenPOWER on IntegriCloud