diff options
author | Mon P Wang <wangmp@apple.com> | 2010-02-01 22:15:09 +0000 |
---|---|---|
committer | Mon P Wang <wangmp@apple.com> | 2010-02-01 22:15:09 +0000 |
commit | d74e0023c589273664250ba35506328784911107 (patch) | |
tree | 54b6226a0a81b3a01e6a431962fb5f7ece36ed5a /llvm/lib/CodeGen/SelectionDAG | |
parent | 47cbefac9461d1822dd7b70dcbcd74f2b162f711 (diff) | |
download | bcm5719-llvm-d74e0023c589273664250ba35506328784911107.tar.gz bcm5719-llvm-d74e0023c589273664250ba35506328784911107.zip |
Improve EXTRACT_VECTOR_ELT patch based on comments from Duncan
llvm-svn: 95012
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 15 |
2 files changed, 10 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 6729a93fd71..10487dabd28 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -5411,10 +5411,7 @@ SDValue DAGCombiner::visitEXTRACT_VECTOR_ELT(SDNode *N) { EVT NVT = N->getValueType(0); if (InOp.getValueType() != NVT) { assert(InOp.getValueType().isInteger() && NVT.isInteger()); - if (NVT.getSizeInBits() > InOp.getValueType().getSizeInBits()) - return DAG.getNode(ISD::SIGN_EXTEND, InVec.getDebugLoc(), NVT, InOp); - else - return DAG.getNode(ISD::TRUNCATE, InVec.getDebugLoc(), NVT, InOp); + return DAG.getSExtOrTrunc(InOp, InVec.getDebugLoc(), NVT); } return InOp; } diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 2e92f8f1fd1..5315b212601 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -2764,13 +2764,16 @@ SDValue SelectionDAG::getNode(unsigned Opcode, DebugLoc DL, EVT VT, // EXTRACT_VECTOR_ELT of INSERT_VECTOR_ELT is often formed when vector // operations are lowered to scalars. if (N1.getOpcode() == ISD::INSERT_VECTOR_ELT) { - // If the indices are the same, return the inserted element. - if (N1.getOperand(2) == N2 && VT == N1.getOperand(1).getValueType()) - return N1.getOperand(1); - // If the indices are known different, extract the element from + // If the indices are the same, return the inserted element else + // if the indices are known different, extract the element from // the original vector. - else if (isa<ConstantSDNode>(N1.getOperand(2)) && - isa<ConstantSDNode>(N2)) + if (N1.getOperand(2) == N2) { + if (VT == N1.getOperand(1).getValueType()) + return N1.getOperand(1); + else + return getSExtOrTrunc(N1.getOperand(1), DL, VT); + } else if (isa<ConstantSDNode>(N1.getOperand(2)) && + isa<ConstantSDNode>(N2)) return getNode(ISD::EXTRACT_VECTOR_ELT, DL, VT, N1.getOperand(0), N2); } break; |