summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2016-07-05 18:25:02 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2016-07-05 18:25:02 +0000
commit2d7938950850bbe77597c27c9bb743d9174468f3 (patch)
tree0ea30adac9dbf36d5516d1ddae9490f6d10881a6 /llvm/lib/CodeGen
parentd458c4de364138d34f77119d853ca278495beaae (diff)
downloadbcm5719-llvm-2d7938950850bbe77597c27c9bb743d9174468f3.tar.gz
bcm5719-llvm-2d7938950850bbe77597c27c9bb743d9174468f3.zip
DAGCombiner: Fold away vector extract of insert with the same index
This only really matters when the index is non-constant since the constant case already gets taken care of by other combines. llvm-svn: 274569
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index a8a76311225..6e6dfd855f8 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -12397,6 +12397,14 @@ SDValue DAGCombiner::visitEXTRACT_VECTOR_ELT(SDNode *N) {
return DAG.getNode(ISD::TRUNCATE, SDLoc(N), NVT, BCSrc);
}
+ // extract_vector_elt (insert_vector_elt vec, val, idx), idx) -> val
+ //
+ // This only really matters if the index is non-constant since other combines
+ // on the constant elements already work.
+ if (InVec.getOpcode() == ISD::INSERT_VECTOR_ELT &&
+ EltNo == InVec.getOperand(2))
+ return InVec.getOperand(1);
+
// Transform: (EXTRACT_VECTOR_ELT( VECTOR_SHUFFLE )) -> EXTRACT_VECTOR_ELT.
// We only perform this optimization before the op legalization phase because
// we may introduce new vector instructions which are not backed by TD
OpenPOWER on IntegriCloud