[llvm] 44a0cd2 - [DAG] visitINSERT_VECTOR_ELT - add <1 x ???> insert_vector_elt(v0,extract_vector_elt(v1,0),0) special case handling
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 11 11:30:16 PDT 2022
Author: Simon Pilgrim
Date: 2022-06-11T19:30:00+01:00
New Revision: 44a0cd25dfdf613ca119c8aa97060b8aa139c7ca
URL: https://github.com/llvm/llvm-project/commit/44a0cd25dfdf613ca119c8aa97060b8aa139c7ca
DIFF: https://github.com/llvm/llvm-project/commit/44a0cd25dfdf613ca119c8aa97060b8aa139c7ca.diff
LOG: [DAG] visitINSERT_VECTOR_ELT - add <1 x ???> insert_vector_elt(v0,extract_vector_elt(v1,0),0) special case handling
Check if we're just replacing one v1x?? vector with another
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/AArch64/arm64-neon-copy.ll
llvm/test/CodeGen/ARM/neon-copy.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 6ba9a07952f30..ca5a804c5f996 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -19353,9 +19353,19 @@ SDValue DAGCombiner::visitINSERT_VECTOR_ELT(SDNode *N) {
// We must know which element is being inserted for folds below here.
unsigned Elt = IndexC->getZExtValue();
+
if (SDValue Shuf = combineInsertEltToShuffle(N, Elt))
return Shuf;
+ // Handle <1 x ???> vector insertion special cases.
+ if (VT.getVectorNumElements() == 1) {
+ // insert_vector_elt(x, extract_vector_elt(y, 0), 0) -> y
+ if (InVal.getOpcode() == ISD::EXTRACT_VECTOR_ELT &&
+ InVal.getOperand(0).getValueType() == VT &&
+ isNullConstant(InVal.getOperand(1)))
+ return InVal.getOperand(0);
+ }
+
// Canonicalize insert_vector_elt dag nodes.
// Example:
// (insert_vector_elt (insert_vector_elt A, Idx0), Idx1)
diff --git a/llvm/test/CodeGen/AArch64/arm64-neon-copy.ll b/llvm/test/CodeGen/AArch64/arm64-neon-copy.ll
index 6f539cd139c42..ab398850fb929 100644
--- a/llvm/test/CodeGen/AArch64/arm64-neon-copy.ll
+++ b/llvm/test/CodeGen/AArch64/arm64-neon-copy.ll
@@ -332,10 +332,6 @@ define <2 x i32> @ins2s2(<2 x i32> %tmp1, <2 x i32> %tmp2) {
define <1 x i64> @ins1d1(<1 x i64> %tmp1, <1 x i64> %tmp2) {
; CHECK-LABEL: ins1d1:
; CHECK: // %bb.0:
-; CHECK-NEXT: // kill: def $d1 killed $d1 def $q1
-; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
-; CHECK-NEXT: mov v1.d[0], v0.d[0]
-; CHECK-NEXT: fmov d0, d1
; CHECK-NEXT: ret
%tmp3 = extractelement <1 x i64> %tmp1, i32 0
%tmp4 = insertelement <1 x i64> %tmp2, i64 %tmp3, i32 0
diff --git a/llvm/test/CodeGen/ARM/neon-copy.ll b/llvm/test/CodeGen/ARM/neon-copy.ll
index c7598e96a4b9f..cbaf8c8f6bb62 100644
--- a/llvm/test/CodeGen/ARM/neon-copy.ll
+++ b/llvm/test/CodeGen/ARM/neon-copy.ll
@@ -327,11 +327,6 @@ define <2 x i32> @ins2s2(<2 x i32> %tmp1, <2 x i32> %tmp2) {
define <1 x i64> @ins1d1(<1 x i64> %tmp1, <1 x i64> %tmp2) {
; CHECK-LABEL: ins1d1:
; CHECK: @ %bb.0:
-; CHECK-NEXT: vmov.32 r0, d0[0]
-; CHECK-NEXT: vmov.32 r1, d0[1]
-; CHECK-NEXT: vmov.32 d1[0], r0
-; CHECK-NEXT: vmov.32 d1[1], r1
-; CHECK-NEXT: vorr d0, d1, d1
; CHECK-NEXT: bx lr
%tmp3 = extractelement <1 x i64> %tmp1, i32 0
%tmp4 = insertelement <1 x i64> %tmp2, i64 %tmp3, i32 0
More information about the llvm-commits
mailing list