summaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2008-10-14 18:13:38 +0000
committerEvan Cheng <evan.cheng@apple.com>2008-10-14 18:13:38 +0000
commit4990b257dd22ef5804fd93742ac5e8621c4d1608 (patch)
treeb1658fc0d96d2be75b499e197668970ad3cf4d66 /lib/Transforms
parent552e3be775c3ed9ff79e3002b369c5267633f72b (diff)
downloadllvm-4990b257dd22ef5804fd93742ac5e8621c4d1608.tar.gz
llvm-4990b257dd22ef5804fd93742ac5e8621c4d1608.tar.bz2
llvm-4990b257dd22ef5804fd93742ac5e8621c4d1608.tar.xz
- Somehow I forgot about one / une.
- Renumber fcmp predicates to match their icmp counterparts. - Try swapping operands to expose more optimization opportunities. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57513 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 391e61e074..a687dbde10 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -3124,14 +3124,16 @@ static unsigned getFCmpCode(FCmpInst::Predicate CC, bool &isOrdered) {
switch (CC) {
case FCmpInst::FCMP_ORD: isOrdered = true; return 0; // 000
case FCmpInst::FCMP_UNO: return 0; // 000
- case FCmpInst::FCMP_OEQ: isOrdered = true; return 1; // 001
- case FCmpInst::FCMP_UEQ: return 1; // 001
- case FCmpInst::FCMP_OGT: isOrdered = true; return 2; // 010
- case FCmpInst::FCMP_UGT: return 2; // 010
+ case FCmpInst::FCMP_OGT: isOrdered = true; return 1; // 001
+ case FCmpInst::FCMP_UGT: return 1; // 001
+ case FCmpInst::FCMP_OEQ: isOrdered = true; return 2; // 010
+ case FCmpInst::FCMP_UEQ: return 2; // 010
case FCmpInst::FCMP_OGE: isOrdered = true; return 3; // 011
case FCmpInst::FCMP_UGE: return 3; // 011
case FCmpInst::FCMP_OLT: isOrdered = true; return 4; // 100
case FCmpInst::FCMP_ULT: return 4; // 100
+ case FCmpInst::FCMP_ONE: isOrdered = true; return 5; // 101
+ case FCmpInst::FCMP_UNE: return 5; // 101
case FCmpInst::FCMP_OLE: isOrdered = true; return 6; // 110
case FCmpInst::FCMP_ULE: return 6; // 110
default:
@@ -3181,7 +3183,7 @@ static Value *getICmpValue(bool sign, unsigned code, Value *LHS, Value *RHS) {
static Value *getFCmpValue(bool isordered, unsigned code,
Value *LHS, Value *RHS) {
switch (code) {
- default: assert(0 && "Illegal ICmp code!");
+ default: assert(0 && "Illegal FCmp code!");
case 0:
if (isordered)
return new FCmpInst(FCmpInst::FCMP_ORD, LHS, RHS);
@@ -3189,14 +3191,14 @@ static Value *getFCmpValue(bool isordered, unsigned code,
return new FCmpInst(FCmpInst::FCMP_UNO, LHS, RHS);
case 1:
if (isordered)
- return new FCmpInst(FCmpInst::FCMP_OEQ, LHS, RHS);
+ return new FCmpInst(FCmpInst::FCMP_OGT, LHS, RHS);
else
- return new FCmpInst(FCmpInst::FCMP_UEQ, LHS, RHS);
+ return new FCmpInst(FCmpInst::FCMP_UGT, LHS, RHS);
case 2:
if (isordered)
- return new FCmpInst(FCmpInst::FCMP_OGT, LHS, RHS);
+ return new FCmpInst(FCmpInst::FCMP_OEQ, LHS, RHS);
else
- return new FCmpInst(FCmpInst::FCMP_UGT, LHS, RHS);
+ return new FCmpInst(FCmpInst::FCMP_UEQ, LHS, RHS);
case 3:
if (isordered)
return new FCmpInst(FCmpInst::FCMP_OGE, LHS, RHS);
@@ -3209,6 +3211,11 @@ static Value *getFCmpValue(bool isordered, unsigned code,
return new FCmpInst(FCmpInst::FCMP_ULT, LHS, RHS);
case 5:
if (isordered)
+ return new FCmpInst(FCmpInst::FCMP_ONE, LHS, RHS);
+ else
+ return new FCmpInst(FCmpInst::FCMP_UNE, LHS, RHS);
+ case 6:
+ if (isordered)
return new FCmpInst(FCmpInst::FCMP_OLE, LHS, RHS);
else
return new FCmpInst(FCmpInst::FCMP_ULE, LHS, RHS);
@@ -3973,6 +3980,11 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
FCmpInst::Predicate Op0CC, Op1CC;
if (match(Op0, m_FCmp(Op0CC, m_Value(Op0LHS), m_Value(Op0RHS))) &&
match(Op1, m_FCmp(Op1CC, m_Value(Op1LHS), m_Value(Op1RHS)))) {
+ if (Op0LHS == Op1RHS && Op0RHS == Op1LHS) {
+ // Swap RHS operands to match LHS.
+ Op1CC = FCmpInst::getSwappedPredicate(Op1CC);
+ std::swap(Op1LHS, Op1RHS);
+ }
if (Op0LHS == Op1LHS && Op0RHS == Op1RHS) {
// Simplify (fcmp cc0 x, y) & (fcmp cc1 x, y).
if (Op0CC == Op1CC)