[PATCH] D104244: [SVE] Selection failure with scalable insertelements
Dylan Fleming via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 14 10:49:47 PDT 2021
DylanFleming-arm created this revision.
Herald added subscribers: psnobl, hiraditya, tschuett.
Herald added a reviewer: efriedma.
DylanFleming-arm requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D104244
Files:
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
llvm/test/CodeGen/AArch64/sve-insert-element.ll
Index: llvm/test/CodeGen/AArch64/sve-insert-element.ll
===================================================================
--- llvm/test/CodeGen/AArch64/sve-insert-element.ll
+++ llvm/test/CodeGen/AArch64/sve-insert-element.ll
@@ -273,3 +273,43 @@
%b = insertelement <vscale x 2 x double> undef, double %a, i32 0
ret <vscale x 2 x double> %b
}
+
+; Insert scalar at index
+define <vscale x 2 x half> @test_insert_with_index_nxv2f16(half %h, i64 %idx) {
+; CHECK-LABEL: test_insert_with_index_nxv2f16:
+; CHECK: // %bb.0:
+; CHECK-NEXT: mov z1.h, w0
+; CHECK-NEXT: index z2.h, #0, #1
+; CHECK-NEXT: ptrue p0.h
+; CHECK-NEXT: cmpeq p0.h, p0/z, z2.h, z1.h
+; CHECK-NEXT: mov z0.h, p0/m, h0
+; CHECK-NEXT: ret
+ %res = insertelement <vscale x 2 x half> undef, half %h, i64 %idx
+ ret <vscale x 2 x half> %res
+}
+
+define <vscale x 4 x half> @test_insert_with_index_nxv4f16(half %h, i64 %idx) {
+; CHECK-LABEL: test_insert_with_index_nxv4f16:
+; CHECK: // %bb.0:
+; CHECK-NEXT: mov z1.h, w0
+; CHECK-NEXT: index z2.h, #0, #1
+; CHECK-NEXT: ptrue p0.h
+; CHECK-NEXT: cmpeq p0.h, p0/z, z2.h, z1.h
+; CHECK-NEXT: mov z0.h, p0/m, h0
+; CHECK-NEXT: ret
+ %res = insertelement <vscale x 4 x half> undef, half %h, i64 %idx
+ ret <vscale x 4 x half> %res
+}
+
+define <vscale x 2 x float> @test_insert_with_index_nxv2f32(float %f, i64 %idx) {
+; CHECK-LABEL: test_insert_with_index_nxv2f32:
+; CHECK: // %bb.0:
+; CHECK-NEXT: mov z1.s, w0
+; CHECK-NEXT: index z2.s, #0, #1
+; CHECK-NEXT: ptrue p0.s
+; CHECK-NEXT: cmpeq p0.s, p0/z, z2.s, z1.s
+; CHECK-NEXT: mov z0.s, p0/m, s0
+; CHECK-NEXT: ret
+ %res = insertelement <vscale x 2 x float> undef, float %f, i64 %idx
+ ret <vscale x 2 x float> %res
+}
Index: llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
===================================================================
--- llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
@@ -2258,12 +2258,30 @@
GPR64:$src)>;
// Insert FP scalar into vector with scalar index
+ def : Pat<(nxv2f16 (vector_insert (nxv2f16 ZPR:$vec), (f16 FPR16:$src), GPR64:$index)),
+ (CPY_ZPmV_H ZPR:$vec,
+ (CMPEQ_PPzZZ_H (PTRUE_H 31),
+ (INDEX_II_H 0, 1),
+ (DUP_ZR_H (i32 (EXTRACT_SUBREG GPR64:$index, sub_32)))),
+ $src)>;
+ def : Pat<(nxv4f16 (vector_insert (nxv4f16 ZPR:$vec), (f16 FPR16:$src), GPR64:$index)),
+ (CPY_ZPmV_H ZPR:$vec,
+ (CMPEQ_PPzZZ_H (PTRUE_H 31),
+ (INDEX_II_H 0, 1),
+ (DUP_ZR_H (i32 (EXTRACT_SUBREG GPR64:$index, sub_32)))),
+ $src)>;
def : Pat<(nxv8f16 (vector_insert (nxv8f16 ZPR:$vec), (f16 FPR16:$src), GPR64:$index)),
(CPY_ZPmV_H ZPR:$vec,
(CMPEQ_PPzZZ_H (PTRUE_H 31),
(INDEX_II_H 0, 1),
(DUP_ZR_H (i32 (EXTRACT_SUBREG GPR64:$index, sub_32)))),
$src)>;
+ def : Pat<(nxv2f32 (vector_insert (nxv2f32 ZPR:$vec), (f32 FPR32:$src), GPR64:$index)),
+ (CPY_ZPmV_S ZPR:$vec,
+ (CMPEQ_PPzZZ_S (PTRUE_S 31),
+ (INDEX_II_S 0, 1),
+ (DUP_ZR_S (i32 (EXTRACT_SUBREG GPR64:$index, sub_32)))),
+ $src)>;
def : Pat<(nxv4f32 (vector_insert (nxv4f32 ZPR:$vec), (f32 FPR32:$src), GPR64:$index)),
(CPY_ZPmV_S ZPR:$vec,
(CMPEQ_PPzZZ_S (PTRUE_S 31),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104244.351927.patch
Type: text/x-patch
Size: 3772 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210614/e3aec26f/attachment.bin>
More information about the llvm-commits
mailing list