diff options
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 10b6b76da4..3e5395bd34 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -1060,17 +1060,30 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT, SDOperand LR = LHS->getOperand(1), RR = RHS->getOperand(1); ISD::CondCode Op2 = RHS->getCondition(); - // (X != 0) | (Y != 0) -> (X|Y != 0) - // (X == 0) & (Y == 0) -> (X|Y == 0) - // (X < 0) | (Y < 0) -> (X|Y < 0) if (LR == RR && isa<ConstantSDNode>(LR) && - cast<ConstantSDNode>(LR)->getValue() == 0 && Op2 == LHS->getCondition() && MVT::isInteger(LL.getValueType())) { - if ((Op2 == ISD::SETEQ && Opcode == ISD::AND) || - (Op2 == ISD::SETNE && Opcode == ISD::OR) || - (Op2 == ISD::SETLT && Opcode == ISD::OR)) + // (X != 0) | (Y != 0) -> (X|Y != 0) + // (X == 0) & (Y == 0) -> (X|Y == 0) + // (X < 0) | (Y < 0) -> (X|Y < 0) + if (cast<ConstantSDNode>(LR)->getValue() == 0 && + ((Op2 == ISD::SETEQ && Opcode == ISD::AND) || + (Op2 == ISD::SETNE && Opcode == ISD::OR) || + (Op2 == ISD::SETLT && Opcode == ISD::OR))) return getSetCC(Op2, VT, getNode(ISD::OR, LR.getValueType(), LL, RL), LR); + + if (cast<ConstantSDNode>(LR)->isAllOnesValue()) { + // (X == -1) & (Y == -1) -> (X&Y == -1) + // (X != -1) | (Y != -1) -> (X&Y != -1) + if ((Opcode == ISD::AND && Op2 == ISD::SETEQ) || + (Opcode == ISD::OR && Op2 == ISD::SETNE)) + return getSetCC(Op2, VT, + getNode(ISD::AND, LR.getValueType(), LL, RL), LR); + // (X > -1) & (Y > -1) -> (X|Y > -1) + if (Opcode == ISD::AND && Op2 == ISD::SETGT) + return getSetCC(Op2, VT, + getNode(ISD::OR, LR.getValueType(), LL, RL), LR); + } } // (X op1 Y) | (Y op2 X) -> (X op1 Y) | (X swapop2 Y) |