diff options
author | Quentin Colombet <qcolombet@apple.com> | 2013-07-30 00:24:09 +0000 |
---|---|---|
committer | Quentin Colombet <qcolombet@apple.com> | 2013-07-30 00:24:09 +0000 |
commit | 6bf4baa408c7042df5791adce351b317e5635e21 (patch) | |
tree | b3013d49a8af3a28c099013010b514ec1c22f47d /llvm/lib/CodeGen/SelectionDAG | |
parent | 6e10f149c4d0ec6fd8b0c6012b6c4d70dccb586d (diff) | |
download | bcm5719-llvm-6bf4baa408c7042df5791adce351b317e5635e21.tar.gz bcm5719-llvm-6bf4baa408c7042df5791adce351b317e5635e21.zip |
[DAGCombiner] insert_vector_elt: Avoid building a vector twice.
This patch prevents the following combine when the input vector is used more
than once.
insert_vector_elt (build_vector elt0, ..., eltN), NewEltIdx, idx
=>
build_vector elt0, ..., NewEltIdx, ..., eltN
The reasons are:
- Building a vector may be expensive, so try to reuse the existing part of a
vector instead of creating a new one (think big vectors).
- elt0 to eltN now have two users instead of one. This may prevent some other
optimizations.
llvm-svn: 187396
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index ac4eeaf0559..503b0e1b1d4 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -8612,7 +8612,9 @@ SDValue DAGCombiner::visitINSERT_VECTOR_ELT(SDNode *N) { // be converted to a BUILD_VECTOR). Fill in the Ops vector with the // vector elements. SmallVector<SDValue, 8> Ops; - if (InVec.getOpcode() == ISD::BUILD_VECTOR) { + // Do not combine these two vectors if the output vector will not replace + // the input vector. + if (InVec.getOpcode() == ISD::BUILD_VECTOR && InVec.hasOneUse()) { Ops.append(InVec.getNode()->op_begin(), InVec.getNode()->op_end()); } else if (InVec.getOpcode() == ISD::UNDEF) { |