diff options
author | Chris Lattner <sabre@nondot.org> | 2006-05-06 23:05:41 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-05-06 23:05:41 +0000 |
commit | 751817c54fdf5381a46c0e448d01e0179a31563f (patch) | |
tree | 45b9c1b9c50e7b556e7cfbf6f3cbb53ae38138b6 /llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | |
parent | 2a4d7b845b0036cb054aef8b9acb558122a70d2f (diff) | |
download | bcm5719-llvm-751817c54fdf5381a46c0e448d01e0179a31563f.tar.gz bcm5719-llvm-751817c54fdf5381a46c0e448d01e0179a31563f.zip |
constant fold sign_extend_inreg
llvm-svn: 28151
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 4809db47756..60a749df2f7 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -1335,6 +1335,14 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT, ConstantSDNode *N1C = dyn_cast<ConstantSDNode>(N1.Val); ConstantSDNode *N2C = dyn_cast<ConstantSDNode>(N2.Val); if (N1C) { + if (Opcode == ISD::SIGN_EXTEND_INREG) { + int64_t Val = N1C->getValue(); + unsigned FromBits = MVT::getSizeInBits(cast<VTSDNode>(N2)->getVT()); + Val <<= 64-FromBits; + Val >>= 64-FromBits; + return getConstant(Val, VT); + } + if (N2C) { uint64_t C1 = N1C->getValue(), C2 = N2C->getValue(); switch (Opcode) { @@ -1441,7 +1449,7 @@ SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT, } } - // Fold a bunch of operators that + // Fold a bunch of operators when the RHS is undef. if (N2.getOpcode() == ISD::UNDEF) { switch (Opcode) { case ISD::ADD: |