diff options
| author | Reid Spencer <rspencer@reidspencer.com> | 2007-01-11 00:25:45 +0000 |
|---|---|---|
| committer | Reid Spencer <rspencer@reidspencer.com> | 2007-01-11 00:25:45 +0000 |
| commit | 74bd0360596cb306da06bfd5d94b5dc4665ca301 (patch) | |
| tree | c5ca7e4cd1c6d607e75f7bc34ab07281c30ce976 /llvm | |
| parent | 15701b5c0d45f5da40a790dc709eb6b52f19c29d (diff) | |
| download | bcm5719-llvm-74bd0360596cb306da06bfd5d94b5dc4665ca301.tar.gz bcm5719-llvm-74bd0360596cb306da06bfd5d94b5dc4665ca301.zip | |
Implement better constant folding of unordered FCMP predicates.
llvm-svn: 33063
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/VMCore/ConstantFolding.cpp | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/llvm/lib/VMCore/ConstantFolding.cpp b/llvm/lib/VMCore/ConstantFolding.cpp index 6215bdd438b..fffba1e6f94 100644 --- a/llvm/lib/VMCore/ConstantFolding.cpp +++ b/llvm/lib/VMCore/ConstantFolding.cpp @@ -1110,18 +1110,38 @@ Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred, case FCmpInst::FCMP_FALSE: return ConstantBool::getFalse(); case FCmpInst::FCMP_TRUE: return ConstantBool::getTrue(); case FCmpInst::FCMP_UNO: - case FCmpInst::FCMP_ORD: break; // Can't fold these + return ConstantBool::get(C1Val != C1Val || C2Val != C2Val); + case FCmpInst::FCMP_ORD: + return ConstantBool::get(C1Val == C1Val && C2Val == C2Val); case FCmpInst::FCMP_UEQ: + if (C1Val != C1Val || C2Val != C2Val) + return ConstantBool::getTrue(); + /* FALL THROUGH */ case FCmpInst::FCMP_OEQ: return ConstantBool::get(C1Val == C2Val); - case FCmpInst::FCMP_ONE: - case FCmpInst::FCMP_UNE: return ConstantBool::get(C1Val != C2Val); - case FCmpInst::FCMP_OLT: - case FCmpInst::FCMP_ULT: return ConstantBool::get(C1Val < C2Val); + case FCmpInst::FCMP_UNE: + if (C1Val != C1Val || C2Val != C2Val) + return ConstantBool::getTrue(); + /* FALL THROUGH */ + case FCmpInst::FCMP_ONE: return ConstantBool::get(C1Val != C2Val); + case FCmpInst::FCMP_ULT: + if (C1Val != C1Val || C2Val != C2Val) + return ConstantBool::getTrue(); + /* FALL THROUGH */ + case FCmpInst::FCMP_OLT: return ConstantBool::get(C1Val < C2Val); case FCmpInst::FCMP_UGT: + if (C1Val != C1Val || C2Val != C2Val) + return ConstantBool::getTrue(); + /* FALL THROUGH */ case FCmpInst::FCMP_OGT: return ConstantBool::get(C1Val > C2Val); - case FCmpInst::FCMP_OLE: - case FCmpInst::FCMP_ULE: return ConstantBool::get(C1Val <= C2Val); + case FCmpInst::FCMP_ULE: + if (C1Val != C1Val || C2Val != C2Val) + return ConstantBool::getTrue(); + /* FALL THROUGH */ + case FCmpInst::FCMP_OLE: return ConstantBool::get(C1Val <= C2Val); case FCmpInst::FCMP_UGE: + if (C1Val != C1Val || C2Val != C2Val) + return ConstantBool::getTrue(); + /* FALL THROUGH */ case FCmpInst::FCMP_OGE: return ConstantBool::get(C1Val >= C2Val); } } else if (const ConstantPacked *CP1 = dyn_cast<ConstantPacked>(C1)) { |

