diff options
author | Mon P Wang <wangmp@apple.com> | 2009-01-17 00:07:25 +0000 |
---|---|---|
committer | Mon P Wang <wangmp@apple.com> | 2009-01-17 00:07:25 +0000 |
commit | 7ac9cdfc991db344a1e0f642aefc6db6b868b9b0 (patch) | |
tree | de2838d4b126bf8e913a5247e83cd9f3abb86fe5 /lib | |
parent | de62aeaec49ddcf4a4c61fbbb3a22d3a4dd448f0 (diff) | |
download | external_llvm-7ac9cdfc991db344a1e0f642aefc6db6b868b9b0.zip external_llvm-7ac9cdfc991db344a1e0f642aefc6db6b868b9b0.tar.gz external_llvm-7ac9cdfc991db344a1e0f642aefc6db6b868b9b0.tar.bz2 |
Simplify extract element of a scalar to vector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62383 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index f8b9142..230079b 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -4878,16 +4878,24 @@ SDValue DAGCombiner::visitINSERT_VECTOR_ELT(SDNode *N) { } SDValue DAGCombiner::visitEXTRACT_VECTOR_ELT(SDNode *N) { - // (vextract (v4f32 load $addr), c) -> (f32 load $addr+c*size) - // (vextract (v4f32 s2v (f32 load $addr)), c) -> (f32 load $addr+c*size) - // (vextract (v4f32 shuffle (load $addr), <1,u,u,u>), 0) -> (f32 load $addr) + // (vextract (scalar_to_vector val, 0) -> val + SDValue InVec = N->getOperand(0); + SDValue EltNo = N->getOperand(1); + + if (isa<ConstantSDNode>(EltNo)) { + unsigned Elt = cast<ConstantSDNode>(EltNo)->getZExtValue(); + if (InVec.getOpcode() == ISD::SCALAR_TO_VECTOR && Elt == 0) { + return InVec.getOperand(0); + } + } // Perform only after legalization to ensure build_vector / vector_shuffle // optimizations have already been done. if (!LegalOperations) return SDValue(); - SDValue InVec = N->getOperand(0); - SDValue EltNo = N->getOperand(1); + // (vextract (v4f32 load $addr), c) -> (f32 load $addr+c*size) + // (vextract (v4f32 s2v (f32 load $addr)), c) -> (f32 load $addr+c*size) + // (vextract (v4f32 shuffle (load $addr), <1,u,u,u>), 0) -> (f32 load $addr) if (isa<ConstantSDNode>(EltNo)) { unsigned Elt = cast<ConstantSDNode>(EltNo)->getZExtValue(); |