1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
2 ; RUN: llc --mtriple=loongarch64 --mattr=+lsx < %s | FileCheck %s
4 define void @extract_16xi8(ptr %src, ptr %dst) nounwind {
5 ; CHECK-LABEL: extract_16xi8:
7 ; CHECK-NEXT: vld $vr0, $a0, 0
8 ; CHECK-NEXT: vpickve2gr.b $a0, $vr0, 1
9 ; CHECK-NEXT: st.b $a0, $a1, 0
11 %v = load volatile <16 x i8>, ptr %src
12 %e = extractelement <16 x i8> %v, i32 1
17 define void @extract_8xi16(ptr %src, ptr %dst) nounwind {
18 ; CHECK-LABEL: extract_8xi16:
20 ; CHECK-NEXT: vld $vr0, $a0, 0
21 ; CHECK-NEXT: vpickve2gr.h $a0, $vr0, 1
22 ; CHECK-NEXT: st.h $a0, $a1, 0
24 %v = load volatile <8 x i16>, ptr %src
25 %e = extractelement <8 x i16> %v, i32 1
26 store i16 %e, ptr %dst
30 define void @extract_4xi32(ptr %src, ptr %dst) nounwind {
31 ; CHECK-LABEL: extract_4xi32:
33 ; CHECK-NEXT: vld $vr0, $a0, 0
34 ; CHECK-NEXT: vpickve2gr.w $a0, $vr0, 1
35 ; CHECK-NEXT: st.w $a0, $a1, 0
37 %v = load volatile <4 x i32>, ptr %src
38 %e = extractelement <4 x i32> %v, i32 1
39 store i32 %e, ptr %dst
43 define void @extract_2xi64(ptr %src, ptr %dst) nounwind {
44 ; CHECK-LABEL: extract_2xi64:
46 ; CHECK-NEXT: vld $vr0, $a0, 0
47 ; CHECK-NEXT: vpickve2gr.d $a0, $vr0, 1
48 ; CHECK-NEXT: st.d $a0, $a1, 0
50 %v = load volatile <2 x i64>, ptr %src
51 %e = extractelement <2 x i64> %v, i32 1
52 store i64 %e, ptr %dst
56 define void @extract_4xfloat(ptr %src, ptr %dst) nounwind {
57 ; CHECK-LABEL: extract_4xfloat:
59 ; CHECK-NEXT: vld $vr0, $a0, 0
60 ; CHECK-NEXT: vreplvei.w $vr0, $vr0, 1
61 ; CHECK-NEXT: fst.s $fa0, $a1, 0
63 %v = load volatile <4 x float>, ptr %src
64 %e = extractelement <4 x float> %v, i32 1
65 store float %e, ptr %dst
69 define void @extract_2xdouble(ptr %src, ptr %dst) nounwind {
70 ; CHECK-LABEL: extract_2xdouble:
72 ; CHECK-NEXT: vld $vr0, $a0, 0
73 ; CHECK-NEXT: vreplvei.d $vr0, $vr0, 1
74 ; CHECK-NEXT: fst.d $fa0, $a1, 0
76 %v = load volatile <2 x double>, ptr %src
77 %e = extractelement <2 x double> %v, i32 1
78 store double %e, ptr %dst
82 define void @extract_16xi8_idx(ptr %src, ptr %dst, i32 %idx) nounwind {
83 ; CHECK-LABEL: extract_16xi8_idx:
85 ; CHECK-NEXT: vld $vr0, $a0, 0
86 ; CHECK-NEXT: bstrpick.d $a0, $a2, 31, 0
87 ; CHECK-NEXT: vreplve.b $vr0, $vr0, $a0
88 ; CHECK-NEXT: movfr2gr.s $a0, $fa0
89 ; CHECK-NEXT: srai.w $a0, $a0, 24
90 ; CHECK-NEXT: st.b $a0, $a1, 0
92 %v = load volatile <16 x i8>, ptr %src
93 %e = extractelement <16 x i8> %v, i32 %idx
98 define void @extract_8xi16_idx(ptr %src, ptr %dst, i32 %idx) nounwind {
99 ; CHECK-LABEL: extract_8xi16_idx:
101 ; CHECK-NEXT: vld $vr0, $a0, 0
102 ; CHECK-NEXT: bstrpick.d $a0, $a2, 31, 0
103 ; CHECK-NEXT: vreplve.h $vr0, $vr0, $a0
104 ; CHECK-NEXT: movfr2gr.s $a0, $fa0
105 ; CHECK-NEXT: srai.w $a0, $a0, 16
106 ; CHECK-NEXT: st.h $a0, $a1, 0
108 %v = load volatile <8 x i16>, ptr %src
109 %e = extractelement <8 x i16> %v, i32 %idx
110 store i16 %e, ptr %dst
114 define void @extract_4xi32_idx(ptr %src, ptr %dst, i32 %idx) nounwind {
115 ; CHECK-LABEL: extract_4xi32_idx:
117 ; CHECK-NEXT: vld $vr0, $a0, 0
118 ; CHECK-NEXT: bstrpick.d $a0, $a2, 31, 0
119 ; CHECK-NEXT: vreplve.w $vr0, $vr0, $a0
120 ; CHECK-NEXT: movfr2gr.s $a0, $fa0
121 ; CHECK-NEXT: st.w $a0, $a1, 0
123 %v = load volatile <4 x i32>, ptr %src
124 %e = extractelement <4 x i32> %v, i32 %idx
125 store i32 %e, ptr %dst
129 define void @extract_2xi64_idx(ptr %src, ptr %dst, i32 %idx) nounwind {
130 ; CHECK-LABEL: extract_2xi64_idx:
132 ; CHECK-NEXT: vld $vr0, $a0, 0
133 ; CHECK-NEXT: bstrpick.d $a0, $a2, 31, 0
134 ; CHECK-NEXT: vreplve.d $vr0, $vr0, $a0
135 ; CHECK-NEXT: movfr2gr.d $a0, $fa0
136 ; CHECK-NEXT: st.d $a0, $a1, 0
138 %v = load volatile <2 x i64>, ptr %src
139 %e = extractelement <2 x i64> %v, i32 %idx
140 store i64 %e, ptr %dst
144 define void @extract_4xfloat_idx(ptr %src, ptr %dst, i32 %idx) nounwind {
145 ; CHECK-LABEL: extract_4xfloat_idx:
147 ; CHECK-NEXT: vld $vr0, $a0, 0
148 ; CHECK-NEXT: bstrpick.d $a0, $a2, 31, 0
149 ; CHECK-NEXT: vreplve.w $vr0, $vr0, $a0
150 ; CHECK-NEXT: fst.s $fa0, $a1, 0
152 %v = load volatile <4 x float>, ptr %src
153 %e = extractelement <4 x float> %v, i32 %idx
154 store float %e, ptr %dst
158 define void @extract_2xdouble_idx(ptr %src, ptr %dst, i32 %idx) nounwind {
159 ; CHECK-LABEL: extract_2xdouble_idx:
161 ; CHECK-NEXT: vld $vr0, $a0, 0
162 ; CHECK-NEXT: bstrpick.d $a0, $a2, 31, 0
163 ; CHECK-NEXT: vreplve.d $vr0, $vr0, $a0
164 ; CHECK-NEXT: fst.d $fa0, $a1, 0
166 %v = load volatile <2 x double>, ptr %src
167 %e = extractelement <2 x double> %v, i32 %idx
168 store double %e, ptr %dst