[PATCH] D149968: [AArch64][SVE] Predicated mul pattern
Dave Green via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 5 08:45:00 PDT 2023
dmgreen created this revision.
dmgreen added reviewers: paulwalker-arm, sdesmalen, david-arm, SjoerdMeijer, efriedma.
Herald added subscribers: psnobl, hiraditya, kristof.beyls, tschuett.
Herald added a project: All.
dmgreen requested review of this revision.
Herald added a project: LLVM.
This is a simple predicated mul pattern, selecting from `select(p, mul(x, y), x)`.
https://reviews.llvm.org/D149968
Files:
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
llvm/test/CodeGen/AArch64/sve-pred-selectop2.ll
Index: llvm/test/CodeGen/AArch64/sve-pred-selectop2.ll
===================================================================
--- llvm/test/CodeGen/AArch64/sve-pred-selectop2.ll
+++ llvm/test/CodeGen/AArch64/sve-pred-selectop2.ll
@@ -117,9 +117,8 @@
; CHECK-LABEL: mul_nxv2i64_x:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: ptrue p0.d
-; CHECK-NEXT: mul z1.d, z0.d, z1.d
; CHECK-NEXT: cmpgt p0.d, p0/z, z2.d, #0
-; CHECK-NEXT: mov z0.d, p0/m, z1.d
+; CHECK-NEXT: mul z0.d, p0/m, z0.d, z1.d
; CHECK-NEXT: ret
entry:
%c = icmp sgt <vscale x 2 x i64> %n, zeroinitializer
@@ -132,9 +131,8 @@
; CHECK-LABEL: mul_nxv4i32_x:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: ptrue p0.s
-; CHECK-NEXT: mul z1.s, z0.s, z1.s
; CHECK-NEXT: cmpgt p0.s, p0/z, z2.s, #0
-; CHECK-NEXT: mov z0.s, p0/m, z1.s
+; CHECK-NEXT: mul z0.s, p0/m, z0.s, z1.s
; CHECK-NEXT: ret
entry:
%c = icmp sgt <vscale x 4 x i32> %n, zeroinitializer
@@ -147,9 +145,8 @@
; CHECK-LABEL: mul_nxv8i16_x:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: ptrue p0.h
-; CHECK-NEXT: mul z1.h, z0.h, z1.h
; CHECK-NEXT: cmpgt p0.h, p0/z, z2.h, #0
-; CHECK-NEXT: mov z0.h, p0/m, z1.h
+; CHECK-NEXT: mul z0.h, p0/m, z0.h, z1.h
; CHECK-NEXT: ret
entry:
%c = icmp sgt <vscale x 8 x i16> %n, zeroinitializer
@@ -162,9 +159,8 @@
; CHECK-LABEL: mul_nxv16i8_x:
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: ptrue p0.b
-; CHECK-NEXT: mul z1.b, z0.b, z1.b
; CHECK-NEXT: cmpgt p0.b, p0/z, z2.b, #0
-; CHECK-NEXT: mov z0.b, p0/m, z1.b
+; CHECK-NEXT: mul z0.b, p0/m, z0.b, z1.b
; CHECK-NEXT: ret
entry:
%c = icmp sgt <vscale x 16 x i8> %n, zeroinitializer
Index: llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
===================================================================
--- llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
@@ -407,6 +407,9 @@
[(int_aarch64_sve_sub node:$pred, node:$op1, node:$op2),
(vselect node:$pred, (sub node:$op1, node:$op2), node:$op1),
(sub node:$op1, (vselect node:$pred, node:$op2, (SVEDup0)))]>;
+def AArch64mul_m1 : PatFrags<(ops node:$pred, node:$op1, node:$op2),
+ [(int_aarch64_sve_mul node:$pred, node:$op1, node:$op2),
+ (vselect node:$pred, (AArch64mul_p (AArch64ptrue 31), node:$op1, node:$op2), node:$op1)]>;
def AArch64mla_m1 : PatFrags<(ops node:$pred, node:$op1, node:$op2, node:$op3),
[(int_aarch64_sve_mla node:$pred, node:$op1, node:$op2, node:$op3),
// add(a, select(mask, mul(b, c), splat(0))) -> mla(a, mask, b, c)
@@ -529,7 +532,7 @@
defm UMIN_ZI : sve_int_arith_imm1_unsigned<0b11, "umin", AArch64umin_p>;
defm MUL_ZI : sve_int_arith_imm2<"mul", AArch64mul_p>;
- defm MUL_ZPmZ : sve_int_bin_pred_arit_2<0b000, "mul", "MUL_ZPZZ", int_aarch64_sve_mul, DestructiveBinaryComm>;
+ defm MUL_ZPmZ : sve_int_bin_pred_arit_2<0b000, "mul", "MUL_ZPZZ", AArch64mul_m1, DestructiveBinaryComm>;
defm SMULH_ZPmZ : sve_int_bin_pred_arit_2<0b010, "smulh", "SMULH_ZPZZ", int_aarch64_sve_smulh, DestructiveBinaryComm>;
defm UMULH_ZPmZ : sve_int_bin_pred_arit_2<0b011, "umulh", "UMULH_ZPZZ", int_aarch64_sve_umulh, DestructiveBinaryComm>;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149968.519879.patch
Type: text/x-patch
Size: 3432 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230505/e5cc9182/attachment.bin>
More information about the llvm-commits
mailing list