Skip to content

Commit 578c804

Browse files
davemgreenLukacma
authored andcommitted
[AArch64] Combing scalar_to_reg into DUP if the DUP already exists (llvm#160499)
If we already have a dup(x) as part of the DAG along with a scalar_to_vec(x), we can re-use the result of the dup to the scalar_to_vec(x).
1 parent f2cf116 commit 578c804

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27602,6 +27602,15 @@ static SDValue performPTestFirstCombine(SDNode *N,
2760227602
static SDValue
2760327603
performScalarToVectorCombine(SDNode *N, TargetLowering::DAGCombinerInfo &DCI,
2760427604
SelectionDAG &DAG) {
27605+
SDLoc DL(N);
27606+
27607+
// If a DUP(Op0) already exists, reuse it for the scalar_to_vector.
27608+
if (DCI.isAfterLegalizeDAG()) {
27609+
if (SDNode *LN = DCI.DAG.getNodeIfExists(AArch64ISD::DUP, N->getVTList(),
27610+
N->getOperand(0)))
27611+
return SDValue(LN, 0);
27612+
}
27613+
2760527614
// Let's do below transform.
2760627615
//
2760727616
// t34: v4i32 = AArch64ISD::UADDLV t2
@@ -27638,7 +27647,6 @@ performScalarToVectorCombine(SDNode *N, TargetLowering::DAGCombinerInfo &DCI,
2763827647
return SDValue();
2763927648

2764027649
// Let's generate new sequence with AArch64ISD::NVCAST.
27641-
SDLoc DL(N);
2764227650
SDValue EXTRACT_SUBVEC =
2764327651
DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, MVT::v2i32, UADDLV,
2764427652
DAG.getConstant(0, DL, MVT::i64));

llvm/test/CodeGen/AArch64/aarch64-matrix-umull-smull.ll

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,11 +1371,10 @@ define noundef <8 x i16> @cmplx_mul_combined_re_im(<8 x i16> noundef %a, i64 %sc
13711371
; CHECK-SD-NEXT: lsr x9, x0, #16
13721372
; CHECK-SD-NEXT: adrp x8, .LCPI14_0
13731373
; CHECK-SD-NEXT: dup v4.8h, w0
1374-
; CHECK-SD-NEXT: dup v1.8h, w9
1375-
; CHECK-SD-NEXT: fmov s3, w9
1376-
; CHECK-SD-NEXT: sqneg v2.8h, v1.8h
1377-
; CHECK-SD-NEXT: ldr q1, [x8, :lo12:.LCPI14_0]
1378-
; CHECK-SD-NEXT: tbl v1.16b, { v2.16b, v3.16b }, v1.16b
1374+
; CHECK-SD-NEXT: ldr q3, [x8, :lo12:.LCPI14_0]
1375+
; CHECK-SD-NEXT: dup v2.8h, w9
1376+
; CHECK-SD-NEXT: sqneg v1.8h, v2.8h
1377+
; CHECK-SD-NEXT: tbl v1.16b, { v1.16b, v2.16b }, v3.16b
13791378
; CHECK-SD-NEXT: rev32 v2.8h, v0.8h
13801379
; CHECK-SD-NEXT: sqdmull v3.4s, v0.4h, v4.4h
13811380
; CHECK-SD-NEXT: sqdmull2 v0.4s, v0.8h, v4.8h

0 commit comments

Comments
 (0)