mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
[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
This commit is contained in:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user