diff --git a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td --- a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td +++ b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td @@ -277,8 +277,11 @@ return N->hasOneUse(); }]>; +def AArch64fabd_p : PatFrag<(ops node:$pg, node:$op1, node:$op2), + (AArch64fabs_mt node:$pg, (AArch64fsub_p node:$pg, node:$op1, node:$op2), undef)>; + def AArch64fneg_mt_nsz : PatFrag<(ops node:$pred, node:$op, node:$pt), - (AArch64fneg_mt node:$pred, node:$op, node:$pt), [{ + (AArch64fneg_mt node:$pred, node:$op, node:$pt), [{ return N->getFlags().hasNoSignedZeros(); }]>; @@ -469,6 +472,7 @@ defm FMINNM_ZPZZ : sve_fp_bin_pred_hfd; defm FMAX_ZPZZ : sve_fp_bin_pred_hfd; defm FMIN_ZPZZ : sve_fp_bin_pred_hfd; + defm FABD_ZPZZ : sve_fp_bin_pred_hfd; defm FDIV_ZPZZ : sve_fp_bin_pred_hfd; } // End HasSVEorStreamingSVE diff --git a/llvm/test/CodeGen/AArch64/sve-fp.ll b/llvm/test/CodeGen/AArch64/sve-fp.ll --- a/llvm/test/CodeGen/AArch64/sve-fp.ll +++ b/llvm/test/CodeGen/AArch64/sve-fp.ll @@ -581,6 +581,74 @@ ret %res } +; FABD + +define @fabd_nxv8f16( %a, %b) { +; CHECK-LABEL: fabd_nxv8f16: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.h +; CHECK-NEXT: fabd z0.h, p0/m, z0.h, z1.h +; CHECK-NEXT: ret + %sub = fsub %a, %b + %res = call @llvm.fabs.nxv8f16( %sub) + ret %res +} + +define @fabd_nxv4f16( %a, %b) { +; CHECK-LABEL: fabd_nxv4f16: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.s +; CHECK-NEXT: fabd z0.h, p0/m, z0.h, z1.h +; CHECK-NEXT: ret + %sub = fsub %a, %b + %res = call @llvm.fabs.nxv4f16( %sub) + ret %res +} + +define @fabd_nxv2f16( %a, %b) { +; CHECK-LABEL: fabd_nxv2f16: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.d +; CHECK-NEXT: fabd z0.h, p0/m, z0.h, z1.h +; CHECK-NEXT: ret + %sub = fsub %a, %b + %res = call @llvm.fabs.nxv2f16( %sub) + ret %res +} + +define @fabd_nxv4f32( %a, %b) { +; CHECK-LABEL: fabd_nxv4f32: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.s +; CHECK-NEXT: fabd z0.s, p0/m, z0.s, z1.s +; CHECK-NEXT: ret + %sub = fsub %a, %b + %res = call @llvm.fabs.nxv4f32( %sub) + ret %res +} + +define @fabd_nxv2f32( %a, %b) { +; CHECK-LABEL: fabd_nxv2f32: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.d +; CHECK-NEXT: fabd z0.s, p0/m, z0.s, z1.s +; CHECK-NEXT: ret + %sub = fsub %a, %b + %res = call @llvm.fabs.nxv2f32( %sub) + ret %res +} + +define @fabd_nxv2f64( %a, %b) { +; CHECK-LABEL: fabd_nxv2f64: +; CHECK: // %bb.0: +; CHECK-NEXT: ptrue p0.d +; CHECK-NEXT: fabd z0.d, p0/m, z0.d, z1.d +; CHECK-NEXT: ret + %sub = fsub %a, %b + %res = call @llvm.fabs.nxv2f64( %sub) + ret %res +} + ; maxnum minnum define @maxnum_nxv16f16( %a, %b) {