Skip to content

Commit adb7275

Browse files
[LLVM][CodeGen][SVE] Maintain existing predicate when lowering aarch64.sve.[s,u]abd.u intrinsics. (#170472)
1 parent 8e53a88 commit adb7275

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23386,11 +23386,15 @@ static SDValue performIntrinsicCombine(SDNode *N,
2338623386
return DAG.getNode(ISD::OR, SDLoc(N), N->getValueType(0), N->getOperand(2),
2338723387
N->getOperand(3));
2338823388
case Intrinsic::aarch64_sve_sabd_u:
23389-
return DAG.getNode(ISD::ABDS, SDLoc(N), N->getValueType(0),
23390-
N->getOperand(2), N->getOperand(3));
23389+
if (SDValue V = convertMergedOpToPredOp(N, ISD::ABDS, DAG, true))
23390+
return V;
23391+
return DAG.getNode(AArch64ISD::ABDS_PRED, SDLoc(N), N->getValueType(0),
23392+
N->getOperand(1), N->getOperand(2), N->getOperand(3));
2339123393
case Intrinsic::aarch64_sve_uabd_u:
23392-
return DAG.getNode(ISD::ABDU, SDLoc(N), N->getValueType(0),
23393-
N->getOperand(2), N->getOperand(3));
23394+
if (SDValue V = convertMergedOpToPredOp(N, ISD::ABDU, DAG, true))
23395+
return V;
23396+
return DAG.getNode(AArch64ISD::ABDU_PRED, SDLoc(N), N->getValueType(0),
23397+
N->getOperand(1), N->getOperand(2), N->getOperand(3));
2339423398
case Intrinsic::aarch64_sve_sdiv_u:
2339523399
return DAG.getNode(AArch64ISD::SDIV_PRED, SDLoc(N), N->getValueType(0),
2339623400
N->getOperand(1), N->getOperand(2), N->getOperand(3));

llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,11 @@ def AArch64urhadd : PatFrags<(ops node:$pg, node:$op1, node:$op2),
341341

342342
def AArch64saba : PatFrags<(ops node:$op1, node:$op2, node:$op3),
343343
[(int_aarch64_sve_saba node:$op1, node:$op2, node:$op3),
344-
(add node:$op1, (AArch64sabd_p (SVEAllActive), node:$op2, node:$op3))]>;
344+
(add node:$op1, (AArch64sabd_p (SVEAnyPredicate), node:$op2, node:$op3))]>;
345345

346346
def AArch64uaba : PatFrags<(ops node:$op1, node:$op2, node:$op3),
347347
[(int_aarch64_sve_uaba node:$op1, node:$op2, node:$op3),
348-
(add node:$op1, (AArch64uabd_p (SVEAllActive), node:$op2, node:$op3))]>;
348+
(add node:$op1, (AArch64uabd_p (SVEAnyPredicate), node:$op2, node:$op3))]>;
349349

350350
def AArch64usra : PatFrags<(ops node:$op1, node:$op2, node:$op3),
351351
[(int_aarch64_sve_usra node:$op1, node:$op2, node:$op3),

llvm/test/CodeGen/AArch64/sve-intrinsics-int-arith-undef.ll

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ define <vscale x 2 x i64> @mul_imm_i64(<vscale x 2 x i1> %pg, <vscale x 2 x i64>
327327
define <vscale x 16 x i8> @sabd_i8(<vscale x 16 x i1> %pg, <vscale x 16 x i8> %a, <vscale x 16 x i8> %b) {
328328
; CHECK-LABEL: sabd_i8:
329329
; CHECK: // %bb.0:
330-
; CHECK-NEXT: ptrue p0.b
331330
; CHECK-NEXT: sabd z0.b, p0/m, z0.b, z1.b
332331
; CHECK-NEXT: ret
333332
%out = call <vscale x 16 x i8> @llvm.aarch64.sve.sabd.u.nxv16i8(<vscale x 16 x i1> %pg,
@@ -339,7 +338,6 @@ define <vscale x 16 x i8> @sabd_i8(<vscale x 16 x i1> %pg, <vscale x 16 x i8> %a
339338
define <vscale x 8 x i16> @sabd_i16(<vscale x 8 x i1> %pg, <vscale x 8 x i16> %a, <vscale x 8 x i16> %b) {
340339
; CHECK-LABEL: sabd_i16:
341340
; CHECK: // %bb.0:
342-
; CHECK-NEXT: ptrue p0.h
343341
; CHECK-NEXT: sabd z0.h, p0/m, z0.h, z1.h
344342
; CHECK-NEXT: ret
345343
%out = call <vscale x 8 x i16> @llvm.aarch64.sve.sabd.u.nxv8i16(<vscale x 8 x i1> %pg,
@@ -351,7 +349,6 @@ define <vscale x 8 x i16> @sabd_i16(<vscale x 8 x i1> %pg, <vscale x 8 x i16> %a
351349
define <vscale x 4 x i32> @sabd_i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
352350
; CHECK-LABEL: sabd_i32:
353351
; CHECK: // %bb.0:
354-
; CHECK-NEXT: ptrue p0.s
355352
; CHECK-NEXT: sabd z0.s, p0/m, z0.s, z1.s
356353
; CHECK-NEXT: ret
357354
%out = call <vscale x 4 x i32> @llvm.aarch64.sve.sabd.u.nxv4i32(<vscale x 4 x i1> %pg,
@@ -363,7 +360,6 @@ define <vscale x 4 x i32> @sabd_i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a
363360
define <vscale x 2 x i64> @sabd_i64(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %a, <vscale x 2 x i64> %b) {
364361
; CHECK-LABEL: sabd_i64:
365362
; CHECK: // %bb.0:
366-
; CHECK-NEXT: ptrue p0.d
367363
; CHECK-NEXT: sabd z0.d, p0/m, z0.d, z1.d
368364
; CHECK-NEXT: ret
369365
%out = call <vscale x 2 x i64> @llvm.aarch64.sve.sabd.u.nxv2i64(<vscale x 2 x i1> %pg,
@@ -883,7 +879,6 @@ define <vscale x 2 x i64> @subr_imm_i64(<vscale x 2 x i1> %pg, <vscale x 2 x i64
883879
define <vscale x 16 x i8> @uabd_i8(<vscale x 16 x i1> %pg, <vscale x 16 x i8> %a, <vscale x 16 x i8> %b) {
884880
; CHECK-LABEL: uabd_i8:
885881
; CHECK: // %bb.0:
886-
; CHECK-NEXT: ptrue p0.b
887882
; CHECK-NEXT: uabd z0.b, p0/m, z0.b, z1.b
888883
; CHECK-NEXT: ret
889884
%out = call <vscale x 16 x i8> @llvm.aarch64.sve.uabd.u.nxv16i8(<vscale x 16 x i1> %pg,
@@ -895,7 +890,6 @@ define <vscale x 16 x i8> @uabd_i8(<vscale x 16 x i1> %pg, <vscale x 16 x i8> %a
895890
define <vscale x 8 x i16> @uabd_i16(<vscale x 8 x i1> %pg, <vscale x 8 x i16> %a, <vscale x 8 x i16> %b) {
896891
; CHECK-LABEL: uabd_i16:
897892
; CHECK: // %bb.0:
898-
; CHECK-NEXT: ptrue p0.h
899893
; CHECK-NEXT: uabd z0.h, p0/m, z0.h, z1.h
900894
; CHECK-NEXT: ret
901895
%out = call <vscale x 8 x i16> @llvm.aarch64.sve.uabd.u.nxv8i16(<vscale x 8 x i1> %pg,
@@ -907,7 +901,6 @@ define <vscale x 8 x i16> @uabd_i16(<vscale x 8 x i1> %pg, <vscale x 8 x i16> %a
907901
define <vscale x 4 x i32> @uabd_i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
908902
; CHECK-LABEL: uabd_i32:
909903
; CHECK: // %bb.0:
910-
; CHECK-NEXT: ptrue p0.s
911904
; CHECK-NEXT: uabd z0.s, p0/m, z0.s, z1.s
912905
; CHECK-NEXT: ret
913906
%out = call <vscale x 4 x i32> @llvm.aarch64.sve.uabd.u.nxv4i32(<vscale x 4 x i1> %pg,
@@ -919,7 +912,6 @@ define <vscale x 4 x i32> @uabd_i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a
919912
define <vscale x 2 x i64> @uabd_i64(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %a, <vscale x 2 x i64> %b) {
920913
; CHECK-LABEL: uabd_i64:
921914
; CHECK: // %bb.0:
922-
; CHECK-NEXT: ptrue p0.d
923915
; CHECK-NEXT: uabd z0.d, p0/m, z0.d, z1.d
924916
; CHECK-NEXT: ret
925917
%out = call <vscale x 2 x i64> @llvm.aarch64.sve.uabd.u.nxv2i64(<vscale x 2 x i1> %pg,

0 commit comments

Comments
 (0)