diff options
author | Nate Begeman <natebegeman@mac.com> | 2005-08-11 02:18:13 +0000 |
---|---|---|
committer | Nate Begeman <natebegeman@mac.com> | 2005-08-11 02:18:13 +0000 |
commit | 5c7656fd537bd8929e1569f0e319b5be560f2b90 (patch) | |
tree | e1654877545fcd9e43577e0b3e99a612afd0b46a /llvm/lib/CodeGen | |
parent | 180b08897fbc240bc642fe330ed0663dd58293fc (diff) | |
download | bcm5719-llvm-5c7656fd537bd8929e1569f0e319b5be560f2b90.tar.gz bcm5719-llvm-5c7656fd537bd8929e1569f0e319b5be560f2b90.zip |
Add a select_cc optimization for recognizing abs(int). This speeds up an
integer MPEG encoding loop by a factor of two.
llvm-svn: 22758
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index e331c4a60bd..12482efd708 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -1495,6 +1495,22 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT, return getNode(ISD::AND, AType, Shift, N3); } } + + // Check to see if this is an integer abs. select_cc setl[te] X, 0, -X, X -> + // Y = sra (X, size(X)-1); xor (add (X, Y), Y) + if (N2C && N2C->isNullValue() && (CC == ISD::SETLT || CC == ISD::SETLE) && + N1 == N4 && N3.getOpcode() == ISD::SUB && N1 == N3.getOperand(1)) { + if (ConstantSDNode *SubC = dyn_cast<ConstantSDNode>(N3.getOperand(0))) { + MVT::ValueType XType = N1.getValueType(); + if (SubC->isNullValue() && MVT::isInteger(XType)) { + SDOperand Shift = getNode(ISD::SRA, XType, N1, + getConstant(MVT::getSizeInBits(XType)-1, + TLI.getShiftAmountTy())); + return getNode(ISD::XOR, XType, getNode(ISD::ADD, XType, N1, Shift), + Shift); + } + } + } } std::vector<SDOperand> Ops; |