diff options
author | Dan Gohman <gohman@apple.com> | 2010-02-22 04:06:03 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-02-22 04:06:03 +0000 |
commit | 754e4a98011c2b88473ea35bfc20d831ae7871b1 (patch) | |
tree | a0ae79166d89474fded14a82474722937063be25 /llvm/lib | |
parent | bf7b192f448f40e9cc4fc00ff3413a0c1f285337 (diff) | |
download | bcm5719-llvm-754e4a98011c2b88473ea35bfc20d831ae7871b1.tar.gz bcm5719-llvm-754e4a98011c2b88473ea35bfc20d831ae7871b1.zip |
Constant-fold certain comparisons with infinity and negative infinity.
llvm-svn: 96777
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index b53ac13925b..1f8053afe94 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -283,6 +283,32 @@ Value *llvm::SimplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS, // True if unordered. return ConstantInt::getTrue(CFP->getContext()); } + // Check whether the constant is an infinity. + if (CFP->getValueAPF().isInfinity()) { + if (CFP->getValueAPF().isNegative()) { + switch (Pred) { + case FCmpInst::FCMP_OLT: + // No value is ordered and less than negative infinity. + return ConstantInt::getFalse(CFP->getContext()); + case FCmpInst::FCMP_UGE: + // All values are unordered with or at least negative infinity. + return ConstantInt::getTrue(CFP->getContext()); + default: + break; + } + } else { + switch (Pred) { + case FCmpInst::FCMP_OGT: + // No value is ordered and greater than infinity. + return ConstantInt::getFalse(CFP->getContext()); + case FCmpInst::FCMP_ULE: + // All values are unordered with and at most infinity. + return ConstantInt::getTrue(CFP->getContext()); + default: + break; + } + } + } } } |