summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/InstructionSimplify.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-03-03 19:46:03 +0000
committerChris Lattner <sabre@nondot.org>2010-03-03 19:46:03 +0000
commit3afc0721c766db6942e79597a9b2e10fe0824194 (patch)
tree2b0d525efc17ad2fcffbf6f8cda0d80a7b476783 /llvm/lib/Analysis/InstructionSimplify.cpp
parenta529c2555560596376e77512490b4945f720d999 (diff)
downloadbcm5719-llvm-3afc0721c766db6942e79597a9b2e10fe0824194.tar.gz
bcm5719-llvm-3afc0721c766db6942e79597a9b2e10fe0824194.zip
fix incorrect folding of icmp with undef, PR6481.
llvm-svn: 97659
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 1f8053afe94..8288e96eb77 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -194,11 +194,10 @@ Value *llvm::SimplifyICmpInst(unsigned Predicate, Value *LHS, Value *RHS,
const Type *ITy = GetCompareTy(LHS);
// icmp X, X -> true/false
- if (LHS == RHS)
+ // X icmp undef -> true/false. For example, icmp ugt %X, undef -> false
+ // because X could be 0.
+ if (LHS == RHS || isa<UndefValue>(RHS))
return ConstantInt::get(ITy, CmpInst::isTrueWhenEqual(Pred));
-
- if (isa<UndefValue>(RHS)) // X icmp undef -> undef
- return UndefValue::get(ITy);
// icmp <global/alloca*/null>, <global/alloca*/null> - Global/Stack value
// addresses never equal each other! We already know that Op0 != Op1.
OpenPOWER on IntegriCloud