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 | 75c9433b49b1e4e2d7e61249c3cd0e3ce910d5c8 (patch) | |
tree | 8d078de34703eaec736eb7137ce1939821713c3a /lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
parent | 3466fb11b70e5512fe15c94b8da99596e69c39cf (diff) | |
download | llvm-75c9433b49b1e4e2d7e61249c3cd0e3ce910d5c8.tar.gz llvm-75c9433b49b1e4e2d7e61249c3cd0e3ce910d5c8.tar.bz2 llvm-75c9433b49b1e4e2d7e61249c3cd0e3ce910d5c8.tar.xz |
[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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187396 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index ac4eeaf055..503b0e1b1d 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/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) { |