diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-08-21 14:45:13 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-08-21 14:45:13 +0000 |
commit | f3ae9cc33edaaeb38384c6d43ac624886f96e1bd (patch) | |
tree | 18672dcc2ed9fcfc4d4c38b12bb9add1657755ff /llvm/lib/Analysis/InstructionSimplify.cpp | |
parent | b02b0ad8c78eab94b2c24333c5c378ffe90ea309 (diff) | |
download | bcm5719-llvm-f3ae9cc33edaaeb38384c6d43ac624886f96e1bd.tar.gz bcm5719-llvm-f3ae9cc33edaaeb38384c6d43ac624886f96e1bd.zip |
[InstSimplify] use isKnownNeverNaN to fold more fcmp ord/uno
Remove duplicate tests from InstCombine that were added with
D50582. I left negative tests there to verify that nothing
in InstCombine tries to go overboard. If isKnownNeverNaN is
improved to handle the FP binops or other cases, we should
have coverage under InstSimplify, so we could remove more
duplicate tests from InstCombine at that time.
llvm-svn: 340279
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 35aaf96d15b..290d169df24 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -3511,13 +3511,11 @@ static Value *SimplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS, if (Pred == FCmpInst::FCMP_TRUE) return getTrue(RetTy); - // UNO/ORD predicates can be trivially folded if NaNs are ignored. - if (FMF.noNaNs()) { - if (Pred == FCmpInst::FCMP_UNO) - return getFalse(RetTy); - if (Pred == FCmpInst::FCMP_ORD) - return getTrue(RetTy); - } + // Fold (un)ordered comparison if we can determine there are no NaNs. + if (Pred == FCmpInst::FCMP_UNO || Pred == FCmpInst::FCMP_ORD) + if (FMF.noNaNs() || + (isKnownNeverNaN(LHS, Q.TLI) && isKnownNeverNaN(RHS, Q.TLI))) + return ConstantInt::get(RetTy, Pred == FCmpInst::FCMP_ORD); // NaN is unordered; NaN is not ordered. assert((FCmpInst::isOrdered(Pred) || FCmpInst::isUnordered(Pred)) && |