summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2017-09-04 01:13:36 +0000
committerCraig Topper <craig.topper@intel.com>2017-09-04 01:13:36 +0000
commit76f44015e7043682977e3795d7bbb20cafa326a3 (patch)
tree054e9c8769fb60b433d2292be597247a05f360af /llvm/lib/Target
parent959fc08f3a22cc5c42fcbda40f52c9e8e93a193d (diff)
downloadbcm5719-llvm-76f44015e7043682977e3795d7bbb20cafa326a3.tar.gz
bcm5719-llvm-76f44015e7043682977e3795d7bbb20cafa326a3.zip
[X86] Add a combine to recognize when we have two insert subvectors that together write the whole vector, but the starting vector isn't undef.
In this case we should replace the starting vector with undef. llvm-svn: 312462
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/X86/X86ISelLowering.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index f7fe3e8add4..80f1afe310f 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -35750,6 +35750,18 @@ static SDValue combineInsertSubvector(SDNode *N, SelectionDAG &DAG,
return DAG.getNode(ISD::INSERT_SUBVECTOR, dl, OpVT,
getZeroVector(OpVT, Subtarget, DAG, dl), SubVec2,
Vec.getOperand(2));
+
+ // If we are inserting into both halves of the vector, the starting
+ // vector should be undef. If it isn't, make it so. Only do this if the
+ // the early insert has no other uses.
+ // TODO: Should this be a generic DAG combine?
+ if (!Vec.getOperand(0).isUndef() && Vec.hasOneUse()) {
+ Vec = DAG.getNode(ISD::INSERT_SUBVECTOR, dl, OpVT, DAG.getUNDEF(OpVT),
+ SubVec2, Vec.getOperand(2));
+ DCI.AddToWorklist(Vec.getNode());
+ return DAG.getNode(ISD::INSERT_SUBVECTOR, dl, OpVT, Vec, SubVec, Idx);
+
+ }
}
}
OpenPOWER on IntegriCloud