1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+v,+d,+zfh,+zvfh -verify-machineinstrs < %s | FileCheck %s
3 ; RUN: llc -mtriple=riscv64 -mattr=+v,+d,+zfh,+zvfh -verify-machineinstrs < %s | FileCheck %s
5 define <vscale x 4 x i32> @splat_c3_nxv4i32(<vscale x 4 x i32> %v) {
6 ; CHECK-LABEL: splat_c3_nxv4i32:
8 ; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
9 ; CHECK-NEXT: vrgather.vi v10, v8, 3
10 ; CHECK-NEXT: vmv.v.v v8, v10
12 %x = extractelement <vscale x 4 x i32> %v, i32 3
13 %ins = insertelement <vscale x 4 x i32> poison, i32 %x, i32 0
14 %splat = shufflevector <vscale x 4 x i32> %ins, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
15 ret <vscale x 4 x i32> %splat
18 define <vscale x 4 x i32> @splat_idx_nxv4i32(<vscale x 4 x i32> %v, i64 %idx) {
19 ; CHECK-LABEL: splat_idx_nxv4i32:
21 ; CHECK-NEXT: vsetvli a1, zero, e32, m2, ta, ma
22 ; CHECK-NEXT: vrgather.vx v10, v8, a0
23 ; CHECK-NEXT: vmv.v.v v8, v10
25 %x = extractelement <vscale x 4 x i32> %v, i64 %idx
26 %ins = insertelement <vscale x 4 x i32> poison, i32 %x, i32 0
27 %splat = shufflevector <vscale x 4 x i32> %ins, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
28 ret <vscale x 4 x i32> %splat
31 define <vscale x 8 x i16> @splat_c4_nxv8i16(<vscale x 8 x i16> %v) {
32 ; CHECK-LABEL: splat_c4_nxv8i16:
34 ; CHECK-NEXT: vsetvli a0, zero, e16, m2, ta, ma
35 ; CHECK-NEXT: vrgather.vi v10, v8, 4
36 ; CHECK-NEXT: vmv.v.v v8, v10
38 %x = extractelement <vscale x 8 x i16> %v, i32 4
39 %ins = insertelement <vscale x 8 x i16> poison, i16 %x, i32 0
40 %splat = shufflevector <vscale x 8 x i16> %ins, <vscale x 8 x i16> poison, <vscale x 8 x i32> zeroinitializer
41 ret <vscale x 8 x i16> %splat
44 define <vscale x 8 x i16> @splat_idx_nxv8i16(<vscale x 8 x i16> %v, i64 %idx) {
45 ; CHECK-LABEL: splat_idx_nxv8i16:
47 ; CHECK-NEXT: vsetvli a1, zero, e16, m2, ta, ma
48 ; CHECK-NEXT: vrgather.vx v10, v8, a0
49 ; CHECK-NEXT: vmv.v.v v8, v10
51 %x = extractelement <vscale x 8 x i16> %v, i64 %idx
52 %ins = insertelement <vscale x 8 x i16> poison, i16 %x, i32 0
53 %splat = shufflevector <vscale x 8 x i16> %ins, <vscale x 8 x i16> poison, <vscale x 8 x i32> zeroinitializer
54 ret <vscale x 8 x i16> %splat
57 define <vscale x 2 x half> @splat_c1_nxv2f16(<vscale x 2 x half> %v) {
58 ; CHECK-LABEL: splat_c1_nxv2f16:
60 ; CHECK-NEXT: vsetvli a0, zero, e16, mf2, ta, ma
61 ; CHECK-NEXT: vrgather.vi v9, v8, 1
62 ; CHECK-NEXT: vmv1r.v v8, v9
64 %x = extractelement <vscale x 2 x half> %v, i32 1
65 %ins = insertelement <vscale x 2 x half> poison, half %x, i32 0
66 %splat = shufflevector <vscale x 2 x half> %ins, <vscale x 2 x half> poison, <vscale x 2 x i32> zeroinitializer
67 ret <vscale x 2 x half> %splat
70 define <vscale x 2 x half> @splat_idx_nxv2f16(<vscale x 2 x half> %v, i64 %idx) {
71 ; CHECK-LABEL: splat_idx_nxv2f16:
73 ; CHECK-NEXT: vsetvli a1, zero, e16, mf2, ta, ma
74 ; CHECK-NEXT: vrgather.vx v9, v8, a0
75 ; CHECK-NEXT: vmv1r.v v8, v9
77 %x = extractelement <vscale x 2 x half> %v, i64 %idx
78 %ins = insertelement <vscale x 2 x half> poison, half %x, i32 0
79 %splat = shufflevector <vscale x 2 x half> %ins, <vscale x 2 x half> poison, <vscale x 2 x i32> zeroinitializer
80 ret <vscale x 2 x half> %splat
83 define <vscale x 4 x float> @splat_c3_nxv4f32(<vscale x 4 x float> %v) {
84 ; CHECK-LABEL: splat_c3_nxv4f32:
86 ; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
87 ; CHECK-NEXT: vrgather.vi v10, v8, 3
88 ; CHECK-NEXT: vmv.v.v v8, v10
90 %x = extractelement <vscale x 4 x float> %v, i64 3
91 %ins = insertelement <vscale x 4 x float> poison, float %x, i32 0
92 %splat = shufflevector <vscale x 4 x float> %ins, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
93 ret <vscale x 4 x float> %splat
96 define <vscale x 4 x float> @splat_idx_nxv4f32(<vscale x 4 x float> %v, i64 %idx) {
97 ; CHECK-LABEL: splat_idx_nxv4f32:
99 ; CHECK-NEXT: vsetvli a1, zero, e32, m2, ta, ma
100 ; CHECK-NEXT: vrgather.vx v10, v8, a0
101 ; CHECK-NEXT: vmv.v.v v8, v10
103 %x = extractelement <vscale x 4 x float> %v, i64 %idx
104 %ins = insertelement <vscale x 4 x float> poison, float %x, i32 0
105 %splat = shufflevector <vscale x 4 x float> %ins, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
106 ret <vscale x 4 x float> %splat