aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-02-22 04:06:03 +0000
committerDan Gohman <gohman@apple.com>2010-02-22 04:06:03 +0000
commit6b617a7213e159097a7e5c7216ed9b04921de4e1 (patch)
tree27a7e2217ae39fda6010dcfa0aa7ef804088467c /lib
parent31a95c524c82e36867761404d902b94f7afc695e (diff)
downloadexternal_llvm-6b617a7213e159097a7e5c7216ed9b04921de4e1.zip
external_llvm-6b617a7213e159097a7e5c7216ed9b04921de4e1.tar.gz
external_llvm-6b617a7213e159097a7e5c7216ed9b04921de4e1.tar.bz2
Constant-fold certain comparisons with infinity and negative infinity.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96777 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/InstructionSimplify.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp
index b53ac13..1f8053a 100644
--- a/lib/Analysis/InstructionSimplify.cpp
+++ b/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;
+ }
+ }
+ }
}
}